nitos_testbed_rc 2.0.3 → 2.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MmJiNmRhODcwNTk1Mzc5YmVjZmZlYWI1NmViYTY4ZDZiOGQ2NjUyNg==
4
+ ZTZiYmVkMDBiZDFjNzI0NTIwZDNkMjk2Yjg4ODJjOTU3NzhkODc5Mg==
5
5
  data.tar.gz: !binary |-
6
- ZDYzOTU5YjM1MmVjMTNiMzkzZDEzOGE1ZDA0MWMwYjBhZjJhNTAzMg==
6
+ MzEwNTRlODAwYzc3NmYwZWFhNmI2ZDg1NzlmNzVkMzNiODg0ZTgxOQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZmNjMDVlZDQ4YTMyZGI4MTg2NDM4MjJiNjIxZTRmMjZiMzlkZjZjMzkwZDlh
10
- YTQ1OGViMzU3ZjkzYjE2Y2ZiZWUwYjFjYzRlZDE3YjlkZmZlOGY4ZjNjZWI3
11
- ZGU1ZDlhNjA5MGFkYjZjMjlmZTYyNWUwODlmYzNlNjJiZDViZjc=
9
+ YmFlNzgyNGQzOGMzZjE5YjMxMWJlZmQxMjYwOTY0OGFiZDc1OTQ2N2ViNmVm
10
+ Yzk5YzNjYzUyYmE2YzkyMTQxYzdjMDZjMmY2NjRmZWFlMzQzYWMxODY5YzY5
11
+ Y2QxMzZiNjQyOWM0N2ZmOThkNjQ3NWI1MTZmMjY0YTA0MmNiYmI=
12
12
  data.tar.gz: !binary |-
13
- NjUzMWZlOWRkMTc1YmJkZmVhYzAzOWRjMTA1ZmIwOWZmYTk1YjRiMjhjZDJk
14
- NTBiMmM1OTgzYWY5MzdkYzEyZTgwZmE5M2I5MDUyZGVkMjZiMjdjMGEzOTVj
15
- ZDc3OWVkZGI0M2EwOTEzYzI5NmFiNTFmZmYwNjMyNDNjZDYyMDE=
13
+ NDFhNTNjYWY4NDFiOGNmNjdiN2U4MGViYjRlYmFjYzM1YzgxN2E5MGMxYzVk
14
+ ODk5ZDQ4OTA5NDkyMmVlNmU4ZWY5MDMxM2U0YzE1ODUzMWQzNzM3MGVhZGI4
15
+ YTM4MzI1YmRhYWIyNGI0ZmY2Y2U2MDAzMjVhZWExMzJhMDg2YjU=
data/README.md CHANGED
@@ -36,9 +36,9 @@ Then you need to run the install_ntrc script to generate the configuration files
36
36
 
37
37
  $ install_ntrc
38
38
 
39
- Hint: If you have an installed nitos_testbed_rc gem and want to keep the configuration files, execute install_ntrc script with --no_conf flag.
39
+ Hint: If you have an installed nitos_testbed_rc gem and want to keep the configuration files, execute install_ntrc script with -nc flag.
40
40
 
41
- $ install_ntrc --no_conf
41
+ $ install_ntrc -nc
42
42
 
43
43
  Create certificates
44
44
  -------------------
data/bin/cm_proxy CHANGED
@@ -16,6 +16,7 @@ $stdout.sync = true
16
16
  @xmpp = @config[:xmpp]
17
17
 
18
18
  require 'nitos_testbed_rc/cm_factory'
19
+ require 'nitos_testbed_rc/cm'
19
20
 
20
21
  cm_entity_cert = File.expand_path(@auth[:entity_cert])
21
22
  cm_entity_key = File.expand_path(@auth[:entity_key])
@@ -53,7 +54,7 @@ class CmPDP
53
54
  return msg# next
54
55
  end
55
56
 
56
- node_name = msg.properties.state.node
57
+ node_name = msg.properties.respond_to?(:state) ? msg.properties.state.node : msg.properties[:state][:node]
57
58
  broker = @config[:broker_url]
58
59
 
59
60
  uri = URI.parse("#{broker}/resources/nodes?name=#{node_name}")
@@ -104,7 +105,11 @@ class CmPDP
104
105
 
105
106
  if acc == 'root'
106
107
  debug "AUTH PASSED (root account)"
107
- msg.properties.state.node = nod
108
+ if msg.properties.respond_to?(:state)
109
+ msg.properties.state.node = nod
110
+ else
111
+ msg.properties[:state][:node] = nod
112
+ end
108
113
  return msg
109
114
  end
110
115
 
@@ -126,7 +131,11 @@ class CmPDP
126
131
  return msg
127
132
  else
128
133
  debug "AUTH PASSED"
129
- msg.properties.state.node = nod
134
+ if msg.properties.respond_to?(:state)
135
+ msg.properties.state.node = nod
136
+ else
137
+ msg.properties[:state][:node] = nod
138
+ end
130
139
  return msg
131
140
  end
132
141
  # wait = true
@@ -228,9 +237,7 @@ OmfCommon.init(@config[:operationMode], opts) do |el|#communication: { url: "xmp
228
237
  info "CM Factory >> Connected to XMPP server"
229
238
  cmFact = OmfRc::ResourceFactory.create(:cm_factory, { uid: 'cm_factory', certificate: cm_entity })
230
239
 
231
- comm.on_interrupted {
232
- cmFact.disconnect
233
- }
240
+ comm.on_interrupted { cmFact.disconnect }
234
241
  end
235
242
  end
236
243
 
data/bin/omf6 CHANGED
@@ -82,7 +82,7 @@ def create_frisbeed(comm, fcontroller, port, options)
82
82
  end
83
83
 
84
84
  #run frisbee client on a node
85
- def create_frisbee(comm, fcontroller, node, port, options, progress_bar)
85
+ def create_frisbee(comm, fcontroller, cm_controller, node, port, options, progress_bar)
86
86
  fcontroller.create(:frisbee, hrn: 'frisbee client', port: port, node_topic: "#{node.to_s}") do |reply_msg|
87
87
  if reply_msg.success?
88
88
  client = reply_msg.resource
@@ -111,75 +111,74 @@ def create_frisbee(comm, fcontroller, node, port, options, progress_bar)
111
111
  else
112
112
  puts "ERROR: Frisbee client stopped unexpectedly with no error message."
113
113
  end
114
- comm.subscribe('cm_factory') do |controller|
115
- controller.on_message do |cm_msg|
116
- if cm_msg.operation == :inform
117
- case cm_msg.read_content("itype")
118
- when 'STATUS'
119
- unless cm_msg.read_property("current").nil? || cm_msg.read_property("desired").nil?
120
- if cm_msg.read_property("current").to_sym == :pxe_off && cm_msg.read_property("desired").to_sym == :pxe_off
121
- n = cm_msg.read_property("node")
122
- @nodes_up_without_pxe << n
123
- if @nodes_up_pxe.length == (@nodes_up_without_pxe.length + @nodes_failed_without_pxe.length)
124
- # puts "INFO: Load proccess completed."
125
- # fcontroller.release(@@server) do |reply_msg|
126
- # shut_down(comm)
127
- # end
128
- stop_loading(comm)
129
- end
130
- end
131
- end
132
- when 'ERROR'
133
- case cm_msg.read_property("event_type")
134
- when "AUTH"
135
- puts "ERROR AUTH: #{cm_msg.read_property("msg")}"
136
- n = cm_msg.read_property("node_name")
137
- @nodes_failed_without_pxe << n
138
- if (@nodes_up_without_pxe.length + @nodes_failed_without_pxe.length) == options[:target_nodes].length
114
+
115
+ cm_controller.on_message do |cm_msg|
116
+ if cm_msg.operation == :inform
117
+ case cm_msg.read_content("itype")
118
+ when 'STATUS'
119
+ unless cm_msg.read_property("current").nil? || cm_msg.read_property("desired").nil?
120
+ if cm_msg.read_property("current").to_sym == :pxe_off && cm_msg.read_property("desired").to_sym == :pxe_off
121
+ n = cm_msg.read_property("node")
122
+ @nodes_up_without_pxe << n
123
+ if @nodes_up_pxe.length == (@nodes_up_without_pxe.length + @nodes_failed_without_pxe.length)
124
+ # puts "INFO: Load proccess completed."
125
+ # fcontroller.release(@@server) do |reply_msg|
126
+ # shut_down(comm)
127
+ # end
139
128
  stop_loading(comm)
140
129
  end
141
- when "HTTP"
142
- puts "ERROR HTTP: #{cm_msg.read_property("msg")}"
143
- n = cm_msg.read_property("node_name")
144
- if @nodes_retrying_without_pxe.include?(n)
145
- @nodes_retrying_without_pxe.delete(n)
146
- @nodes_failed_without_pxe << n
147
- if (@nodes_up_without_pxe.length + @nodes_failed_without_pxe.length) == options[:target_nodes].length
148
- stop_loading(comm)
149
- end
150
- else
151
- @nodes_retrying_without_pxe << n
152
- controller.configure(state: {node: n.to_sym, status: :start_on_pxe})
153
- end
154
- when "TIME_OUT"
155
- puts "ERROR TIME_OUT: #{cm_msg.read_property("msg")}"
156
- n = cm_msg.read_property("node_name")
130
+ end
131
+ end
132
+ when 'ERROR'
133
+ case cm_msg.read_property("event_type")
134
+ when "AUTH"
135
+ puts "ERROR AUTH: #{cm_msg.read_property("msg")}"
136
+ n = cm_msg.read_property("node_name")
137
+ @nodes_failed_without_pxe << n
138
+ if (@nodes_up_without_pxe.length + @nodes_failed_without_pxe.length) == options[:target_nodes].length
139
+ stop_loading(comm)
140
+ end
141
+ when "HTTP"
142
+ puts "ERROR HTTP: #{cm_msg.read_property("msg")}"
143
+ n = cm_msg.read_property("node_name")
144
+ if @nodes_retrying_without_pxe.include?(n)
145
+ @nodes_retrying_without_pxe.delete(n)
157
146
  @nodes_failed_without_pxe << n
158
147
  if (@nodes_up_without_pxe.length + @nodes_failed_without_pxe.length) == options[:target_nodes].length
159
148
  stop_loading(comm)
160
149
  end
161
150
  else
162
- error cm_msg.read_content('reason') if cm_msg.read_content("reason")
151
+ @nodes_retrying_without_pxe << n
152
+ controller.configure(state: {node: n.to_sym, status: :start_on_pxe})
163
153
  end
164
- when 'WARN'
165
- warn cm_msg.read_content('reason') if cm_msg.read_content("reason")
154
+ when "TIME_OUT"
155
+ puts "ERROR TIME_OUT: #{cm_msg.read_property("msg")}"
156
+ n = cm_msg.read_property("node_name")
157
+ @nodes_failed_without_pxe << n
158
+ if (@nodes_up_without_pxe.length + @nodes_failed_without_pxe.length) == options[:target_nodes].length
159
+ stop_loading(comm)
160
+ end
161
+ else
162
+ error cm_msg.read_content('reason') if cm_msg.read_content("reason")
166
163
  end
164
+ when 'WARN'
165
+ warn cm_msg.read_content('reason') if cm_msg.read_content("reason")
167
166
  end
168
167
  end
169
- unless options[:wait]
170
- controller.configure(state: {node: node.to_sym, status: options[:last_action].to_sym, wait: options[:wait]})
171
- @nodes_reset += 1
172
- if @nodes_reset == @nodes_up_pxe.length
173
- @load_end_msg.split("\n").each {|line| puts "INFO: #{line}"}
174
- stop_loading(comm)
175
- end
176
- else
177
- puts "INFO: Trying to #{options[:last_action]} node '#{client_msg.read_property("node")}' out of PXE."
178
- controller.configure(state: {node: node.to_sym, status: :start_without_pxe, last_action: options[:last_action]})
179
- @nodes_reset += 1
180
- if @nodes_reset == @nodes_up_pxe.length
181
- @load_end_msg.split("\n").each {|line| puts "INFO: #{line}"}
182
- end
168
+ end
169
+ unless options[:wait]
170
+ cm_controller.configure(state: {node: node.to_sym, status: options[:last_action].to_sym, wait: options[:wait]})
171
+ @nodes_reset += 1
172
+ if @nodes_reset == @nodes_up_pxe.length
173
+ @load_end_msg.split("\n").each {|line| puts "INFO: #{line}"}
174
+ stop_loading(comm)
175
+ end
176
+ else
177
+ puts "INFO: Trying to #{options[:last_action]} node '#{client_msg.read_property("node")}' out of PXE."
178
+ cm_controller.configure(state: {node: node.to_sym, status: :start_without_pxe, last_action: options[:last_action]})
179
+ @nodes_reset += 1
180
+ if @nodes_reset == @nodes_up_pxe.length
181
+ @load_end_msg.split("\n").each {|line| puts "INFO: #{line}"}
183
182
  end
184
183
  end
185
184
  end
@@ -210,7 +209,7 @@ def stop_loading(comm)
210
209
  end
211
210
 
212
211
 
213
- def start_load(comm, options, node)
212
+ def start_load(comm, cm_controller, options, node)
214
213
  if @nodes_up_pxe.length == 0
215
214
  puts "ERROR: ALL Nodes failled to boot on PXE."
216
215
  shut_down(comm)
@@ -232,7 +231,7 @@ def start_load(comm, options, node)
232
231
  @nodes_up_pxe.each do |node|
233
232
  puts "INFO: Starting Loading Procedure on node '#{node}'"
234
233
  @load_complete[node] = 0
235
- create_frisbee(comm, @fcontroller, node, port, options, prog_bar) #frisbee client
234
+ create_frisbee(comm, @fcontroller, cm_controller, node, port, options, prog_bar) #frisbee client
236
235
  end
237
236
  prog_bar.count = 0
238
237
  prog_bar.write
@@ -291,63 +290,72 @@ def load(comm, options)
291
290
  @nodes_failed_pxe = []
292
291
  nodes_retrying_pxe = []
293
292
  port = nil
294
- controller.on_message do |m|
295
- if m.operation == :inform
296
- case m.read_content("itype")
297
- when 'STATUS'
298
- unless m.read_property("current").nil? && m.read_property("desired").nil?
299
- if m.read_property("current").to_sym == :pxe_on && m.read_property("desired").to_sym == :pxe_on
300
- n = m.read_property("node_name")
301
- @nodes_up_pxe << n
302
- print_until_timeout "INFO: Node '#{n}' has booted on PXE."
303
- start_load(comm, options, n)
304
- else
305
- print_until_timeout "ERROR: exit code: #{m.read_content('exit_code')}" if m.read_content('exit_code')
293
+ controller.create(:cm, hrn: "cm") do |reply_msg|
294
+ if reply_msg.success?
295
+ cm_res = reply_msg.resource
296
+ cm_res.on_subscribed do
297
+ cm_res.on_message do |m|
298
+ if options[:target_nodes].include?(m.read_property('node_name')) && m.operation == :inform
299
+ case m.read_content("itype")
300
+ when 'STATUS'
301
+ unless m.read_property("current").nil? && m.read_property("desired").nil?
302
+ if m.read_property("current").to_sym == :pxe_on && m.read_property("desired").to_sym == :pxe_on
303
+ n = m.read_property("node_name")
304
+ @nodes_up_pxe << n
305
+ print_until_timeout "INFO: Node '#{n}' has booted on PXE."
306
+ start_load(comm, cm_res, options, n)
307
+ else
308
+ print_until_timeout "ERROR: exit code: #{m.read_content('exit_code')}" if m.read_content('exit_code')
309
+ end
310
+ end
311
+ when 'ERROR'
312
+ case m.read_property("event_type")
313
+ when "AUTH"
314
+ print_until_timeout "ERROR AUTH: #{m.read_property("msg")}"
315
+ n = m.read_property("node_name")
316
+ @nodes_failed_pxe << n
317
+ start_load(comm, cm_res, options, n)
318
+ when "HTTP"
319
+ print_until_timeout "ERROR HTTP: #{m.read_property("msg")}"
320
+ n = m.read_property("node_name")
321
+ if nodes_retrying_pxe.include?(n)
322
+ nodes_retrying_pxe.delete(n)
323
+ @nodes_failed_pxe << n
324
+ start_load(comm, cm_res, options, n)
325
+ else
326
+ nodes_retrying_pxe << n
327
+ controller.configure(state: {node: n.to_sym, status: :start_on_pxe})
328
+ end
329
+ when "TIME_OUT"
330
+ print_until_timeout "ERROR TIME_OUT: #{m.read_property("msg")}"
331
+ n = m.read_property("node_name")
332
+ @nodes_failed_pxe << n
333
+ start_load(comm, cm_res, options, n)
334
+ else
335
+ print_until_timeout "ERROR: #{ m.read_content('reason')}" if m.read_content("reason")
336
+ end
337
+ when 'WARN'
338
+ print_until_timeout "WARN: #{ cm_msg.read_content('reason')}" if m.read_content("reason")
339
+ end
306
340
  end
307
341
  end
308
- when 'ERROR'
309
- case m.read_property("event_type")
310
- when "AUTH"
311
- print_until_timeout "ERROR AUTH: #{m.read_property("msg")}"
312
- n = m.read_property("node_name")
313
- @nodes_failed_pxe << n
314
- start_load(comm, options, n)
315
- when "HTTP"
316
- print_until_timeout "ERROR HTTP: #{m.read_property("msg")}"
317
- n = m.read_property("node_name")
318
- if nodes_retrying_pxe.include?(n)
319
- nodes_retrying_pxe.delete(n)
320
- @nodes_failed_pxe << n
321
- start_load(comm, options, n)
322
- else
323
- nodes_retrying_pxe << n
324
- controller.configure(state: {node: n.to_sym, status: :start_on_pxe})
325
- end
326
- when "TIME_OUT"
327
- print_until_timeout "ERROR TIME_OUT: #{m.read_property("msg")}"
328
- n = m.read_property("node_name")
329
- @nodes_failed_pxe << n
330
- start_load(comm, options, n)
331
- else
332
- print_until_timeout "ERROR: #{ m.read_content('reason')}" if m.read_content("reason")
342
+ options[:target_nodes].each do |node|
343
+ cm_res.configure(state: {node: node.to_sym, status: :start_on_pxe})
333
344
  end
334
- when 'WARN'
335
- print_until_timeout "WARN: #{ cm_msg.read_content('reason')}" if m.read_content("reason")
345
+ puts "INFO: Waiting for target nodes to boot on PXE."
346
+ @waiting = true
347
+ @time = 0
348
+ wait_until_timeout(1){
349
+ while waiting?
350
+ sleep 1 # Simulate a task taking an unknown amount of time
351
+ @time += 1
352
+ end
353
+ }
336
354
  end
355
+ else
356
+ error reply_msg.inspect
337
357
  end
338
358
  end
339
- options[:target_nodes].each do |node|
340
- controller.configure(state: {node: node.to_sym, status: :start_on_pxe})
341
- end
342
- puts "INFO: Waiting for target nodes to boot on PXE."
343
- @waiting = true
344
- @time = 0
345
- wait_until_timeout(1){
346
- while waiting?
347
- sleep 1 # Simulate a task taking an unknown amount of time
348
- @time += 1
349
- end
350
- }
351
359
  else
352
360
  error controller.inspect
353
361
  end
@@ -411,7 +419,7 @@ def create_imagezip_server(comm, fcontroller, port, options)
411
419
  end
412
420
 
413
421
  #run imagezip client on a node
414
- def create_imagezip_client(comm, fcontroller, node, port, options)
422
+ def create_imagezip_client(comm, fcontroller, cm_controller, node, port, options)
415
423
  fcontroller.create(:imagezip_client, {hrn: 'imagezip client', port: port, node_topic: "#{node.to_s}"}) do |reply_msg|
416
424
  if reply_msg.success?
417
425
  client = reply_msg.resource
@@ -432,60 +440,61 @@ def create_imagezip_client(comm, fcontroller, node, port, options)
432
440
  end
433
441
  puts "INFO: Image was saved in '#{@frisbee[:imageDir]}/#{@image}'"
434
442
  puts "INFO:"
435
- comm.subscribe('cm_factory') do |controller|
436
- controller.on_message do |cm_msg|
437
- if cm_msg.operation == :inform
438
- case cm_msg.read_content("itype")
439
- when 'STATUS'
440
- unless cm_msg.read_property("current").nil? && cm_msg.read_property("desired").nil?
441
- if cm_msg.read_property("current").to_sym == :pxe_off && cm_msg.read_property("desired").to_sym == :pxe_off
442
- puts "INFO: Save proccess completed."
443
- fcontroller.release(@@server) do |reply_msg|
444
- shut_down(comm)
445
- end
446
- end
447
- end
448
- when 'ERROR'
449
- case cm_msg.read_property("event_type")
450
- when "AUTH"
451
- puts "ERROR AUTH: #{cm_msg.read_property("msg")}"
443
+
444
+ cm_controller.on_message do |cm_msg|
445
+ if cm_msg.operation == :inform
446
+ case cm_msg.read_content("itype")
447
+ when 'STATUS'
448
+ unless cm_msg.read_property("current").nil? && cm_msg.read_property("desired").nil?
449
+ if cm_msg.read_property("current").to_sym == :pxe_off && cm_msg.read_property("desired").to_sym == :pxe_off
450
+ puts "INFO: Save proccess completed."
452
451
  fcontroller.release(@@server) do |reply_msg|
453
452
  shut_down(comm)
454
453
  end
455
- when "HTTP"
456
- puts "ERROR HTTP: #{cm_msg.read_property("msg")}"
457
- if @retried
458
- fcontroller.release(@@server) do |reply_msg|
459
- shut_down(comm)
460
- end
461
- else
462
- @retried = true
463
- controller.configure(state: {node: node.to_sym, status: :start_without_pxe, last_action: options[:last_action]})
464
- end
465
- when "TIME_OUT"
466
- puts "ERROR TIME_OUT: #{cm_msg.read_property("msg")}"
454
+ end
455
+ end
456
+ when 'ERROR'
457
+ case cm_msg.read_property("event_type")
458
+ when "AUTH"
459
+ puts "ERROR AUTH: #{cm_msg.read_property("msg")}"
460
+ fcontroller.release(@@server) do |reply_msg|
461
+ shut_down(comm)
462
+ end
463
+ when "HTTP"
464
+ puts "ERROR HTTP: #{cm_msg.read_property("msg")}"
465
+ if @retried
467
466
  fcontroller.release(@@server) do |reply_msg|
468
467
  puts "INFO: #{client_msg.read_property("node")}: #{client_msg.read_property("msg")}"
469
468
  puts "INFO: Image was saved in '#{@frisbee[:imageDir]}/#{@image}'"
470
469
  shut_down(comm)
471
470
  end
472
471
  else
473
- error cm_msg.read_content('reason') if cm_msg.read_content("reason")
472
+ @retried = true
473
+ cm_controller.configure(state: {node: node.to_sym, status: :start_without_pxe, last_action: options[:last_action]})
474
474
  end
475
- when 'WARN'
476
- warn cm_msg.read_content('reason') if cm_msg.read_content("reason")
475
+ when "TIME_OUT"
476
+ puts "ERROR TIME_OUT: #{cm_msg.read_property("msg")}"
477
+ fcontroller.release(@@server) do |reply_msg|
478
+ puts "INFO: #{client_msg.read_property("node")}: #{client_msg.read_property("msg")}"
479
+ puts "INFO: Image was saved in '#{@frisbee[:imageDir]}/#{@image}'"
480
+ shut_down(comm)
481
+ end
482
+ else
483
+ error cm_msg.read_content('reason') if cm_msg.read_content("reason")
477
484
  end
485
+ when 'WARN'
486
+ warn cm_msg.read_content('reason') if cm_msg.read_content("reason")
478
487
  end
479
488
  end
480
- puts "INFO: Trying to #{options[:last_action]} node '#{client_msg.read_property("node")}' out of PXE."
481
- unless options[:wait]
482
- controller.configure(state: {node: node.to_sym, status: options[:last_action].to_sym, wait: options[:wait]})
483
- puts "INFO: Save proccess completed."
484
- shut_down(comm)
485
- else
486
- # puts "INFO: Trying to #{options[:last_action]} node '#{client_msg.read_property("node")}' out of PXE."
487
- controller.configure(state: {node: node.to_sym, status: :start_without_pxe, last_action: options[:last_action]})
488
- end
489
+ end
490
+ puts "INFO: Trying to #{options[:last_action]} node '#{client_msg.read_property("node")}' out of PXE."
491
+ unless options[:wait]
492
+ cm_controller.configure(state: {node: node.to_sym, status: options[:last_action].to_sym, wait: options[:wait]})
493
+ puts "INFO: Save proccess completed."
494
+ shut_down(comm)
495
+ else
496
+ # puts "INFO: Trying to #{options[:last_action]} node '#{client_msg.read_property("node")}' out of PXE."
497
+ cm_controller.configure(state: {node: node.to_sym, status: :start_without_pxe, last_action: options[:last_action]})
489
498
  end
490
499
  end
491
500
  end
@@ -502,65 +511,75 @@ def save(comm, options)
502
511
  @retried = false
503
512
  unless controller.error?
504
513
  port = nil
505
- controller.on_message do |m|
506
- if m.operation == :inform
507
- case m.read_content("itype")
508
- when 'STATUS'
509
- unless m.read_property("current").nil? && m.read_property("desired").nil?
510
- # logger.info "#{m.read_property("node_name")}, current: #{m.read_property("current")}, desired: #{m.read_property("desired")}"
511
- if m.read_property("current").to_sym == :pxe_on && m.read_property("desired").to_sym == :pxe_on
512
- puts "INFO: Node '#{options[:node]}' is up and running on pxe."
513
- comm.subscribe('frisbee_factory') do |fcontroller|
514
- puts "INFO: Requesting available port"
515
- fcontroller.request([:ports]) do |m|
516
- port = m.read_property("ports")
517
- start_saving()
518
- puts "INFO: Starting Imagezip Server on port '#{port}'"
519
- create_imagezip_server(comm, fcontroller, port, options)
520
- puts "INFO: Starting Imagezip Client on node '#{options[:node]}'"
521
- create_imagezip_client(comm, fcontroller, options[:node], port, options)
522
- print "INFO: Saving Image for node '#{options[:node]}'..."
523
- show_wait_spinner(5){
524
- while saving?
525
- sleep 1
514
+ controller.create(:cm, hrn: "cm") do |reply_msg|
515
+ if reply_msg.success?
516
+ cm_res = reply_msg.resource
517
+ cm_res.on_subscribed do
518
+ cm_res.on_message do |m|
519
+ if m.operation == :inform
520
+ case m.read_content("itype")
521
+ when 'STATUS'
522
+ unless m.read_property("current").nil? && m.read_property("desired").nil?
523
+ # logger.info "#{m.read_property("node_name")}, current: #{m.read_property("current")}, desired: #{m.read_property("desired")}"
524
+ if m.read_property("current").to_sym == :pxe_on && m.read_property("desired").to_sym == :pxe_on
525
+ puts "INFO: Node '#{options[:node]}' is up and running on pxe."
526
+ comm.subscribe('frisbee_factory') do |fcontroller|
527
+ puts "INFO: Requesting available port"
528
+ fcontroller.request([:ports]) do |m|
529
+ port = m.read_property("ports")
530
+ start_saving()
531
+ puts "INFO: Starting Imagezip Server on port '#{port}'"
532
+ create_imagezip_server(comm, fcontroller, port, options)
533
+ puts "INFO: Starting Imagezip Client on node '#{options[:node]}'"
534
+ create_imagezip_client(comm, fcontroller, cm_res, options[:node], port, options)
535
+ print "INFO: Saving Image for node '#{options[:node]}'..."
536
+ show_wait_spinner(5){
537
+ while saving?
538
+ sleep 1
539
+ end
540
+ print "\b"
541
+ print "done!"
542
+ puts "\n"
543
+ }
544
+ end
526
545
  end
527
- print "\b"
528
- print "done!"
529
- puts "\n"
530
- }
546
+ else
547
+ puts "ERROR: exit code: #{m.read_content('exit_code')}" if m.read_content('exit_code')
548
+ end
531
549
  end
550
+ when 'ERROR'
551
+ case m.read_property("event_type")
552
+ when "AUTH"
553
+ puts "ERROR AUTH: #{m.read_property("msg")}"
554
+ shut_down(comm)
555
+ when "HTTP"
556
+ puts "ERROR HTTP: #{m.read_property("msg")}"
557
+ if @retried
558
+ shut_down(comm)
559
+ else
560
+ @retried = true
561
+ controller.configure(state: {node: options[:node].to_sym, status: :start_on_pxe})
562
+ end
563
+ when "TIME_OUT"
564
+ puts "ERROR TIME_OUT: #{m.read_property("msg")}"
565
+ shut_down(comm)
566
+ else
567
+ puts "ERROR: #{m.read_content('reason')}" if m.read_content("reason")
568
+ end
569
+ when 'WARN'
570
+ puts "WARN: #{m.read_content('reason')}" if m.read_content("reason")
532
571
  end
533
- else
534
- puts "ERROR: exit code: #{m.read_content('exit_code')}" if m.read_content('exit_code')
535
572
  end
536
573
  end
537
- when 'ERROR'
538
- case m.read_property("event_type")
539
- when "AUTH"
540
- puts "ERROR AUTH: #{m.read_property("msg")}"
541
- shut_down(comm)
542
- when "HTTP"
543
- puts "ERROR HTTP: #{m.read_property("msg")}"
544
- if @retried
545
- shut_down(comm)
546
- else
547
- @retried = true
548
- controller.configure(state: {node: options[:node].to_sym, status: :start_on_pxe})
549
- end
550
- when "TIME_OUT"
551
- puts "ERROR TIME_OUT: #{m.read_property("msg")}"
552
- shut_down(comm)
553
- else
554
- puts "ERROR: #{m.read_content('reason')}" if m.read_content("reason")
555
- end
556
- when 'WARN'
557
- puts "WARN: #{m.read_content('reason')}" if m.read_content("reason")
574
+
575
+ cm_res.configure(state: {node: options[:node].to_sym, status: :start_on_pxe})
576
+ puts "INFO: Waiting for Node '#{options[:node]}' to boot on PXE."
558
577
  end
578
+ else
579
+ error controller.inspect
580
+ shut_down(comm)
559
581
  end
560
582
  end
561
-
562
- controller.configure(state: {node: options[:node].to_sym, status: :start_on_pxe})
563
- puts "INFO: Waiting for Node '#{options[:node]}' to boot on PXE."
564
583
  else
565
584
  puts "ERROR: #{controller.inspect}"
566
585
  end
@@ -575,102 +594,107 @@ def tell(comm, options)
575
594
  nodes_failed = []
576
595
  nodes_ok = []
577
596
  nodes_retrying = []
578
- controller.on_message do |m|
579
- if m.operation == :inform
580
- case m.read_content("itype")
581
- when 'STATUS'
582
- unless m.read_property("current").nil? && m.read_property("desired").nil?
583
- if m.read_property("current") != m.read_property("desired")
584
- if options[:wait]
585
- puts "INFO: Waiting for node '#{m.read_property("node_name")}'."
586
- else
587
- n = m.read_property("node_name")
588
- nodes_ok << n
589
- if (nodes_ok.length + nodes_failed.length) == options[:target_nodes].length
597
+
598
+ controller.create(:cm, {hrn: 'cm resource'}) do |reply_msg|
599
+ if reply_msg.success?
600
+ res = reply_msg.resource
601
+ res.on_subscribed do
602
+ res.on_message do |m|
603
+ if m.operation == :inform
604
+ case m.read_content("itype")
605
+ when 'STATUS'
606
+ unless m.read_property("current").nil? && m.read_property("desired").nil?
607
+ if m.read_property("current") != m.read_property("desired")
608
+ if options[:wait]
609
+ puts "INFO: Waiting for node '#{m.read_property("node_name")}'."
610
+ else
611
+ n = m.read_property("node_name")
612
+ nodes_ok << n
613
+ if (nodes_ok.length + nodes_failed.length) == options[:target_nodes].length
614
+ tell_complete_msg(options[:status], nodes_ok, nodes_failed) if options[:wait]
615
+ shut_down(comm)
616
+ end
617
+ end
618
+ else
619
+ n = m.read_property("node_name")
620
+ nodes_ok << n
621
+ if (nodes_ok.length + nodes_failed.length) == options[:target_nodes].length
622
+ tell_complete_msg(options[:status], nodes_ok, nodes_failed) if options[:wait]
623
+ puts "INFO: Proccess complete. "
624
+ shut_down(comm)
625
+ end
626
+ end
627
+ end
628
+ when 'ERROR'
629
+ case m.read_property("event_type")
630
+ when "AUTH"
631
+ puts "ERROR AUTH: #{m.read_property("msg")}"
632
+ n = m.read_property("node_name")
633
+ nodes_failed << n
634
+ if (nodes_ok.length + nodes_failed.length) == options[:target_nodes].length
635
+ tell_complete_msg(options[:status], nodes_ok, nodes_failed) if options[:wait]
636
+ puts "INFO: Proccess complete. "
637
+ shut_down(comm)
638
+ end
639
+ when "HTTP"
640
+ puts "ERROR HTTP: #{m.read_property("msg")}"
641
+ n = m.read_property("node_name")
642
+ if nodes_retrying.include?(n)
643
+ nodes_retrying.delete(n)
644
+ nodes_failed << n
645
+ if (nodes_ok.length + nodes_failed.length) == options[:target_nodes].length
646
+ tell_complete_msg(options[:status], nodes_ok, nodes_failed) if options[:wait]
647
+ puts "INFO: Proccess complete. "
648
+ shut_down(comm)
649
+ end
650
+ else
651
+ nodes_retrying << n
652
+ puts "INFO: Failed to reach Node '#{n}', retrying to get the status of the node."
653
+ controller.configure(state: {node: n.to_sym, status: options[:status].to_sym})
654
+ end
655
+ when "TIME_OUT"
656
+ puts "ERROR TIME_OUT: #{m.read_property("msg")}"
657
+ n = m.read_property("node_name")
658
+ nodes_failed << n
659
+ if (nodes_ok.length + nodes_failed.length) == options[:target_nodes].length
660
+ tell_complete_msg(options[:status], nodes_ok, nodes_failed) if options[:wait]
661
+ puts "INFO: Proccess complete. "
662
+ shut_down(comm)
663
+ end
664
+ else
665
+ puts "ERROR: #{m.read_content('reason')}" if m.read_content("reason")
590
666
  tell_complete_msg(options[:status], nodes_ok, nodes_failed) if options[:wait]
667
+ puts "INFO: Proccess complete. "
591
668
  shut_down(comm)
592
669
  end
593
- end
594
- else
595
- n = m.read_property("node_name")
596
- nodes_ok << n
597
- if (nodes_ok.length + nodes_failed.length) == options[:target_nodes].length
598
- tell_complete_msg(options[:status], nodes_ok, nodes_failed) if options[:wait]
599
- puts "INFO: Proccess complete. "
600
- shut_down(comm)
670
+ when 'WARN'
671
+ puts "WARN: #{m.read_content('reason')}" if m.read_content("reason")
601
672
  end
602
673
  end
603
674
  end
604
- when 'ERROR'
605
- case m.read_property("event_type")
606
- when "AUTH"
607
- puts "ERROR AUTH: #{m.read_property("msg")}"
608
- n = m.read_property("node_name")
609
- nodes_failed << n
610
- if (nodes_ok.length + nodes_failed.length) == options[:target_nodes].length
611
- tell_complete_msg(options[:status], nodes_ok, nodes_failed) if options[:wait]
612
- puts "INFO: Proccess complete. "
613
- shut_down(comm)
614
- end
615
- when "HTTP"
616
- puts "ERROR HTTP: #{m.read_property("msg")}"
617
- n = m.read_property("node_name")
618
- if nodes_retrying.include?(n)
619
- nodes_retrying.delete(n)
620
- nodes_failed << n
621
- if (nodes_ok.length + nodes_failed.length) == options[:target_nodes].length
622
- tell_complete_msg(options[:status], nodes_ok, nodes_failed) if options[:wait]
623
- puts "INFO: Proccess complete. "
624
- shut_down(comm)
625
- end
626
- else
627
- nodes_retrying << n
628
- puts "INFO: Failed to reach Node '#{n}', retrying to get the status of the node."
629
- controller.configure(state: {node: n.to_sym, status: options[:status].to_sym})
630
- end
631
- when "TIME_OUT"
632
- puts "ERROR TIME_OUT: #{m.read_property("msg")}"
633
- n = m.read_property("node_name")
634
- nodes_failed << n
635
- if (nodes_ok.length + nodes_failed.length) == options[:target_nodes].length
636
- tell_complete_msg(options[:status], nodes_ok, nodes_failed) if options[:wait]
637
- puts "INFO: Proccess complete. "
638
- shut_down(comm)
639
- end
640
- else
641
- puts "ERROR: #{m.read_content('reason')}" if m.read_content("reason")
642
- tell_complete_msg(options[:status], nodes_ok, nodes_failed) if options[:wait]
643
- puts "INFO: Proccess complete. "
644
- shut_down(comm)
675
+ end
676
+ if options[:status] == "on" || options[:status] == "off" || options[:status] == "reset"
677
+ options[:status] == 'reset' if options[:status] == "reboot" || options[:status] == "restart"
678
+ options[:target_nodes].each do |node|
679
+ res.configure(state: {node: node.to_sym, status: options[:status].to_sym, wait: options[:wait]})
645
680
  end
646
- when 'WARN'
647
- puts "WARN: #{m.read_content('reason')}" if m.read_content("reason")
681
+ else
682
+ puts "WARN: Invalid value for -a, only on/off/reset values are available."
683
+ puts opt_parser
684
+ shut_down(comm)
648
685
  end
686
+ unless options[:wait]
687
+ puts "\nINFO: Proccess complete. "
688
+ shut_down(comm)
689
+ end
690
+ else
691
+ error controller.inspect
692
+ shut_down(comm)
649
693
  end
650
694
  end
651
- if options[:status] == "on"
652
- options[:target_nodes].each do |node|
653
- controller.configure(state: {node: node.to_sym, status: :on, wait: options[:wait]})
654
- end
655
- elsif options[:status] == "off"
656
- options[:target_nodes].each do |node|
657
- controller.configure(state: {node: node.to_sym, status: :off, wait: options[:wait]})
658
- end
659
- elsif options[:status] == "reset"
660
- options[:target_nodes].each do |node|
661
- controller.configure(state: {node: node.to_sym, status: :reset, wait: options[:wait]})
662
- end
663
- else
664
- puts "WARN: Invalid value for -a, only on/off/reset values are available."
665
- puts opt_parser
666
- shut_down(comm)
667
- end
668
- unless options[:wait]
669
- puts "\nINFO: Proccess complete. "
670
- shut_down(comm)
671
- end
672
695
  else
673
696
  error controller.inspect
697
+ shut_down(comm)
674
698
  end
675
699
  end
676
700
  end
@@ -683,58 +707,68 @@ def stat(comm, options)
683
707
  nodes_failed = []
684
708
  nodes_ok = []
685
709
  nodes_retrying = []
686
- controller.on_message do |m|
687
- if m.operation == :inform
688
- case m.read_content("itype")
689
- when 'STATUS'
690
- unless m.read_property("current").nil?
691
- puts "INFO: Node '#{m.read_property("node_name")}' reported status is: #{m.read_property("current")}"
692
- n = m.read_property("node_name")
693
- nodes_ok << n
694
- if (nodes_ok.length + nodes_failed.length) == options[:target_nodes].length
695
- puts "INFO: ------------------------------------------------------"
696
- shut_down(comm)
697
- end
698
- end
699
- when 'ERROR'
700
- case m.read_property("event_type")
701
- when "AUTH"
702
- puts "ERROR AUTH: #{m.read_property("msg")}"
703
- n = m.read_property("node_name")
704
- nodes_failed << n
705
- if (nodes_ok.length + nodes_failed.length) == options[:target_nodes].length
706
- puts "INFO: ------------------------------------------------------"
707
- shut_down(comm)
708
- end
709
- when "HTTP"
710
- puts "ERROR HTTP: #{m.read_property("msg")}"
711
- n = m.read_property("node_name")
712
- if nodes_retrying.include?(n)
713
- nodes_retrying.delete(n)
714
- nodes_failed << n
715
- if (nodes_ok.length + nodes_failed.length) == options[:target_nodes].length
716
- puts "INFO: ------------------------------------------------------"
717
- shut_down(comm)
710
+ controller.create(:cm, {hrn: 'cm resource'}) do |reply_msg|
711
+ if reply_msg.success?
712
+ res = reply_msg.resource
713
+ res.on_subscribed do
714
+ res.on_message do |m|
715
+ if m.operation == :inform
716
+ case m.read_content("itype")
717
+ when 'STATUS'
718
+ unless m.read_property("current").nil?
719
+ puts "INFO: Node '#{m.read_property("node_name")}' reported status is: #{m.read_property("current")}"
720
+ n = m.read_property("node_name")
721
+ nodes_ok << n
722
+ if (nodes_ok.length + nodes_failed.length) == options[:target_nodes].length
723
+ puts "INFO: ------------------------------------------------------"
724
+ shut_down(comm)
725
+ end
726
+ end
727
+ when 'ERROR'
728
+ case m.read_property("event_type")
729
+ when "AUTH"
730
+ puts "ERROR AUTH: #{m.read_property("msg")}"
731
+ n = m.read_property("node_name")
732
+ nodes_failed << n
733
+ if (nodes_ok.length + nodes_failed.length) == options[:target_nodes].length
734
+ puts "INFO: ------------------------------------------------------"
735
+ shut_down(comm)
736
+ end
737
+ when "HTTP"
738
+ puts "ERROR HTTP: #{m.read_property("msg")}"
739
+ n = m.read_property("node_name")
740
+ if nodes_retrying.include?(n)
741
+ nodes_retrying.delete(n)
742
+ nodes_failed << n
743
+ if (nodes_ok.length + nodes_failed.length) == options[:target_nodes].length
744
+ puts "INFO: ------------------------------------------------------"
745
+ shut_down(comm)
746
+ end
747
+ else
748
+ nodes_retrying << n
749
+ puts "INFO: Failed to reach Node '#{n}', retrying to get the status of the node."
750
+ controller.configure(state: {node: n.to_sym, status: :get_status})
751
+ end
752
+ else
753
+ puts "ERROR: #{m.read_content('reason')}" if m.read_content("itype") == 'ERROR'
754
+ puts "INFO: ------------------------------------------------------"
755
+ shut_down(comm)
756
+ end
757
+ when 'WARN'
758
+ puts "WARN: #{m.read_content('reason')}" if m.read_content("itype") == 'WARN'
718
759
  end
719
- else
720
- nodes_retrying << n
721
- puts "INFO: Failed to reach Node '#{n}', retrying to get the status of the node."
722
- controller.configure(state: {node: n.to_sym, status: :get_status})
723
760
  end
724
- else
725
- puts "ERROR: #{m.read_content('reason')}" if m.read_content("itype") == 'ERROR'
726
- puts "INFO: ------------------------------------------------------"
727
- shut_down(comm)
728
761
  end
729
- when 'WARN'
730
- puts "WARN: #{m.read_content('reason')}" if m.read_content("itype") == 'WARN'
762
+
763
+ options[:target_nodes].each do |node|
764
+ res.configure(state: {node: node.to_sym, status: :get_status})
765
+ end
731
766
  end
767
+ else
768
+ error controller.inspect
769
+ shut_down(comm)
732
770
  end
733
771
  end
734
-
735
- options[:target_nodes].each do |node|
736
- controller.configure(state: {node: node.to_sym, status: :get_status})
737
- end
738
772
  else
739
773
  error controller.inspect
740
774
  shut_down(comm)
@@ -802,12 +836,13 @@ def shut_down(comm)
802
836
  comm.disconnect
803
837
  end
804
838
 
805
- OmfCommon.init(@config[:operationMode], {communication: { url: "xmpp://#{@xmpp[:script_user]}:#{@xmpp[:password]}@#{@xmpp[:server]}", auth: {}}, logging: nil }) do
839
+ OmfCommon.init(@config[:operationMode], {communication: { url: "xmpp://#{@xmpp[:script_user]}:#{@xmpp[:password]}@#{@xmpp[:server]}", auth: {}}}) do
806
840
  OmfCommon.comm.on_connected do |comm|
807
841
  OmfCommon::Auth::CertificateStore.instance.register_default_certs(trusted_roots)
808
842
  entity.resource_id = OmfCommon.comm.local_topic.address
809
843
  OmfCommon::Auth::CertificateStore.instance.register(entity)
810
844
 
845
+ options[:status] = "reset" if ARGV[0] == 'tell' && (options[:status] == "reboot" || options[:status] == "restart")
811
846
  start_up_msg(ARGV[0], options)
812
847
 
813
848
  case ARGV[0]
@@ -867,8 +902,6 @@ OmfCommon.init(@config[:operationMode], {communication: { url: "xmpp://#{@xmpp[:
867
902
  shut_down(comm)
868
903
  end
869
904
 
870
- comm.on_interrupted {
871
- shut_down(comm)
872
- }
905
+ comm.on_interrupted {shut_down(comm)}
873
906
  end
874
907
  end