nitos_testbed_rc 1.0.0.pre.4 → 1.0.0.pre.5
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.
- data/bin/cm_proxy +122 -66
- data/bin/frisbee_proxy +120 -64
- data/bin/install_ntrc +3 -1
- data/bin/omf6 +380 -201
- data/etc/cm_proxy_conf.yaml +5 -0
- data/etc/frisbee_proxy_conf.yaml +3 -0
- data/lib/nitos_testbed_rc/cm_factory.rb +113 -67
- data/lib/nitos_testbed_rc/frisbee.rb +13 -6
- data/lib/nitos_testbed_rc/imagezip_client.rb +16 -14
- data/lib/nitos_testbed_rc/imagezip_server.rb +5 -3
- data/lib/nitos_testbed_rc/user.rb +118 -32
- data/lib/nitos_testbed_rc/user_factory.rb +1 -1
- data/lib/version.rb +1 -1
- data/nitos_testbed_rc.gemspec +2 -2
- metadata +7 -7
data/bin/omf6
CHANGED
@@ -3,7 +3,10 @@ require 'rubygems'
|
|
3
3
|
require 'time'
|
4
4
|
require 'omf_common'
|
5
5
|
require 'optparse'
|
6
|
+
require 'progress_bar'
|
6
7
|
CONF_PATH = '~/.omf/etc/omf_script_conf.yaml'
|
8
|
+
FRISB_PATH = '/etc/nitos_testbed_rc/frisbee_proxy_conf.yaml'
|
9
|
+
CM_PATH = '/etc/nitos_testbed_rc/cm_proxy_conf.yaml'
|
7
10
|
|
8
11
|
@config = YAML.load_file(File.expand_path(CONF_PATH))
|
9
12
|
# @config = YAML.load_file(File.join(File.dirname(File.expand_path(__FILE__)), '.../etc/omf_script_conf.yaml'))
|
@@ -11,6 +14,11 @@ CONF_PATH = '~/.omf/etc/omf_script_conf.yaml'
|
|
11
14
|
@xmpp = @config[:xmpp]
|
12
15
|
@omf = @config[:omf_script]
|
13
16
|
|
17
|
+
@fconfig = YAML.load_file(File.expand_path(FRISB_PATH))
|
18
|
+
@frisbee = @fconfig[:frisbee]
|
19
|
+
|
20
|
+
@cmconfig = YAML.load_file(File.expand_path(CM_PATH))
|
21
|
+
|
14
22
|
options = {}
|
15
23
|
opt_parser = OptionParser.new do |opts|
|
16
24
|
opts.banner = "Usage: omf6 [COMMAND] [OPTIONS]"
|
@@ -27,7 +35,7 @@ opt_parser = OptionParser.new do |opts|
|
|
27
35
|
opts.on('-a', '--status STATUS', 'the status you want to get the node to. Required only on tell command.') { |v| options[:status] = v }
|
28
36
|
opts.on('-t', '--target_nodes NODES', 'target nodes you want to run the command too. Required on commands load, tell and stat.') {|v| options[:target_nodes] = v.split(",") }
|
29
37
|
|
30
|
-
options[:last_action] = @omf[:last_action] #actions are reset and shutdown
|
38
|
+
options[:last_action] = @omf[:last_action] if ARGV[0] == 'save' || ARGV[0] == 'load'#actions are reset and shutdown
|
31
39
|
opts.on('-l', '--last_action ACTION', "action you want to perform after the commands is executed. Optional on commands load and save (last_action can be reset/shutdown. Default #{options[:last_action]})."){|v| options[:last_action] = v}
|
32
40
|
options[:wait] = false
|
33
41
|
opts.on('-w', '--wait', 'wait until pingable. Used in tell command (default vallue is off)'){|v| options[:wait] = true}
|
@@ -35,7 +43,8 @@ end
|
|
35
43
|
|
36
44
|
entity_cert = File.expand_path(@auth[:entity_cert])
|
37
45
|
entity_key = File.expand_path(@auth[:entity_key])
|
38
|
-
entity = OmfCommon::Auth::Certificate.create_from_pem(File.read(entity_cert))#, File.read(entity_key))
|
46
|
+
entity = OmfCommon::Auth::Certificate.create_from_pem(File.read(entity_cert) + File.read(entity_key))#, File.read(entity_key))
|
47
|
+
# entity = OmfCommon::Auth::Certificate.new({cert: entity_cert, key: entity_key})
|
39
48
|
|
40
49
|
trusted_roots = File.expand_path(@auth[:root_cert_dir])
|
41
50
|
|
@@ -50,21 +59,22 @@ def create_frisbeed(comm, fcontroller, port, options)
|
|
50
59
|
server.on_message do |m|
|
51
60
|
if m.operation == :inform
|
52
61
|
if m.read_content("event") == "STDOUT"
|
53
|
-
puts m.read_content("msg")
|
62
|
+
puts "INFO: #{m.read_content("msg")}"
|
54
63
|
elsif m.read_content("event") == "EXIT"
|
55
|
-
puts m.read_content("msg")
|
64
|
+
puts "INFO: #{m.read_content("msg")}"
|
56
65
|
end
|
57
66
|
end
|
58
67
|
end
|
59
68
|
end
|
60
69
|
else
|
61
|
-
|
70
|
+
puts "ERROR: Frisbeed resource creation failed - #{reply_msg[:reason]}"
|
71
|
+
shut_down(comm)
|
62
72
|
end
|
63
73
|
end
|
64
74
|
end
|
65
75
|
|
66
76
|
#run frisbee client on a node
|
67
|
-
def create_frisbee(comm, fcontroller, node, port, options)
|
77
|
+
def create_frisbee(comm, fcontroller, node, port, options, progress_bar)
|
68
78
|
fcontroller.create(:frisbee, hrn: 'frisbee client', port: port, node_topic: "#{node.to_s}") do |reply_msg|
|
69
79
|
if reply_msg.success?
|
70
80
|
client = reply_msg.resource
|
@@ -78,9 +88,17 @@ def create_frisbee(comm, fcontroller, node, port, options)
|
|
78
88
|
# puts "load operation started."
|
79
89
|
# end
|
80
90
|
elsif client_msg.read_property("event") == "STDOUT"
|
81
|
-
|
91
|
+
@load_complete[client_msg.read_property("node")] = client_msg.read_property("msg").sub('%', '').to_i
|
92
|
+
overall = @load_complete.values.inject(:+)
|
93
|
+
progress_bar.count = ( overall / @nodes_up_pxe.length)
|
94
|
+
progress_bar.write
|
82
95
|
elsif client_msg.read_property("event") == "EXIT"
|
83
|
-
|
96
|
+
@load_complete[client_msg.read_property("node")] = 100
|
97
|
+
overall = @load_complete.values.inject(:+)
|
98
|
+
progress_bar.count = ( overall / @nodes_up_pxe.length)
|
99
|
+
progress_bar.write
|
100
|
+
msg = client_msg.read_property("msg").split("\n")
|
101
|
+
@load_end_msg += "#{client_msg.read_property("node")}: #{"#{msg[0]} #{msg[1][14..29]}"}\n"
|
84
102
|
comm.subscribe('cm_factory') do |controller|
|
85
103
|
controller.on_message do |cm_msg|
|
86
104
|
if cm_msg.operation == :inform
|
@@ -91,48 +109,42 @@ def create_frisbee(comm, fcontroller, node, port, options)
|
|
91
109
|
n = cm_msg.read_property("node")
|
92
110
|
@nodes_up_without_pxe << n
|
93
111
|
if @nodes_up_pxe.length == (@nodes_up_without_pxe.length + @nodes_failed_without_pxe.length)
|
94
|
-
puts "
|
95
|
-
fcontroller.release(@@server) do |reply_msg|
|
96
|
-
|
97
|
-
end
|
112
|
+
# puts "INFO: Load proccess completed."
|
113
|
+
# fcontroller.release(@@server) do |reply_msg|
|
114
|
+
# shut_down(comm)
|
115
|
+
# end
|
116
|
+
stop_loading(comm, fcontroller)
|
98
117
|
end
|
99
118
|
end
|
100
119
|
end
|
101
120
|
when 'ERROR'
|
102
121
|
case cm_msg.read_property("event_type")
|
103
122
|
when "AUTH"
|
104
|
-
|
123
|
+
puts "ERROR AUTH: #{cm_msg.read_property("msg")}"
|
105
124
|
n = cm_msg.read_property("node_name")
|
106
125
|
@nodes_failed_without_pxe << n
|
107
126
|
if (@nodes_up_without_pxe.length + @nodes_failed_without_pxe.length) == options[:target_nodes].length
|
108
|
-
|
109
|
-
fcontroller.release(@@server) do |reply_msg|
|
110
|
-
comm.disconnect
|
111
|
-
end
|
127
|
+
stop_loading(comm, fcontroller)
|
112
128
|
end
|
113
129
|
when "HTTP"
|
114
|
-
|
130
|
+
puts "ERROR HTTP: #{cm_msg.read_property("msg")}"
|
115
131
|
n = cm_msg.read_property("node_name")
|
116
132
|
if @nodes_retrying_without_pxe.include?(n)
|
117
133
|
@nodes_retrying_without_pxe.delete(n)
|
118
134
|
@nodes_failed_without_pxe << n
|
119
135
|
if (@nodes_up_without_pxe.length + @nodes_failed_without_pxe.length) == options[:target_nodes].length
|
120
|
-
|
121
|
-
comm.disconnect
|
122
|
-
end
|
136
|
+
stop_loading(comm)
|
123
137
|
end
|
124
138
|
else
|
125
139
|
@nodes_retrying_without_pxe << n
|
126
140
|
controller.configure(state: {node: n.to_sym, status: :start_on_pxe})
|
127
141
|
end
|
128
142
|
when "TIME_OUT"
|
129
|
-
|
143
|
+
puts "ERROR TIME_OUT: #{cm_msg.read_property("msg")}"
|
130
144
|
n = cm_msg.read_property("node_name")
|
131
145
|
@nodes_failed_without_pxe << n
|
132
146
|
if (@nodes_up_without_pxe.length + @nodes_failed_without_pxe.length) == options[:target_nodes].length
|
133
|
-
|
134
|
-
comm.disconnect
|
135
|
-
end
|
147
|
+
stop_loading(comm)
|
136
148
|
end
|
137
149
|
else
|
138
150
|
error cm_msg.read_content('reason') if cm_msg.read_content("reason")
|
@@ -142,8 +154,21 @@ def create_frisbee(comm, fcontroller, node, port, options)
|
|
142
154
|
end
|
143
155
|
end
|
144
156
|
end
|
145
|
-
|
146
|
-
|
157
|
+
unless options[:wait]
|
158
|
+
controller.configure(state: {node: node.to_sym, status: options[:last_action].to_sym, wait: options[:wait]})
|
159
|
+
@nodes_reset += 1
|
160
|
+
if @nodes_reset == @nodes_up_pxe.length
|
161
|
+
@load_end_msg.split("\n").each {|line| puts "INFO: #{line}"}
|
162
|
+
stop_loading(comm)
|
163
|
+
end
|
164
|
+
else
|
165
|
+
puts "INFO: Trying to #{options[:last_action]} node '#{client_msg.read_property("node")}' out of PXE."
|
166
|
+
controller.configure(state: {node: node.to_sym, status: :start_without_pxe, last_action: options[:last_action]})
|
167
|
+
@nodes_reset += 1
|
168
|
+
if @nodes_reset == @nodes_up_pxe.length
|
169
|
+
@load_end_msg.split("\n").each {|line| puts "INFO: #{line}"}
|
170
|
+
end
|
171
|
+
end
|
147
172
|
end
|
148
173
|
end
|
149
174
|
end
|
@@ -155,6 +180,93 @@ def create_frisbee(comm, fcontroller, node, port, options)
|
|
155
180
|
end
|
156
181
|
end
|
157
182
|
|
183
|
+
def loading?
|
184
|
+
@loading
|
185
|
+
end
|
186
|
+
|
187
|
+
def start_loading
|
188
|
+
@loading = true
|
189
|
+
end
|
190
|
+
|
191
|
+
def stop_loading(comm)
|
192
|
+
@loading = false
|
193
|
+
puts "INFO: Load proccess completed."
|
194
|
+
@fcontroller.release(@@server) do |reply_msg|
|
195
|
+
shut_down(comm)
|
196
|
+
end
|
197
|
+
sleep 2
|
198
|
+
end
|
199
|
+
|
200
|
+
|
201
|
+
def start_load(comm, options, node)
|
202
|
+
if @nodes_up_pxe.length == 0
|
203
|
+
puts "ERROR: ALL Nodes failled to boot on PXE."
|
204
|
+
shut_down(comm)
|
205
|
+
end
|
206
|
+
@nodes_reset = 0
|
207
|
+
if @nof_nodes == (@nodes_up_pxe.length + @nodes_failed_pxe.length) #all nodes are up and running on pxe
|
208
|
+
stop_waiting()
|
209
|
+
comm.subscribe('frisbee_factory') do |fcontroller|
|
210
|
+
puts "INFO: Requesting available port"
|
211
|
+
@fcontroller = fcontroller
|
212
|
+
@fcontroller.request([:ports]) do |m|
|
213
|
+
port = m.read_property("ports")
|
214
|
+
puts "INFO: Starting Loading Procedure on port '#{port}'"
|
215
|
+
start_loading()
|
216
|
+
create_frisbeed(comm, @fcontroller, port, options)
|
217
|
+
@load_complete = {}
|
218
|
+
prog_bar = ProgressBar.new(100, :bar, :percentage, :elapsed, :eta, :rate)
|
219
|
+
@load_end_msg = ''
|
220
|
+
@nodes_up_pxe.each do |node|
|
221
|
+
puts "INFO: Starting Loading Procedure on node '#{node}'"
|
222
|
+
@load_complete[node] = 0
|
223
|
+
create_frisbee(comm, @fcontroller, node, port, options, prog_bar) #frisbee client
|
224
|
+
end
|
225
|
+
prog_bar.count = 0
|
226
|
+
prog_bar.write
|
227
|
+
# puts "DEBUG: load_complete: #{@load_complete}"
|
228
|
+
@nodes_failed_pxe.each do |node|
|
229
|
+
puts "INFO: Node '#{node}' failed to boot on PXE."
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
def waiting?
|
237
|
+
@waiting
|
238
|
+
end
|
239
|
+
|
240
|
+
def stop_waiting
|
241
|
+
puts "INFO: All nodes are up and running on PXE."
|
242
|
+
@waiting = false
|
243
|
+
sleep 1
|
244
|
+
end
|
245
|
+
|
246
|
+
def print_until_timeout(msg = '')
|
247
|
+
print "\r"
|
248
|
+
print " "
|
249
|
+
print "\r"
|
250
|
+
puts msg
|
251
|
+
end
|
252
|
+
|
253
|
+
def wait_until_timeout(fps=1)
|
254
|
+
delay = 1.0/fps
|
255
|
+
iter = 0
|
256
|
+
spinner = Thread.new do
|
257
|
+
while iter do # Keep spinning until told otherwise
|
258
|
+
print "INFO: #{@time} / #{@cmconfig[:timeout]} seconds until TIMEOUT!"
|
259
|
+
sleep delay
|
260
|
+
print "\r"
|
261
|
+
STDOUT.flush
|
262
|
+
end
|
263
|
+
end
|
264
|
+
yield.tap{ # After yielding to the block, save the return value
|
265
|
+
iter = false # Tell the thread to exit, cleaning up after itself…
|
266
|
+
spinner.join # …and wait for it to do so.
|
267
|
+
} # Use the block's return value as the method's
|
268
|
+
end
|
269
|
+
|
158
270
|
def load(comm, options)
|
159
271
|
comm.subscribe('cm_factory') do |controller|
|
160
272
|
#TODO handle the case some nodes are not up and running
|
@@ -164,7 +276,7 @@ def load(comm, options)
|
|
164
276
|
@nodes_failed_without_pxe = []
|
165
277
|
@nodes_retrying_without_pxe = []
|
166
278
|
@nodes_up_pxe = []
|
167
|
-
nodes_failed_pxe = []
|
279
|
+
@nodes_failed_pxe = []
|
168
280
|
nodes_retrying_pxe = []
|
169
281
|
port = nil
|
170
282
|
controller.on_message do |m|
|
@@ -175,111 +287,97 @@ def load(comm, options)
|
|
175
287
|
if m.read_property("current").to_sym == :pxe_on && m.read_property("desired").to_sym == :pxe_on
|
176
288
|
n = m.read_property("node_name")
|
177
289
|
@nodes_up_pxe << n
|
178
|
-
|
179
|
-
|
180
|
-
comm.subscribe('frisbee_factory') do |fcontroller|
|
181
|
-
puts "requesting available port"
|
182
|
-
fcontroller.request([:ports]) do |m|
|
183
|
-
port = m.read_property("ports")
|
184
|
-
puts "running frisbee server on port '#{port}'"
|
185
|
-
create_frisbeed(comm, fcontroller, port, options)
|
186
|
-
@nodes_up_pxe.each do |node|
|
187
|
-
create_frisbee(comm, fcontroller, node, port, options) #frisbee client
|
188
|
-
end
|
189
|
-
puts "running frisbee client on specified nodes."
|
190
|
-
end
|
191
|
-
end
|
192
|
-
end
|
290
|
+
print_until_timeout "INFO: Node '#{n}' has booted on PXE."
|
291
|
+
start_load(comm, options, n)
|
193
292
|
else
|
194
|
-
|
293
|
+
print_until_timeout "ERROR: exit code: #{m.read_content('exit_code')}" if m.read_content('exit_code')
|
195
294
|
end
|
196
295
|
end
|
197
296
|
when 'ERROR'
|
198
297
|
case m.read_property("event_type")
|
199
298
|
when "AUTH"
|
200
|
-
|
299
|
+
print_until_timeout "ERROR AUTH: #{m.read_property("msg")}"
|
201
300
|
n = m.read_property("node_name")
|
202
|
-
nodes_failed_pxe << n
|
203
|
-
|
204
|
-
puts "all nodes are up and running on pxe."
|
205
|
-
comm.subscribe('frisbee_factory') do |fcontroller|
|
206
|
-
puts "requesting available port"
|
207
|
-
fcontroller.request([:ports]) do |m|
|
208
|
-
port = m.read_property("ports")
|
209
|
-
puts "running frisbee server on port '#{port}'"
|
210
|
-
create_frisbeed(comm, fcontroller, port, options)
|
211
|
-
@nodes_up_pxe.each do |node|
|
212
|
-
create_frisbee(comm, fcontroller, node, port, options) #frisbee client
|
213
|
-
end
|
214
|
-
puts "running frisbee client on specified nodes."
|
215
|
-
end
|
216
|
-
end
|
217
|
-
end
|
301
|
+
@nodes_failed_pxe << n
|
302
|
+
start_load(comm, options, n)
|
218
303
|
when "HTTP"
|
219
|
-
|
304
|
+
print_until_timeout "ERROR HTTP: #{m.read_property("msg")}"
|
220
305
|
n = m.read_property("node_name")
|
221
306
|
if nodes_retrying_pxe.include?(n)
|
222
307
|
nodes_retrying_pxe.delete(n)
|
223
|
-
nodes_failed_pxe << n
|
224
|
-
|
225
|
-
puts "all nodes are up and running on pxe."
|
226
|
-
comm.subscribe('frisbee_factory') do |fcontroller|
|
227
|
-
puts "requesting available port"
|
228
|
-
fcontroller.request([:ports]) do |m|
|
229
|
-
port = m.read_property("ports")
|
230
|
-
puts "running frisbee server on port '#{port}'"
|
231
|
-
create_frisbeed(comm, fcontroller, port, options)
|
232
|
-
@nodes_up_pxe.each do |node|
|
233
|
-
create_frisbee(comm, fcontroller, node, port, options) #frisbee client
|
234
|
-
end
|
235
|
-
puts "running frisbee client on specified nodes."
|
236
|
-
end
|
237
|
-
end
|
238
|
-
end
|
308
|
+
@nodes_failed_pxe << n
|
309
|
+
start_load(comm, options, n)
|
239
310
|
else
|
240
311
|
nodes_retrying_pxe << n
|
241
312
|
controller.configure(state: {node: n.to_sym, status: :start_on_pxe})
|
242
313
|
end
|
243
314
|
when "TIME_OUT"
|
244
|
-
|
315
|
+
print_until_timeout "ERROR TIME_OUT: #{m.read_property("msg")}"
|
245
316
|
n = m.read_property("node_name")
|
246
|
-
nodes_failed_pxe << n
|
247
|
-
|
248
|
-
puts "all nodes are up and running on pxe."
|
249
|
-
comm.subscribe('frisbee_factory') do |fcontroller|
|
250
|
-
puts "requesting available port"
|
251
|
-
fcontroller.request([:ports]) do |m|
|
252
|
-
port = m.read_property("ports")
|
253
|
-
puts "running frisbee server on port '#{port}'"
|
254
|
-
create_frisbeed(comm, fcontroller, port, options)
|
255
|
-
@nodes_up_pxe.each do |node|
|
256
|
-
create_frisbee(comm, fcontroller, node, port, options) #frisbee client
|
257
|
-
end
|
258
|
-
puts "running frisbee client on specified nodes."
|
259
|
-
end
|
260
|
-
end
|
261
|
-
end
|
317
|
+
@nodes_failed_pxe << n
|
318
|
+
start_load(comm, options, n)
|
262
319
|
else
|
263
|
-
|
320
|
+
print_until_timeout "ERROR: #{ m.read_content('reason')}" if m.read_content("reason")
|
264
321
|
end
|
265
322
|
when 'WARN'
|
266
|
-
|
323
|
+
print_until_timeout "WARN: #{ cm_msg.read_content('reason')}" if m.read_content("reason")
|
267
324
|
end
|
268
325
|
end
|
269
326
|
end
|
270
327
|
options[:target_nodes].each do |node|
|
271
328
|
controller.configure(state: {node: node.to_sym, status: :start_on_pxe})
|
272
329
|
end
|
273
|
-
puts "
|
330
|
+
puts "INFO: Waiting for target nodes to boot on PXE."
|
331
|
+
@waiting = true
|
332
|
+
@time = 0
|
333
|
+
wait_until_timeout(1){
|
334
|
+
while waiting?
|
335
|
+
sleep 1 # Simulate a task taking an unknown amount of time
|
336
|
+
@time += 1
|
337
|
+
end
|
338
|
+
}
|
274
339
|
else
|
275
340
|
error controller.inspect
|
276
341
|
end
|
277
342
|
end
|
278
343
|
end
|
279
344
|
|
345
|
+
@saving = true
|
346
|
+
def saving?
|
347
|
+
@saving
|
348
|
+
end
|
349
|
+
|
350
|
+
def start_saving
|
351
|
+
@saving = true
|
352
|
+
end
|
353
|
+
|
354
|
+
def stop_saving
|
355
|
+
@saving = false
|
356
|
+
sleep 1
|
357
|
+
end
|
358
|
+
|
359
|
+
def show_wait_spinner(fps=10)
|
360
|
+
chars = %w[| / - \\]
|
361
|
+
delay = 1.0/fps
|
362
|
+
iter = 0
|
363
|
+
spinner = Thread.new do
|
364
|
+
while iter do # Keep spinning until told otherwise
|
365
|
+
print chars[(iter+=1) % chars.length]
|
366
|
+
sleep delay
|
367
|
+
print "\b"
|
368
|
+
end
|
369
|
+
end
|
370
|
+
yield.tap{ # After yielding to the block, save the return value
|
371
|
+
iter = false # Tell the thread to exit, cleaning up after itself…
|
372
|
+
spinner.join # …and wait for it to do so.
|
373
|
+
} # Use the block's return value as the method's
|
374
|
+
end
|
375
|
+
|
280
376
|
#run imagezip server
|
281
377
|
def create_imagezip_server(comm, fcontroller, port, options)
|
282
|
-
|
378
|
+
user = `echo $USER`.strip!
|
379
|
+
@image = "#{user}-node-#{options[:node]}-#{Time.now.strftime("%d_%m_%Y_%H:%M")}.ndz"
|
380
|
+
fcontroller.create(:imagezip_server, {hrn: 'imagezip server', image_name: @image, port: port}) do |reply_msg|
|
283
381
|
if reply_msg.success?
|
284
382
|
server = reply_msg.resource
|
285
383
|
@@server = server
|
@@ -287,15 +385,15 @@ def create_imagezip_server(comm, fcontroller, port, options)
|
|
287
385
|
server.on_message do |m|
|
288
386
|
if m.operation == :inform
|
289
387
|
if m.read_content("event") == "STDOUT"
|
290
|
-
puts m.read_content("msg")
|
388
|
+
puts "INFO: #{puts m.read_content("msg")}"
|
291
389
|
elsif m.read_content("event") == "EXIT"
|
292
|
-
puts m.read_content("msg")
|
390
|
+
puts "INFO: #{m.read_content("msg")}"
|
293
391
|
end
|
294
392
|
end
|
295
393
|
end
|
296
394
|
end
|
297
395
|
else
|
298
|
-
|
396
|
+
puts "ERROR: Imagezip Server resource creation failed - #{reply_msg[:reason]}"
|
299
397
|
end
|
300
398
|
end
|
301
399
|
end
|
@@ -309,9 +407,15 @@ def create_imagezip_client(comm, fcontroller, node, port, options)
|
|
309
407
|
client.on_message do |client_msg|
|
310
408
|
if client_msg.operation == :inform
|
311
409
|
if client_msg.read_property("event") == "STDOUT"
|
312
|
-
print "#{client_msg.read_property("msg")}"
|
410
|
+
# print "#{client_msg.read_property("msg")}"
|
313
411
|
elsif client_msg.read_property("event") == "EXIT"
|
314
|
-
|
412
|
+
stop_saving()
|
413
|
+
puts "INFO:"
|
414
|
+
client_msg.read_property("msg").split("\n").each do |line|
|
415
|
+
puts "INFO: #{line}"
|
416
|
+
end
|
417
|
+
puts "INFO: Image was saved in '#{@frisbee[:imageDir]}/#{@image}'"
|
418
|
+
puts "INFO:"
|
315
419
|
comm.subscribe('cm_factory') do |controller|
|
316
420
|
controller.on_message do |cm_msg|
|
317
421
|
if cm_msg.operation == :inform
|
@@ -319,33 +423,35 @@ def create_imagezip_client(comm, fcontroller, node, port, options)
|
|
319
423
|
when 'STATUS'
|
320
424
|
unless cm_msg.read_property("current").nil? && cm_msg.read_property("desired").nil?
|
321
425
|
if cm_msg.read_property("current").to_sym == :pxe_off && cm_msg.read_property("desired").to_sym == :pxe_off
|
322
|
-
puts "
|
426
|
+
puts "INFO: Save proccess completed."
|
323
427
|
fcontroller.release(@@server) do |reply_msg|
|
324
|
-
comm
|
428
|
+
shut_down(comm)
|
325
429
|
end
|
326
430
|
end
|
327
431
|
end
|
328
432
|
when 'ERROR'
|
329
433
|
case cm_msg.read_property("event_type")
|
330
434
|
when "AUTH"
|
331
|
-
|
435
|
+
puts "ERROR AUTH: #{cm_msg.read_property("msg")}"
|
332
436
|
fcontroller.release(@@server) do |reply_msg|
|
333
|
-
comm
|
437
|
+
shut_down(comm)
|
334
438
|
end
|
335
439
|
when "HTTP"
|
336
|
-
|
440
|
+
puts "ERROR HTTP: #{cm_msg.read_property("msg")}"
|
337
441
|
if @retried
|
338
442
|
fcontroller.release(@@server) do |reply_msg|
|
339
|
-
comm
|
443
|
+
shut_down(comm)
|
340
444
|
end
|
341
445
|
else
|
342
446
|
@retried = true
|
343
447
|
controller.configure(state: {node: node.to_sym, status: :start_without_pxe, last_action: options[:last_action]})
|
344
448
|
end
|
345
449
|
when "TIME_OUT"
|
346
|
-
|
450
|
+
puts "ERROR TIME_OUT: #{cm_msg.read_property("msg")}"
|
347
451
|
fcontroller.release(@@server) do |reply_msg|
|
348
|
-
|
452
|
+
puts "INFO: #{client_msg.read_property("node")}: #{client_msg.read_property("msg")}"
|
453
|
+
puts "INFO: Image was saved in '#{@frisbee[:imageDir]}/#{@image}'"
|
454
|
+
shut_down(comm)
|
349
455
|
end
|
350
456
|
else
|
351
457
|
error cm_msg.read_content('reason') if cm_msg.read_content("reason")
|
@@ -355,15 +461,22 @@ def create_imagezip_client(comm, fcontroller, node, port, options)
|
|
355
461
|
end
|
356
462
|
end
|
357
463
|
end
|
358
|
-
puts "#{options[:last_action]} node '#{client_msg.read_property("node")}' out of PXE."
|
359
|
-
|
464
|
+
puts "INFO: Trying to #{options[:last_action]} node '#{client_msg.read_property("node")}' out of PXE."
|
465
|
+
unless options[:wait]
|
466
|
+
controller.configure(state: {node: node.to_sym, status: options[:last_action].to_sym, wait: options[:wait]})
|
467
|
+
puts "INFO: Save proccess completed."
|
468
|
+
shut_down(comm)
|
469
|
+
else
|
470
|
+
# puts "INFO: Trying to #{options[:last_action]} node '#{client_msg.read_property("node")}' out of PXE."
|
471
|
+
controller.configure(state: {node: node.to_sym, status: :start_without_pxe, last_action: options[:last_action]})
|
472
|
+
end
|
360
473
|
end
|
361
474
|
end
|
362
475
|
end
|
363
476
|
end
|
364
477
|
end
|
365
478
|
else
|
366
|
-
|
479
|
+
puts "ERROR: Imagezip Client resource creation failed - #{reply_msg[:reason]}"
|
367
480
|
end
|
368
481
|
end
|
369
482
|
end
|
@@ -375,57 +488,66 @@ def save(comm, options)
|
|
375
488
|
port = nil
|
376
489
|
controller.on_message do |m|
|
377
490
|
if m.operation == :inform
|
378
|
-
puts m.inspect
|
379
491
|
case m.read_content("itype")
|
380
492
|
when 'STATUS'
|
381
493
|
unless m.read_property("current").nil? && m.read_property("desired").nil?
|
382
|
-
logger.info "#{m.read_property("node_name")}, current: #{m.read_property("current")}, desired: #{m.read_property("desired")}"
|
494
|
+
# logger.info "#{m.read_property("node_name")}, current: #{m.read_property("current")}, desired: #{m.read_property("desired")}"
|
383
495
|
if m.read_property("current").to_sym == :pxe_on && m.read_property("desired").to_sym == :pxe_on
|
384
|
-
puts "node is up and running on pxe."
|
496
|
+
puts "INFO: Node '#{options[:node]}' is up and running on pxe."
|
385
497
|
comm.subscribe('frisbee_factory') do |fcontroller|
|
386
|
-
puts "
|
498
|
+
puts "INFO: Requesting available port"
|
387
499
|
fcontroller.request([:ports]) do |m|
|
388
500
|
port = m.read_property("ports")
|
389
|
-
|
501
|
+
start_saving()
|
502
|
+
puts "INFO: Starting Imagezip Server on port '#{port}'"
|
390
503
|
create_imagezip_server(comm, fcontroller, port, options)
|
391
504
|
sleep 2
|
392
|
-
puts "
|
505
|
+
puts "INFO: Starting Imagezip Client on node '#{options[:node]}'"
|
393
506
|
create_imagezip_client(comm, fcontroller, options[:node], port, options)
|
507
|
+
print "INFO: Saving Image for node '#{options[:node]}'..."
|
508
|
+
show_wait_spinner(5){
|
509
|
+
while saving?
|
510
|
+
sleep 1
|
511
|
+
end
|
512
|
+
print "\b"
|
513
|
+
print "done!"
|
514
|
+
puts "\n"
|
515
|
+
}
|
394
516
|
end
|
395
517
|
end
|
396
518
|
else
|
397
|
-
|
519
|
+
puts "ERROR: exit code: #{m.read_content('exit_code')}" if m.read_content('exit_code')
|
398
520
|
end
|
399
521
|
end
|
400
522
|
when 'ERROR'
|
401
523
|
case m.read_property("event_type")
|
402
524
|
when "AUTH"
|
403
|
-
|
404
|
-
comm
|
525
|
+
puts "ERROR AUTH: #{m.read_property("msg")}"
|
526
|
+
shut_down(comm)
|
405
527
|
when "HTTP"
|
406
|
-
|
528
|
+
puts "ERROR HTTP: #{m.read_property("msg")}"
|
407
529
|
if @retried
|
408
|
-
comm
|
530
|
+
shut_down(comm)
|
409
531
|
else
|
410
532
|
@retried = true
|
411
533
|
controller.configure(state: {node: options[:node].to_sym, status: :start_on_pxe})
|
412
534
|
end
|
413
535
|
when "TIME_OUT"
|
414
|
-
|
415
|
-
comm
|
536
|
+
puts "ERROR TIME_OUT: #{m.read_property("msg")}"
|
537
|
+
shut_down(comm)
|
416
538
|
else
|
417
|
-
|
539
|
+
puts "ERROR: #{m.read_content('reason')}" if m.read_content("reason")
|
418
540
|
end
|
419
541
|
when 'WARN'
|
420
|
-
|
542
|
+
puts "WARN: #{m.read_content('reason')}" if m.read_content("reason")
|
421
543
|
end
|
422
544
|
end
|
423
545
|
end
|
424
546
|
|
425
547
|
controller.configure(state: {node: options[:node].to_sym, status: :start_on_pxe})
|
426
|
-
puts "
|
548
|
+
puts "INFO: Waiting for Node '#{options[:node]}' to boot on PXE."
|
427
549
|
else
|
428
|
-
|
550
|
+
puts "ERROR: #{controller.inspect}"
|
429
551
|
end
|
430
552
|
end
|
431
553
|
end
|
@@ -433,6 +555,8 @@ end
|
|
433
555
|
def tell(comm, options)
|
434
556
|
comm.subscribe('cm_factory') do |controller|
|
435
557
|
unless controller.error?
|
558
|
+
puts "\nINFO: Executing tell #{options[:status]} command on all nodes."
|
559
|
+
puts "INFO: ------------------------------------------------------" if options[:wait]
|
436
560
|
nodes_failed = []
|
437
561
|
nodes_ok = []
|
438
562
|
nodes_retrying = []
|
@@ -443,61 +567,69 @@ def tell(comm, options)
|
|
443
567
|
unless m.read_property("current").nil? && m.read_property("desired").nil?
|
444
568
|
if m.read_property("current") != m.read_property("desired")
|
445
569
|
if options[:wait]
|
446
|
-
puts "Waiting for node '#{m.read_property("node_name")}'."
|
447
|
-
logger.info "#{m.read_property("node_name")} is #{m.read_property("current")}."
|
570
|
+
puts "INFO: Waiting for node '#{m.read_property("node_name")}'."
|
448
571
|
else
|
449
572
|
n = m.read_property("node_name")
|
450
573
|
nodes_ok << n
|
451
574
|
if (nodes_ok.length + nodes_failed.length) == options[:target_nodes].length
|
452
|
-
|
453
|
-
comm
|
575
|
+
tell_complete_msg(options[:status], nodes_ok, nodes_failed) if options[:wait]
|
576
|
+
shut_down(comm)
|
454
577
|
end
|
455
578
|
end
|
456
579
|
else
|
457
580
|
n = m.read_property("node_name")
|
458
581
|
nodes_ok << n
|
459
582
|
if (nodes_ok.length + nodes_failed.length) == options[:target_nodes].length
|
460
|
-
|
461
|
-
|
583
|
+
tell_complete_msg(options[:status], nodes_ok, nodes_failed) if options[:wait]
|
584
|
+
puts "INFO: Proccess complete. "
|
585
|
+
shut_down(comm)
|
462
586
|
end
|
463
587
|
end
|
464
588
|
end
|
465
589
|
when 'ERROR'
|
466
590
|
case m.read_property("event_type")
|
467
591
|
when "AUTH"
|
468
|
-
|
592
|
+
puts "ERROR AUTH: #{m.read_property("msg")}"
|
469
593
|
n = m.read_property("node_name")
|
470
594
|
nodes_failed << n
|
471
595
|
if (nodes_ok.length + nodes_failed.length) == options[:target_nodes].length
|
472
|
-
|
596
|
+
tell_complete_msg(options[:status], nodes_ok, nodes_failed) if options[:wait]
|
597
|
+
puts "INFO: Proccess complete. "
|
598
|
+
shut_down(comm)
|
473
599
|
end
|
474
600
|
when "HTTP"
|
475
|
-
|
601
|
+
puts "ERROR HTTP: #{m.read_property("msg")}"
|
476
602
|
n = m.read_property("node_name")
|
477
603
|
if nodes_retrying.include?(n)
|
478
604
|
nodes_retrying.delete(n)
|
479
605
|
nodes_failed << n
|
480
606
|
if (nodes_ok.length + nodes_failed.length) == options[:target_nodes].length
|
481
|
-
|
607
|
+
tell_complete_msg(options[:status], nodes_ok, nodes_failed) if options[:wait]
|
608
|
+
puts "INFO: Proccess complete. "
|
609
|
+
shut_down(comm)
|
482
610
|
end
|
483
611
|
else
|
484
612
|
nodes_retrying << n
|
485
|
-
|
613
|
+
puts "INFO: Failed to reach Node '#{n}', retrying to get the status of the node."
|
486
614
|
controller.configure(state: {node: n.to_sym, status: options[:status].to_sym})
|
487
615
|
end
|
488
616
|
when "TIME_OUT"
|
489
|
-
|
617
|
+
puts "ERROR TIME_OUT: #{m.read_property("msg")}"
|
490
618
|
n = m.read_property("node_name")
|
491
619
|
nodes_failed << n
|
492
620
|
if (nodes_ok.length + nodes_failed.length) == options[:target_nodes].length
|
493
|
-
|
621
|
+
tell_complete_msg(options[:status], nodes_ok, nodes_failed) if options[:wait]
|
622
|
+
puts "INFO: Proccess complete. "
|
623
|
+
shut_down(comm)
|
494
624
|
end
|
495
625
|
else
|
496
|
-
|
497
|
-
|
626
|
+
puts "ERROR: #{m.read_content('reason')}" if m.read_content("reason")
|
627
|
+
tell_complete_msg(options[:status], nodes_ok, nodes_failed) if options[:wait]
|
628
|
+
puts "INFO: Proccess complete. "
|
629
|
+
shut_down(comm)
|
498
630
|
end
|
499
631
|
when 'WARN'
|
500
|
-
|
632
|
+
puts "WARN: #{m.read_content('reason')}" if m.read_content("reason")
|
501
633
|
end
|
502
634
|
end
|
503
635
|
end
|
@@ -514,13 +646,13 @@ def tell(comm, options)
|
|
514
646
|
controller.configure(state: {node: node.to_sym, status: :reset, wait: options[:wait]})
|
515
647
|
end
|
516
648
|
else
|
517
|
-
puts "Invalid value for -a, only on/off/reset values are available."
|
649
|
+
puts "WARN: Invalid value for -a, only on/off/reset values are available."
|
518
650
|
puts opt_parser
|
519
|
-
comm
|
651
|
+
shut_down(comm)
|
520
652
|
end
|
521
653
|
unless options[:wait]
|
522
|
-
puts "Proccess complete."
|
523
|
-
comm
|
654
|
+
puts "\nINFO: Proccess complete. "
|
655
|
+
shut_down(comm)
|
524
656
|
end
|
525
657
|
else
|
526
658
|
error controller.inspect
|
@@ -531,6 +663,8 @@ end
|
|
531
663
|
def stat(comm, options)
|
532
664
|
comm.subscribe('cm_factory') do |controller|
|
533
665
|
unless controller.error?
|
666
|
+
puts "\nINFO: Executing status command on all nodes."
|
667
|
+
puts "INFO: ------------------------------------------------------"
|
534
668
|
nodes_failed = []
|
535
669
|
nodes_ok = []
|
536
670
|
nodes_retrying = []
|
@@ -539,57 +673,46 @@ def stat(comm, options)
|
|
539
673
|
case m.read_content("itype")
|
540
674
|
when 'STATUS'
|
541
675
|
unless m.read_property("current").nil?
|
542
|
-
puts "#{m.read_property("node_name")} is #{m.read_property("current")}"
|
543
|
-
logger.info "#{m.read_property("msg")}, exit code: #{m.read_property("exit_code")}"
|
676
|
+
puts "INFO: Node '#{m.read_property("node_name")}' reported status is: #{m.read_property("current")}"
|
544
677
|
n = m.read_property("node_name")
|
545
678
|
nodes_ok << n
|
546
679
|
if (nodes_ok.length + nodes_failed.length) == options[:target_nodes].length
|
547
|
-
|
680
|
+
puts "INFO: ------------------------------------------------------"
|
681
|
+
shut_down(comm)
|
548
682
|
end
|
549
|
-
# elsif m.read_property("event_type") == "EXIT"
|
550
|
-
# puts "ERROR: #{m.read_property("node")} - #{m.read_property("msg")}"
|
551
|
-
# logger.info "#{m.read_property("msg")}, exit code: #{m.read_property("exit_code")}"
|
552
|
-
# nof_nodes += 1
|
553
|
-
# if nof_nodes == options[:target_nodes].length
|
554
|
-
# comm.disconnect
|
555
|
-
# end
|
556
683
|
end
|
557
684
|
when 'ERROR'
|
558
685
|
case m.read_property("event_type")
|
559
686
|
when "AUTH"
|
560
|
-
|
687
|
+
puts "ERROR AUTH: #{m.read_property("msg")}"
|
561
688
|
n = m.read_property("node_name")
|
562
689
|
nodes_failed << n
|
563
690
|
if (nodes_ok.length + nodes_failed.length) == options[:target_nodes].length
|
564
|
-
|
691
|
+
puts "INFO: ------------------------------------------------------"
|
692
|
+
shut_down(comm)
|
565
693
|
end
|
566
694
|
when "HTTP"
|
567
|
-
|
695
|
+
puts "ERROR HTTP: #{m.read_property("msg")}"
|
568
696
|
n = m.read_property("node_name")
|
569
697
|
if nodes_retrying.include?(n)
|
570
698
|
nodes_retrying.delete(n)
|
571
699
|
nodes_failed << n
|
572
700
|
if (nodes_ok.length + nodes_failed.length) == options[:target_nodes].length
|
573
|
-
|
701
|
+
puts "INFO: ------------------------------------------------------"
|
702
|
+
shut_down(comm)
|
574
703
|
end
|
575
704
|
else
|
576
705
|
nodes_retrying << n
|
577
|
-
|
706
|
+
puts "INFO: Failed to reach Node '#{n}', retrying to get the status of the node."
|
578
707
|
controller.configure(state: {node: n.to_sym, status: :get_status})
|
579
708
|
end
|
580
|
-
when "TIME_OUT"
|
581
|
-
logger.info "#{m.read_property("msg")}, exit code: #{m.read_property("exit_code")}"
|
582
|
-
n = m.read_property("node_name")
|
583
|
-
nodes_failed << n
|
584
|
-
if (nodes_ok.length + nodes_failed.length) == options[:target_nodes].length
|
585
|
-
comm.disconnect
|
586
|
-
end
|
587
709
|
else
|
588
|
-
|
589
|
-
|
710
|
+
puts "ERROR: #{m.read_content('reason')}" if m.read_content("itype") == 'ERROR'
|
711
|
+
puts "INFO: ------------------------------------------------------"
|
712
|
+
shut_down(comm)
|
590
713
|
end
|
591
714
|
when 'WARN'
|
592
|
-
|
715
|
+
puts "WARN: #{m.read_content('reason')}" if m.read_content("itype") == 'WARN'
|
593
716
|
end
|
594
717
|
end
|
595
718
|
end
|
@@ -599,82 +722,138 @@ def stat(comm, options)
|
|
599
722
|
end
|
600
723
|
else
|
601
724
|
error controller.inspect
|
602
|
-
comm
|
725
|
+
shut_down(comm)
|
603
726
|
end
|
604
727
|
end
|
605
728
|
end
|
606
729
|
|
607
730
|
opt_parser.parse!
|
608
731
|
|
732
|
+
def tell_complete_msg(command, nodes_ok, nodes_failed)
|
733
|
+
puts "\nINFO: Domain: #{@xmpp[:server]} - Command: #{command}"
|
734
|
+
puts "INFO: -----------------------------------------------"
|
735
|
+
nodes_ok.each do |n|
|
736
|
+
puts "INFO: Node #{n} \tReply: OK"
|
737
|
+
end
|
738
|
+
nodes_failed.each do |n|
|
739
|
+
puts "INFO: Node #{n} \tReply: FAILED"
|
740
|
+
end
|
741
|
+
puts "INFO: -----------------------------------------------"
|
742
|
+
end
|
743
|
+
|
744
|
+
def start_up_msg(command, options)
|
745
|
+
puts "\nINFO: OMF 6 script started."
|
746
|
+
puts "INFO: Message authentication is enabled."
|
747
|
+
puts "INFO: Calling #{command} with the following options: "
|
748
|
+
options.each do |key, value|
|
749
|
+
if value.kind_of? Array
|
750
|
+
if value.length == 1
|
751
|
+
puts "INFO: \t#{key}:\t{#{value[0]}}"
|
752
|
+
next
|
753
|
+
end
|
754
|
+
out = "INFO: \t#{key}:\t{"
|
755
|
+
value.each do |v|
|
756
|
+
out += "#{v}, "
|
757
|
+
end
|
758
|
+
out = out[0...-2]
|
759
|
+
out += "}"
|
760
|
+
puts out
|
761
|
+
else
|
762
|
+
if key.size > 7
|
763
|
+
puts "INFO: \t#{key}:\t#{value}"
|
764
|
+
else
|
765
|
+
puts "INFO: \t#{key}:\t\t#{value}"
|
766
|
+
end
|
767
|
+
end
|
768
|
+
end
|
769
|
+
end
|
770
|
+
|
771
|
+
def pxe_fail_msg(comm)
|
772
|
+
puts "ALl nodes failed to load on PXE"
|
773
|
+
shut_down(comm)
|
774
|
+
end
|
775
|
+
|
776
|
+
def shut_down(comm)
|
777
|
+
if saving?
|
778
|
+
stop_saving
|
779
|
+
end
|
780
|
+
if loading?
|
781
|
+
stop_loading(comm)
|
782
|
+
end
|
783
|
+
puts "\nINFO: "
|
784
|
+
puts "INFO: Shutting down experiment, please wait..."
|
785
|
+
puts "INFO: "
|
786
|
+
# sleep 1
|
787
|
+
comm.disconnect
|
788
|
+
end
|
789
|
+
|
609
790
|
OmfCommon.init(@config[:operationMode], communication: { url: "xmpp://#{@xmpp[:script_user]}:#{@xmpp[:password]}@#{@xmpp[:server]}", auth: {} }) do
|
610
791
|
OmfCommon.comm.on_connected do |comm|
|
611
792
|
OmfCommon::Auth::CertificateStore.instance.register_default_certs(trusted_roots)
|
612
793
|
entity.resource_id = OmfCommon.comm.local_topic.address
|
613
794
|
OmfCommon::Auth::CertificateStore.instance.register(entity)
|
614
795
|
|
615
|
-
|
796
|
+
start_up_msg(ARGV[0], options)
|
616
797
|
|
617
798
|
case ARGV[0]
|
618
799
|
when "load"
|
619
800
|
if options[:node].nil? && options[:status].nil? && !options[:target_nodes].nil?
|
620
801
|
if options[:last_action] == "reset" || options[:last_action] == "shutdown"
|
621
|
-
puts "call load on options #{options.inspect}"
|
622
802
|
load(comm, options)
|
623
803
|
else
|
624
|
-
puts "Invalid value for -l, only reset/shutdown values are available."
|
804
|
+
puts "WARN: Invalid value for -l, only reset/shutdown values are available."
|
625
805
|
puts opt_parser
|
626
|
-
comm
|
806
|
+
shut_down(comm)
|
627
807
|
end
|
628
808
|
else
|
629
|
-
puts "Invalid arguements."
|
809
|
+
puts "WARN: Invalid arguements."
|
630
810
|
puts opt_parser
|
631
|
-
comm
|
811
|
+
shut_down(comm)
|
632
812
|
end
|
633
813
|
when "save"
|
634
814
|
if options[:image].nil? && !options[:node].nil? && options[:status].nil? && options[:target_nodes].nil?
|
635
815
|
if options[:last_action] == "reset" || options[:last_action] == "shutdown"
|
636
|
-
puts "call save on options #{options.inspect}"
|
637
816
|
save(comm, options)
|
638
817
|
else
|
639
|
-
puts "Invalid value for -l, only reset/shutdown values are available."
|
818
|
+
puts "WARN: Invalid value for -l, only reset/shutdown values are available."
|
640
819
|
puts opt_parser
|
641
|
-
comm
|
820
|
+
shut_down(comm)
|
642
821
|
end
|
643
822
|
else
|
644
|
-
puts "Invalid arguements."
|
823
|
+
puts "WARN: Invalid arguements."
|
645
824
|
puts opt_parser
|
646
|
-
comm
|
825
|
+
shut_down(comm)
|
647
826
|
end
|
648
827
|
when "tell"
|
649
828
|
if options[:image].nil? && options[:node].nil? && !options[:status].nil? && !options[:target_nodes].nil?
|
650
829
|
if options[:status] == "on" || options[:status] == "off" || options[:status] == "reset"
|
651
|
-
puts "call tell on options #{options.inspect}"
|
652
830
|
tell(comm, options)
|
653
831
|
else
|
654
|
-
puts "Invalid value for -a, only on/off/reset values are available."
|
832
|
+
puts "WARN: Invalid value for -a, only on/off/reset values are available."
|
655
833
|
puts opt_parser
|
656
|
-
comm
|
834
|
+
shut_down(comm)
|
657
835
|
end
|
658
836
|
else
|
659
|
-
puts "Invalid arguements."
|
837
|
+
puts "WARN: Invalid arguements."
|
660
838
|
puts opt_parser
|
661
|
-
comm
|
839
|
+
shut_down(comm)
|
662
840
|
end
|
663
841
|
when "stat"
|
664
842
|
if options[:image].nil? && options[:node].nil? && options[:status].nil? && !options[:target_nodes].nil?
|
665
|
-
puts "call stat on options #{options.inspect}"
|
666
843
|
stat(comm, options)
|
667
844
|
else
|
668
|
-
puts "Invalid arguements."
|
845
|
+
puts "WARN: Invalid arguements."
|
669
846
|
puts opt_parser
|
670
|
-
comm
|
847
|
+
shut_down(comm)
|
671
848
|
end
|
672
849
|
else
|
673
|
-
puts "Invalid command / options."
|
850
|
+
puts "WARN: Invalid command / options."
|
674
851
|
puts opt_parser
|
675
|
-
comm
|
852
|
+
shut_down(comm)
|
676
853
|
end
|
677
854
|
|
678
|
-
comm.on_interrupted {
|
855
|
+
comm.on_interrupted {
|
856
|
+
shut_down(comm)
|
857
|
+
}
|
679
858
|
end
|
680
|
-
end
|
859
|
+
end
|