lorj 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +6 -3
- data/lib/core/core.rb +9 -10
- data/lib/core/definition.rb +9 -2
- data/lib/core/lorj-basedefinition.rb +69 -9
- data/lib/core/lorj-baseprocess.rb +6 -1
- data/lib/core_process/CloudProcess.rb +9 -6
- data/lib/core_process/global_process.rb +184 -88
- data/lib/core_process/network_process.rb +96 -94
- data/lib/lorj/version.rb +1 -1
- data/lib/lorj.rb +2 -5
- data/lib/prc-config.rb +12 -5
- data/lib/prc-logging.rb +80 -2
- data/lib/prc.rb +23 -0
- data/lib/providers/hpcloud/Hpcloud.rb +28 -21
- data/lib/providers/hpcloud/compute.rb +5 -0
- data/lorj.gemspec +29 -26
- metadata +36 -7
@@ -37,19 +37,19 @@
|
|
37
37
|
# ---------------------------------------------------------------------------
|
38
38
|
# Network/Subnetwork Management
|
39
39
|
# ---------------------------------------------------------------------------
|
40
|
-
class CloudProcess
|
40
|
+
class CloudProcess
|
41
41
|
# Process Query handler
|
42
42
|
def forj_query_network(sCloudObj, sQuery, hParams)
|
43
43
|
|
44
44
|
|
45
45
|
# Call Provider query function
|
46
|
-
|
46
|
+
controller_query(sObjectType, sControlerQuery)
|
47
47
|
end
|
48
48
|
|
49
49
|
# Process Create handler
|
50
50
|
def forj_get_or_create_network(sCloudObj, hParams)
|
51
51
|
|
52
|
-
|
52
|
+
PrcLib.state("Searching for network '%s'" % [hParams[:network_name]])
|
53
53
|
networks = find_network(sCloudObj, hParams)
|
54
54
|
if networks.length == 0
|
55
55
|
network = create_network(sCloudObj, hParams)
|
@@ -65,7 +65,8 @@ class CloudProcess < BaseProcess
|
|
65
65
|
config[:subnetwork_name] = hParams[:subnetwork_name]
|
66
66
|
end
|
67
67
|
|
68
|
-
object.Create(:subnetwork)
|
68
|
+
#object.Create(:subnetwork)
|
69
|
+
Create(:subnetwork)
|
69
70
|
|
70
71
|
network
|
71
72
|
|
@@ -76,7 +77,7 @@ class CloudProcess < BaseProcess
|
|
76
77
|
begin
|
77
78
|
oProvider.delete(sCloudObj, hParams)
|
78
79
|
rescue => e
|
79
|
-
|
80
|
+
PrcLib.error("%s\n%s" % [e.message, e.backtrace.join("\n")])
|
80
81
|
end
|
81
82
|
end
|
82
83
|
|
@@ -84,7 +85,7 @@ class CloudProcess < BaseProcess
|
|
84
85
|
begin
|
85
86
|
oProvider.get(sCloudObj, sID, hParams)
|
86
87
|
rescue => e
|
87
|
-
|
88
|
+
PrcLib.error("%s\n%s" % [e.message, e.backtrace.join("\n")])
|
88
89
|
end
|
89
90
|
end
|
90
91
|
|
@@ -97,11 +98,11 @@ class CloudProcess < BaseProcess
|
|
97
98
|
def create_network(sCloudObj, hParams)
|
98
99
|
name = hParams[:network_name]
|
99
100
|
begin
|
100
|
-
|
101
|
-
network =
|
102
|
-
|
101
|
+
PrcLib.state("Creating network '%s'" % [name])
|
102
|
+
network = controller_create(sCloudObj)
|
103
|
+
PrcLib.info("Network '%s' created" % [network[:name]])
|
103
104
|
rescue => e
|
104
|
-
|
105
|
+
PrcLib.fatal(1, "Unable to create network '%s'" % [name, e])
|
105
106
|
end
|
106
107
|
network
|
107
108
|
end
|
@@ -114,33 +115,33 @@ class CloudProcess < BaseProcess
|
|
114
115
|
begin
|
115
116
|
# retrieve the Provider collection object.
|
116
117
|
sQuery = {:name => hParams[:network_name]}
|
117
|
-
oList =
|
118
|
+
oList = controller_query(sCloudObj, sQuery)
|
118
119
|
query_single(sCloudObj, oList, sQuery, hParams[:network_name])
|
119
120
|
rescue => e
|
120
|
-
|
121
|
+
PrcLib.error("%s\n%s" % [e.message, e.backtrace.join("\n")])
|
121
122
|
end
|
122
123
|
end
|
123
124
|
|
124
125
|
def forj_get_or_create_subnetwork(sCloudObj, hParams)
|
125
126
|
|
126
|
-
|
127
|
+
PrcLib.state("Searching for sub-network attached to network '%s'" % [hParams[:network, :name]])
|
127
128
|
#######################
|
128
129
|
begin
|
129
130
|
sQuery = { :network_id => hParams[:network, :id] }
|
130
|
-
subnets =
|
131
|
+
subnets = controller_query(:subnetwork, sQuery)
|
131
132
|
rescue => e
|
132
|
-
|
133
|
+
PrcLib.error("%s\n%s" % [e.message, e.backtrace.join("\n")])
|
133
134
|
end
|
134
135
|
if subnets
|
135
136
|
case subnets.length()
|
136
137
|
when 0
|
137
|
-
|
138
|
+
PrcLib.info("No subnet found from '%s' network" % [hParams[:network, :name]])
|
138
139
|
subnet = ForjLib::Data.new
|
139
140
|
when 1
|
140
|
-
|
141
|
+
PrcLib.info("Found '%s' subnet from '%s' network" % [subnets[0, :name], hParams[:network, :name]])
|
141
142
|
subnet = subnets[0]
|
142
143
|
else
|
143
|
-
|
144
|
+
PrcLib.warning("Several subnet was found on '%s'. Choosing the first one = '%s'" % [hParams[:network, :name], subnets[0, :name]])
|
144
145
|
subnet = subnets[0]
|
145
146
|
end
|
146
147
|
end
|
@@ -149,7 +150,7 @@ class CloudProcess < BaseProcess
|
|
149
150
|
begin
|
150
151
|
subnet = create_subnet(sCloudObj, hParams)
|
151
152
|
rescue => e
|
152
|
-
|
153
|
+
PrcLib.error("%s\n%s" % [e.message, e.backtrace.join("\n")])
|
153
154
|
end
|
154
155
|
end
|
155
156
|
register(subnet)
|
@@ -158,12 +159,12 @@ class CloudProcess < BaseProcess
|
|
158
159
|
|
159
160
|
def create_subnet(sCloudObj, hParams)
|
160
161
|
name = hParams[:subnetwork_name]
|
161
|
-
|
162
|
+
PrcLib.state("Creating subnet '%s'" % [name])
|
162
163
|
begin
|
163
|
-
subnet =
|
164
|
-
|
164
|
+
subnet = controller_create(sCloudObj)
|
165
|
+
PrcLib.info("Subnet '%s' created." % [subnet[:name]])
|
165
166
|
rescue => e
|
166
|
-
|
167
|
+
PrcLib.fatal(1, "Unable to create '%s' subnet." % name, e)
|
167
168
|
end
|
168
169
|
subnet
|
169
170
|
end
|
@@ -173,12 +174,12 @@ class CloudProcess < BaseProcess
|
|
173
174
|
oNetworkConnect = get_cloudObj(:network_connection)
|
174
175
|
oSubNetwork = get_cloudObj(:subnetwork)
|
175
176
|
|
176
|
-
|
177
|
+
PrcLib.state("Deleting subnet '%s'" % [oSubNetwork.name])
|
177
178
|
begin
|
178
179
|
provider_delete_subnetwork(oNetworkConnect, oSubNetwork)
|
179
180
|
oNetworkConnect.subnets.get(oSubNetwork.id).destroy
|
180
181
|
rescue => e
|
181
|
-
|
182
|
+
PrcLib.error("%s\n%s" % [e.message, e.backtrace.join("\n")])
|
182
183
|
end
|
183
184
|
end
|
184
185
|
end
|
@@ -205,17 +206,17 @@ class CloudProcess
|
|
205
206
|
router = create_router(router_name) if not router or router.empty?
|
206
207
|
create_router_interface(oSubNetwork, router) if router and not router.empty?
|
207
208
|
else
|
208
|
-
sQuery = {:id =>
|
209
|
-
routers =
|
209
|
+
sQuery = {:id => router_port[:device_id]}
|
210
|
+
routers = controller_query(:router, sQuery)
|
210
211
|
case routers.length()
|
211
|
-
|
212
|
-
|
212
|
+
when 1
|
213
|
+
PrcLib.info("Found router '%s' attached to the network '%s'." % [
|
213
214
|
routers[0, :name],
|
214
|
-
|
215
|
+
hParams[:network, :name]
|
215
216
|
])
|
216
217
|
router = routers[0]
|
217
218
|
else
|
218
|
-
|
219
|
+
PrcLib.warning("Unable to find the router id '%s'" % [ router_port[:device_id]])
|
219
220
|
router = ForjLib::Data.new
|
220
221
|
|
221
222
|
end
|
@@ -224,7 +225,7 @@ class CloudProcess
|
|
224
225
|
end
|
225
226
|
|
226
227
|
def forj_update_router(sCloudObj, hParams)
|
227
|
-
|
228
|
+
controller_update(sCloudObj)
|
228
229
|
################################
|
229
230
|
#routers[0].external_gateway_info = { 'network_id' => external_network.id }
|
230
231
|
#routers[0].save
|
@@ -235,18 +236,18 @@ class CloudProcess
|
|
235
236
|
#------------------------------------#
|
236
237
|
|
237
238
|
def get_router(name)
|
238
|
-
|
239
|
+
PrcLib.state("Searching for router '%s'" % [name] )
|
239
240
|
begin
|
240
|
-
routers =
|
241
|
+
routers = controller_query(:router, {:name => name})
|
241
242
|
case routers.length()
|
242
243
|
when 1
|
243
244
|
routers[0]
|
244
245
|
else
|
245
|
-
|
246
|
+
PrcLib.info("Router '%s' not found." % [ name ] )
|
246
247
|
ForjLib::Data.new
|
247
248
|
end
|
248
249
|
rescue => e
|
249
|
-
|
250
|
+
PrcLib.error("%s\n%s" % [e.message, e.backtrace.join("\n")])
|
250
251
|
end
|
251
252
|
end
|
252
253
|
|
@@ -254,17 +255,17 @@ class CloudProcess
|
|
254
255
|
begin
|
255
256
|
if oExternalNetwork
|
256
257
|
sExtNet = get_data(oExternalNetwork, :name)
|
257
|
-
|
258
|
+
PrcLib.state("Creating router '%s' attached to the external Network '%s'" % [router_name, sExtNet])
|
258
259
|
config[:external_gateway_id] = get_data(oExternalNetwork, :id)
|
259
260
|
else
|
260
|
-
|
261
|
+
PrcLib.state("Creating router '%s' without external Network" % [router_name])
|
261
262
|
end
|
262
263
|
|
263
|
-
router =
|
264
|
+
router = controller_create(:router)
|
264
265
|
if oExternalNetwork
|
265
|
-
|
266
|
+
PrcLib.info("Router '%s' created and attached to the external Network '%s'." % [router_name, sExtNet])
|
266
267
|
else
|
267
|
-
|
268
|
+
PrcLib.info("Router '%s' created without external Network." % [router_name])
|
268
269
|
end
|
269
270
|
rescue => e
|
270
271
|
raise ForjError.new(), "Unable to create '%s' router\n%s" % [router_name, e.message]
|
@@ -273,13 +274,13 @@ class CloudProcess
|
|
273
274
|
end
|
274
275
|
|
275
276
|
def delete_router(oNetworkConnect, oRouter)
|
276
|
-
|
277
|
+
PrcLib.state("Deleting router '%s'" % [router.name])
|
277
278
|
begin
|
278
279
|
#################
|
279
280
|
provider_delete_router(oNetworkConnect, oRouter)
|
280
281
|
# oNetworkConnect.routers.get(router.id).destroy
|
281
282
|
rescue => e
|
282
|
-
|
283
|
+
PrcLib.error("Unable to delete '%s' router ID" % router_id, e)
|
283
284
|
end
|
284
285
|
end
|
285
286
|
|
@@ -287,49 +288,49 @@ class CloudProcess
|
|
287
288
|
# Router interface to connect to the network
|
288
289
|
def create_router_interface(oSubnet, oRouter)
|
289
290
|
|
290
|
-
|
291
|
+
PrcLib.state("Attaching subnet '%s' to router '%s'" % [oSubnet[:name], oRouter[:name]])
|
291
292
|
begin
|
292
|
-
|
293
|
+
controller_create(:router_interface)
|
293
294
|
|
294
295
|
#################
|
295
296
|
#provider_add_interface()
|
296
297
|
# oRouter.add_interface(oSubnet.id, nil)
|
297
298
|
rescue => e
|
298
|
-
|
299
|
+
PrcLib.error("%s\n%s" % [e.message, e.backtrace.join("\n")])
|
299
300
|
end
|
300
301
|
end
|
301
302
|
|
302
303
|
def delete_router_interface(oSubnet, oRouter)
|
303
|
-
|
304
|
+
PrcLib.state("Removing subnet '%s' from router '%s'" % [oSubnet.name, oRouter.name])
|
304
305
|
subnet_id = oSubnet.id
|
305
306
|
begin
|
306
307
|
#################
|
307
308
|
oRouter.remove_interface(subnet_id)
|
308
309
|
rescue => e
|
309
|
-
|
310
|
+
PrcLib.error("%s\n%s" % [e.message, e.backtrace.join("\n")])
|
310
311
|
end
|
311
312
|
end
|
312
313
|
|
313
314
|
def get_router_interface_attached(sCloudObj, hParams)
|
314
315
|
|
315
316
|
oNetwork = hParams[:network]
|
316
|
-
|
317
|
+
PrcLib.state("Searching for router port attached to the network '%s'" % [hParams[:network, :name]] )
|
317
318
|
begin
|
318
319
|
# Searching for router port attached
|
319
320
|
#################
|
320
321
|
sQuery = {:network_id => hParams[:network, :id], :device_owner => 'network:router_interface'}
|
321
322
|
|
322
|
-
ports =
|
323
|
+
ports = controller_query(sCloudObj, sQuery)
|
323
324
|
case ports.length()
|
324
325
|
when 0
|
325
|
-
|
326
|
+
PrcLib.info("No router port attached to the network '%s'" % [hParams[:network, :name] ])
|
326
327
|
ForjLib::Data.new
|
327
328
|
else
|
328
|
-
|
329
|
+
PrcLib.info("Found a router port attached to the network '%s' " % [hParams[:network, :name] ] )
|
329
330
|
ports[0]
|
330
331
|
end
|
331
332
|
rescue => e
|
332
|
-
|
333
|
+
PrcLib.error("%s\n%s" % [e.message, e.backtrace.join("\n")])
|
333
334
|
end
|
334
335
|
end
|
335
336
|
|
@@ -338,38 +339,38 @@ class CloudProcess
|
|
338
339
|
|
339
340
|
return nil if not name or not oNetworkConnect
|
340
341
|
|
341
|
-
|
342
|
+
PrcLib.state("Getting gateway '%s'" % [name])
|
342
343
|
networks = oNetworkConnect
|
343
344
|
begin
|
344
345
|
netty = networks.get(name)
|
345
346
|
rescue => e
|
346
|
-
|
347
|
+
PrcLib.error("%s\n%s" % [e.message, e.backtrace.join("\n")])
|
347
348
|
end
|
348
|
-
|
349
|
-
|
349
|
+
PrcLib.state("Found gateway '%s'" % [name]) if netty
|
350
|
+
PrcLib.state("Unable to find gateway '%s'" % [name]) if not netty
|
350
351
|
return netty
|
351
352
|
end
|
352
353
|
|
353
354
|
def query_external_network(hParams)
|
354
|
-
|
355
|
+
PrcLib.state("Identifying External gateway")
|
355
356
|
begin
|
356
357
|
# Searching for router port attached
|
357
358
|
#################
|
358
359
|
sQuery = { :router_external => true }
|
359
|
-
networks =
|
360
|
+
networks = controller_query(:network, sQuery)
|
360
361
|
case networks.length()
|
361
362
|
when 0
|
362
|
-
|
363
|
+
PrcLib.info("No external network")
|
363
364
|
ForjLib::Data.new
|
364
365
|
when 1
|
365
|
-
|
366
|
+
PrcLib.info("Found external network '%s'." % [networks[0, :name] ] )
|
366
367
|
networks[0]
|
367
368
|
else
|
368
|
-
|
369
|
+
PrcLib.warn("Found several external networks. Selecting the first one '%s'" % [networks[0, :name]] )
|
369
370
|
networks[0]
|
370
371
|
end
|
371
372
|
rescue => e
|
372
|
-
|
373
|
+
PrcLib.error("%s\n%s" % [e.message, e.backtrace.join("\n")])
|
373
374
|
end
|
374
375
|
end
|
375
376
|
|
@@ -384,19 +385,19 @@ class CloudProcess
|
|
384
385
|
# Process Create handler
|
385
386
|
def forj_get_or_create_sg(sCloudObj, hParams)
|
386
387
|
sSGName = hParams[:security_group]
|
387
|
-
|
388
|
+
PrcLib.state("Searching for security group '%s'" % [sSGName] )
|
388
389
|
|
389
390
|
security_group = forj_query_sg(sCloudObj, {:name => sSGName}, hParams)
|
390
391
|
security_group = create_security_group(sCloudObj, hParams) if not security_group
|
391
392
|
register(security_group)
|
392
393
|
|
393
|
-
|
394
|
+
PrcLib.info('Configuring Security Group \'%s\'' % [sSGName])
|
394
395
|
ports = config.get(:ports)
|
395
396
|
|
396
397
|
ports.each do |port|
|
397
398
|
port = port.to_s if port.class != String
|
398
399
|
if not (/^\d+(-\d+)?$/ =~ port)
|
399
|
-
|
400
|
+
PrcLib.error("Port '%s' is not valid. Must be <Port> or <PortMin>-<PortMax>" % [port])
|
400
401
|
else
|
401
402
|
mPortFound = /^(\d+)(-(\d+))?$/.match(port)
|
402
403
|
portmin = mPortFound[1]
|
@@ -408,7 +409,8 @@ class CloudProcess
|
|
408
409
|
config[:port_max] = portmax.to_i
|
409
410
|
config[:addr_map] = '0.0.0.0/0'
|
410
411
|
|
411
|
-
object.Create(:rule)
|
412
|
+
#object.Create(:rule)
|
413
|
+
Create(:rule)
|
412
414
|
end
|
413
415
|
end
|
414
416
|
security_group
|
@@ -432,19 +434,19 @@ class CloudProcess
|
|
432
434
|
oSSLError=SSLErrorMgt.new
|
433
435
|
|
434
436
|
begin
|
435
|
-
sgroups =
|
437
|
+
sgroups = controller_query(sCloudObj, sQuery)
|
436
438
|
rescue => e
|
437
439
|
if not oSSLError.ErrorDetected(e.message,e.backtrace, e)
|
438
440
|
retry
|
439
441
|
end
|
440
|
-
|
442
|
+
PrcLib.fatal(1, "Unable to get list of security groups.", e)
|
441
443
|
end
|
442
444
|
case sgroups.length()
|
443
445
|
when 0
|
444
|
-
|
446
|
+
PrcLib.info("No security group '%s' found" % [ hParams[:security_group] ] )
|
445
447
|
nil
|
446
448
|
when 1
|
447
|
-
|
449
|
+
PrcLib.info("Found security group '%s'" % [sgroups[0, :name]])
|
448
450
|
sgroups[0]
|
449
451
|
end
|
450
452
|
end
|
@@ -452,12 +454,12 @@ class CloudProcess
|
|
452
454
|
# SecurityGroups Process internal functions #
|
453
455
|
#-------------------------------------------#
|
454
456
|
def create_security_group(sCloudObj, hParams)
|
455
|
-
|
457
|
+
PrcLib.state("Creating security group '%s'" % hParams[:security_group])
|
456
458
|
begin
|
457
|
-
sg =
|
458
|
-
|
459
|
+
sg = controller_create(sCloudObj)
|
460
|
+
PrcLib.info("Security group '%s' created." % sg[:name])
|
459
461
|
rescue => e
|
460
|
-
|
462
|
+
PrcLib.error("%s\n%s" % [e.message, e.backtrace.join("\n")])
|
461
463
|
end
|
462
464
|
sg
|
463
465
|
end
|
@@ -470,7 +472,7 @@ class CloudProcess
|
|
470
472
|
|
471
473
|
oSSLError=SSLErrorMgt.new
|
472
474
|
begin
|
473
|
-
|
475
|
+
controller_delete(sCloudObj)
|
474
476
|
rescue => e
|
475
477
|
if not oSSLError.ErrorDetected(e.message,e.backtrace, e)
|
476
478
|
retry
|
@@ -481,14 +483,14 @@ class CloudProcess
|
|
481
483
|
# Process Query handler
|
482
484
|
def forj_query_rule(sCloudObj, sQuery, hParams)
|
483
485
|
sRule = '%s %s:%s - %s to %s' % [ hParams[:dir], hParams[:rule_proto], hParams[:port_min], hParams[:port_max], hParams[:addr_map] ]
|
484
|
-
|
486
|
+
PrcLib.state("Searching for rule '%s'" % [ sRule ])
|
485
487
|
oSSLError = SSLErrorMgt.new
|
486
488
|
begin
|
487
489
|
sInfo = {
|
488
490
|
:items => [:dir, :rule_proto, :port_min, :port_max, :addr_map],
|
489
491
|
:items_form => '%s %s:%s - %s to %s'
|
490
492
|
}
|
491
|
-
oList =
|
493
|
+
oList = controller_query(sCloudObj, sQuery)
|
492
494
|
query_single(sCloudObj, oList, sQuery, sRule, sInfo)
|
493
495
|
rescue => e
|
494
496
|
if not oSSLError.ErrorDetected(e.message,e.backtrace, e)
|
@@ -522,16 +524,16 @@ class CloudProcess
|
|
522
524
|
def create_rule(sCloudObj, hParams)
|
523
525
|
|
524
526
|
sRule = '%s %s:%s - %s to %s' % [ hParams[:dir], hParams[:rule_proto], hParams[:port_min], hParams[:port_max], hParams[:addr_map] ]
|
525
|
-
|
527
|
+
PrcLib.state("Creating rule '%s'" % [sRule])
|
526
528
|
oSSLError=SSLErrorMgt.new
|
527
529
|
begin
|
528
|
-
rule =
|
529
|
-
|
530
|
+
rule = controller_create(sCloudObj)
|
531
|
+
PrcLib.info("Rule '%s' created." % [sRule])
|
530
532
|
rescue StandardError => e
|
531
533
|
if not oSSLError.ErrorDetected(e.message,e.backtrace, e)
|
532
534
|
retry
|
533
535
|
end
|
534
|
-
|
536
|
+
PrcLib.error 'error creating the rule for port %s' % [sRule]
|
535
537
|
end
|
536
538
|
rule
|
537
539
|
end
|
@@ -544,24 +546,24 @@ end
|
|
544
546
|
class CloudProcess
|
545
547
|
def forj_get_or_create_ext_net(sCloudObj, hParams)
|
546
548
|
|
547
|
-
|
549
|
+
PrcLib.state("Checking router '%s' gateway" % hParams[:router, :name])
|
548
550
|
|
549
551
|
oRouter = hParams[:router]
|
550
552
|
sRouterName = hParams[:router, :name]
|
551
553
|
sNetworkId = hParams[:router, :gateway_network_id]
|
552
554
|
if sNetworkId
|
553
555
|
external_network = forj_query_external_network(sCloudObj, {:id => sNetworkId}, hParams)
|
554
|
-
|
556
|
+
PrcLib.info("Router '%s' is attached to the external gateway '%s'." % [ sRouterName, external_network[:name] ] )
|
555
557
|
else
|
556
|
-
|
557
|
-
|
558
|
+
PrcLib.info("Router '%s' needs to be attached to an external gateway." % [ sRouterName ] )
|
559
|
+
PrcLib.state("Attaching")
|
558
560
|
external_network = forj_query_external_network(:network, {}, hParams)
|
559
561
|
if not external_network.empty?
|
560
562
|
oRouter[:gateway_network_id] = external_network[:id]
|
561
563
|
forj_update_router(:router, hParams)
|
562
|
-
|
564
|
+
PrcLib.info("Router '%s' attached to the external network '%s'." % [ sRouterName, external_network[:name] ])
|
563
565
|
else
|
564
|
-
|
566
|
+
PrcLib.fatal(1, "Unable to attach router '%s' to an external gateway. Required for boxes to get internet access. " % [ get_data(:router, :name) ] )
|
565
567
|
end
|
566
568
|
end
|
567
569
|
|
@@ -571,24 +573,24 @@ class CloudProcess
|
|
571
573
|
end
|
572
574
|
|
573
575
|
def forj_query_external_network(sCloudObj, sQuery, hParams)
|
574
|
-
|
576
|
+
PrcLib.state("Identifying External gateway")
|
575
577
|
begin
|
576
578
|
# Searching for external network
|
577
|
-
networks =
|
579
|
+
networks = controller_query(:network, sQuery.merge({ :external => true }))
|
578
580
|
|
579
581
|
case networks.length()
|
580
582
|
when 0
|
581
|
-
|
583
|
+
PrcLib.info("No external network")
|
582
584
|
nil
|
583
585
|
when 1
|
584
|
-
|
586
|
+
PrcLib.info("Found external network '%s'." % [networks[0, :name] ])
|
585
587
|
networks[0]
|
586
588
|
else
|
587
|
-
|
589
|
+
PrcLib.warning("Found several external networks. Selecting the first one '%s'" % [networks[0, :name]])
|
588
590
|
networks[0]
|
589
591
|
end
|
590
592
|
rescue => e
|
591
|
-
|
593
|
+
PrcLib.error("%s\n%s" % [e.message, e.backtrace.join("\n")])
|
592
594
|
end
|
593
595
|
end
|
594
596
|
|
data/lib/lorj/version.rb
CHANGED
data/lib/lorj.rb
CHANGED
@@ -41,11 +41,8 @@ require "core/definition_internal" # Lorj internal functions
|
|
41
41
|
|
42
42
|
module Lorj
|
43
43
|
slib_forj = File.dirname(__FILE__)
|
44
|
-
$FORJ_LIB = File.expand_path(File.join(File.dirname(slib_forj),'lib'))
|
45
44
|
|
45
|
+
PrcLib.lib_path = File.expand_path(File.join(File.dirname(slib_forj),'lib'))
|
46
46
|
|
47
|
-
|
48
|
-
|
49
|
-
$PROVIDERS_PATH = File.expand_path(File.join($FORJ_LIB, "providers"))
|
50
|
-
$CORE_PROCESS_PATH = File.join($FORJ_LIB, "core_process")
|
47
|
+
PrcLib.core_level = 0
|
51
48
|
end
|
data/lib/prc-config.rb
CHANGED
@@ -152,7 +152,7 @@ module Lorj
|
|
152
152
|
#
|
153
153
|
# rhSet(yVal, 'blabla', :test2, 'text') => :test
|
154
154
|
# # yVal = {:test2 => {:test5 => :test, 'text' => 'blabla'}, :test5 => :test }
|
155
|
-
def
|
155
|
+
def self::rhSet(yVal, value, *p)
|
156
156
|
if p.length() == 0
|
157
157
|
return yVal
|
158
158
|
end
|
@@ -192,7 +192,7 @@ module Lorj
|
|
192
192
|
# - hash of hashes updated.
|
193
193
|
# * *Raises* :
|
194
194
|
# Nothing
|
195
|
-
def
|
195
|
+
def self.rhKeyToSymbol(yVal, levels = 1)
|
196
196
|
return nil if yVal.nil? or yVal.class != Hash
|
197
197
|
yRes = {}
|
198
198
|
yVal.each { | key, value |
|
@@ -223,7 +223,7 @@ module Lorj
|
|
223
223
|
# - false : all key path are symbols.
|
224
224
|
# * *Raises* :
|
225
225
|
# Nothing
|
226
|
-
def
|
226
|
+
def self.rhKeyToSymbol?(yVal, levels = 1)
|
227
227
|
return false if yVal.nil? or yVal.class != Hash
|
228
228
|
yVal.each { | key, value |
|
229
229
|
if key.class == String
|
@@ -360,6 +360,8 @@ module Lorj
|
|
360
360
|
# * *Raises* :
|
361
361
|
# - ++ ->
|
362
362
|
def self.meta_each
|
363
|
+
return nil if Lorj::rhGet(@@yDefaults, :sections).nil?
|
364
|
+
|
363
365
|
Lorj::rhGet(@@yDefaults, :sections).each { | section, hValue |
|
364
366
|
hValue.each { | key, value |
|
365
367
|
yield section, key, value
|
@@ -458,9 +460,14 @@ module Lorj
|
|
458
460
|
|
459
461
|
PrcLib.info("Reading default configuration '%s'..." % @@sDefaultsName)
|
460
462
|
|
461
|
-
|
463
|
+
if File.exists?(@@sDefaultsName)
|
464
|
+
@@yDefaults = YAML.load_file(@@sDefaultsName)
|
465
|
+
|
466
|
+
self.build_section_mapping
|
467
|
+
else
|
468
|
+
PrcLib.warning("PrcLib.app_defaults is set to '%s'. Trying to load '%s' but not found. Application defaults won't be loaded." % [PrcLib.app_defaults, @@sDefaultsName])
|
469
|
+
end
|
462
470
|
|
463
|
-
self.build_section_mapping
|
464
471
|
end
|
465
472
|
end
|
466
473
|
|