nitos_testbed_rc 2.0.3 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/README.md +2 -2
- data/bin/cm_proxy +13 -6
- data/bin/omf6 +372 -339
- data/lib/nitos_testbed_rc/cm.rb +493 -0
- data/lib/nitos_testbed_rc/cm_factory.rb +439 -457
- data/lib/nitos_testbed_rc/frisbee.rb +89 -24
- data/lib/nitos_testbed_rc/frisbeed.rb +1 -1
- data/lib/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZTZiYmVkMDBiZDFjNzI0NTIwZDNkMjk2Yjg4ODJjOTU3NzhkODc5Mg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MzEwNTRlODAwYzc3NmYwZWFhNmI2ZDg1NzlmNzVkMzNiODg0ZTgxOQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YmFlNzgyNGQzOGMzZjE5YjMxMWJlZmQxMjYwOTY0OGFiZDc1OTQ2N2ViNmVm
|
10
|
+
Yzk5YzNjYzUyYmE2YzkyMTQxYzdjMDZjMmY2NjRmZWFlMzQzYWMxODY5YzY5
|
11
|
+
Y2QxMzZiNjQyOWM0N2ZmOThkNjQ3NWI1MTZmMjY0YTA0MmNiYmI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
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
|
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
|
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
|
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
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
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
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
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
|
-
|
151
|
+
@nodes_retrying_without_pxe << n
|
152
|
+
controller.configure(state: {node: n.to_sym, status: :start_on_pxe})
|
163
153
|
end
|
164
|
-
when
|
165
|
-
|
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
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
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.
|
295
|
-
if
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
if m.read_property(
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
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
|
-
|
309
|
-
|
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
|
-
|
335
|
-
|
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
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
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
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
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
|
-
|
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
|
476
|
-
|
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
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
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.
|
506
|
-
if
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
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
|
-
|
528
|
-
|
529
|
-
|
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
|
-
|
538
|
-
|
539
|
-
|
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
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
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
|
-
|
594
|
-
|
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
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
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
|
-
|
647
|
-
puts "WARN:
|
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.
|
687
|
-
if
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
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
|
-
|
730
|
-
|
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: {}}
|
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
|