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 +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
@@ -5,9 +5,6 @@ require 'open-uri'
|
|
5
5
|
require 'nokogiri'
|
6
6
|
require 'net/ssh'
|
7
7
|
|
8
|
-
REBOOT_CMD = "reboot"
|
9
|
-
SHUTDOWN_CMD = "shutdown -P now"
|
10
|
-
|
11
8
|
module OmfRc::ResourceProxy::CMFactory
|
12
9
|
include OmfRc::ResourceProxyDSL
|
13
10
|
|
@@ -17,483 +14,468 @@ module OmfRc::ResourceProxy::CMFactory
|
|
17
14
|
|
18
15
|
register_proxy :cm_factory
|
19
16
|
|
20
|
-
configure :state do |res, value|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
# next
|
34
|
-
# end
|
35
|
-
# nod = {}
|
36
|
-
# nod[:node_name] = value.node[:name]
|
37
|
-
# value.node[:interfaces].each do |i|
|
38
|
-
# if i[:role] == "control"
|
39
|
-
# nod[:node_ip] = i[:ip][:address]
|
40
|
-
# nod[:node_mac] = i[:mac]
|
41
|
-
# elsif i[:role] == "cm_network"
|
42
|
-
# nod[:node_cm_ip] = i[:ip][:address]
|
43
|
-
# end
|
44
|
-
# end
|
45
|
-
# nod[:node_cm_ip] = value.node[:cmc][:ip][:address]
|
46
|
-
nod = value.node
|
47
|
-
# nod = {node_name: "node1", node_ip: "10.0.0.1", node_mac: "00-03-1d-0d-4b-96", node_cm_ip: "10.0.0.101"}
|
17
|
+
# configure :state do |res, value|
|
18
|
+
# debug "Received message '#{value.inspect}'"
|
19
|
+
# if error_msg = value.error_msg
|
20
|
+
# res.inform(:error,{
|
21
|
+
# event_type: "AUTH",
|
22
|
+
# exit_code: "-1",
|
23
|
+
# node_name: value[:node],
|
24
|
+
# msg: error_msg
|
25
|
+
# }, :ALL)
|
26
|
+
# next
|
27
|
+
# end
|
28
|
+
# nod = value.node
|
29
|
+
# # nod = {node_name: "node1", node_ip: "10.0.0.1", node_mac: "00-03-1d-0d-4b-96", node_cm_ip: "10.0.0.101"}
|
48
30
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
end
|
31
|
+
# case value[:status].to_sym
|
32
|
+
# when :on then res.start_node(nod, value[:wait])
|
33
|
+
# when :off then res.stop_node(nod, value[:wait])
|
34
|
+
# when :reset then res.reset_node(nod, value[:wait])
|
35
|
+
# when :start_on_pxe then res.start_node_pxe(nod)
|
36
|
+
# when :start_without_pxe then res.start_node_pxe_off(nod, value[:last_action])
|
37
|
+
# when :get_status then res.status(nod)
|
38
|
+
# else
|
39
|
+
# res.log_inform_warn "Cannot switch node to unknown state '#{value[:status].to_s}'!"
|
40
|
+
# end
|
41
|
+
# end
|
60
42
|
|
61
|
-
#this is used by the get status call
|
62
|
-
work("status") do |res, node|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
43
|
+
# #this is used by the get status call
|
44
|
+
# work("status") do |res, node|
|
45
|
+
# debug "Status url: http://#{node[:node_cm_ip].to_s}/state"
|
46
|
+
# begin
|
47
|
+
# resp = open("http://#{node[:node_cm_ip].to_s}/state")
|
48
|
+
# rescue
|
49
|
+
# res.inform(:error, {
|
50
|
+
# event_type: "HTTP",
|
51
|
+
# exit_code: "-1",
|
52
|
+
# node_name: "#{node[:node_name].to_s}",
|
53
|
+
# msg: "failed to reach cm, ip: #{node[:node_cm_ip].to_s}."
|
54
|
+
# }, :ALL)
|
55
|
+
# next
|
56
|
+
# end
|
57
|
+
# ans = res.parse_responce(resp, "//Response//line//value")
|
76
58
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
end
|
59
|
+
# res.inform(:status, {
|
60
|
+
# current: "#{ans}",
|
61
|
+
# node_name: "#{node[:node_name].to_s}"
|
62
|
+
# }, :ALL)
|
63
|
+
# sleep 1 #this solves the getting stuck problem.
|
64
|
+
# end
|
83
65
|
|
84
|
-
work("start_node") do |res, node, wait|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
66
|
+
# work("start_node") do |res, node, wait|
|
67
|
+
# node[:node_mac] = node[:node_mac].downcase.gsub(/:/, '-')
|
68
|
+
# symlink_name = "/tftpboot/pxelinux.cfg/01-#{node[:node_mac]}"
|
69
|
+
# if File.exists?(symlink_name)
|
70
|
+
# File.delete(symlink_name)
|
71
|
+
# end
|
72
|
+
# debug "Start_node url: http://#{node[:node_cm_ip].to_s}/on"
|
73
|
+
# begin
|
74
|
+
# resp = open("http://#{node[:node_cm_ip].to_s}/on")
|
75
|
+
# rescue
|
76
|
+
# res.inform(:error, {
|
77
|
+
# event_type: "HTTP",
|
78
|
+
# exit_code: "-1",
|
79
|
+
# node_name: "#{node[:node_name].to_s}",
|
80
|
+
# msg: "#{node[:name]} failed to reach cm, ip: #{node[:node_cm_ip].to_s}."
|
81
|
+
# }, :ALL)
|
82
|
+
# next
|
83
|
+
# end
|
102
84
|
|
103
|
-
|
85
|
+
# ans = res.parse_responce(resp, "//Response")
|
104
86
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
87
|
+
# if ans == 'ok'
|
88
|
+
# res.inform(:status, {
|
89
|
+
# node_name: "#{node[:node_name].to_s}",
|
90
|
+
# current: :booting,
|
91
|
+
# desired: :running
|
92
|
+
# }, :ALL)
|
93
|
+
# elsif ans == 'already on'
|
94
|
+
# res.inform(:status, {
|
95
|
+
# node_name: "#{node[:node_name].to_s}",
|
96
|
+
# current: :running,
|
97
|
+
# desired: :running
|
98
|
+
# }, :ALL)
|
99
|
+
# end
|
118
100
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
end
|
101
|
+
# if wait
|
102
|
+
# if res.wait_until_ping(node[:node_ip])
|
103
|
+
# res.inform(:status, {
|
104
|
+
# node_name: "#{node[:node_name].to_s}",
|
105
|
+
# current: :running,
|
106
|
+
# desired: :running
|
107
|
+
# }, :ALL)
|
108
|
+
# else
|
109
|
+
# res.inform(:error, {
|
110
|
+
# event_type: "TIME_OUT",
|
111
|
+
# exit_code: "-1",
|
112
|
+
# node_name: "#{node[:node_name].to_s}",
|
113
|
+
# msg: "Node '#{node[:node_name].to_s}' timed out while booting."
|
114
|
+
# }, :ALL)
|
115
|
+
# end
|
116
|
+
# end
|
117
|
+
# sleep 1
|
118
|
+
# end
|
137
119
|
|
138
|
-
work("stop_node") do |res, node, wait|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
120
|
+
# work("stop_node") do |res, node, wait|
|
121
|
+
# node[:node_mac] = node[:node_mac].downcase.gsub(/:/, '-')
|
122
|
+
# symlink_name = "/tftpboot/pxelinux.cfg/01-#{node[:node_mac]}"
|
123
|
+
# if File.exists?(symlink_name)
|
124
|
+
# File.delete(symlink_name)
|
125
|
+
# end
|
126
|
+
# begin
|
127
|
+
# debug "Shutting down node '#{node[:node_name]}' through ssh."
|
128
|
+
# ssh = Net::SSH.start(node[:node_ip], 'root')#, :password => @password)
|
129
|
+
# resp = ssh.exec!(SHUTDOWN_CMD)
|
130
|
+
# ssh.close
|
131
|
+
# debug "shutting down completed with ssh."
|
132
|
+
# res.inform(:status, {
|
133
|
+
# node_name: "#{node[:node_name].to_s}",
|
134
|
+
# current: :running,
|
135
|
+
# desired: :stopped
|
136
|
+
# }, :ALL)
|
137
|
+
# rescue
|
138
|
+
# begin
|
139
|
+
# debug "ssh failed, using CM card instead."
|
140
|
+
# debug "Stop_node url: http://#{node[:node_cm_ip].to_s}/off"
|
159
141
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
142
|
+
# begin
|
143
|
+
# resp = open("http://#{node[:node_cm_ip].to_s}/off")
|
144
|
+
# rescue
|
145
|
+
# res.inform(:error, {
|
146
|
+
# event_type: "HTTP",
|
147
|
+
# exit_code: "-1",
|
148
|
+
# node_name: "#{node[:node_name].to_s}",
|
149
|
+
# msg: "#{node[:name]} failed to reach cm, ip: #{node[:node_cm_ip].to_s}."
|
150
|
+
# }, :ALL)
|
151
|
+
# next
|
152
|
+
# end
|
171
153
|
|
172
|
-
|
154
|
+
# ans = res.parse_responce(resp, "//Response")
|
173
155
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
156
|
+
# if ans == 'ok'
|
157
|
+
# res.inform(:status, {
|
158
|
+
# node_name: "#{node[:node_name].to_s}",
|
159
|
+
# current: :running,
|
160
|
+
# desired: :stopped
|
161
|
+
# }, :ALL)
|
162
|
+
# elsif ans == 'already off'
|
163
|
+
# res.inform(:status, {
|
164
|
+
# node_name: "#{node[:node_name].to_s}",
|
165
|
+
# current: :stopped,
|
166
|
+
# desired: :stopped
|
167
|
+
# }, :ALL)
|
168
|
+
# end
|
169
|
+
# rescue
|
170
|
+
# res.inform(:error, {
|
171
|
+
# event_type: "HTTP",
|
172
|
+
# exit_code: "-1",
|
173
|
+
# node_name: "#{node[:node_name].to_s}",
|
174
|
+
# msg: "failed to reach cm, ip: #{node[:node_cm_ip].to_s}."
|
175
|
+
# }, :ALL)
|
176
|
+
# next
|
177
|
+
# end
|
178
|
+
# end
|
197
179
|
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
end
|
180
|
+
# if wait
|
181
|
+
# if res.wait_until_no_ping(node[:node_ip])
|
182
|
+
# res.inform(:status, {
|
183
|
+
# node_name: "#{node[:node_name].to_s}",
|
184
|
+
# current: :stopped,
|
185
|
+
# desired: :stopped
|
186
|
+
# }, :ALL)
|
187
|
+
# else
|
188
|
+
# res.inform(:error, {
|
189
|
+
# event_type: "TIME_OUT",
|
190
|
+
# exit_code: "-1",
|
191
|
+
# node_name: "#{node[:node_name].to_s}",
|
192
|
+
# msg: "Node '#{node[:node_name].to_s}' timed out while shutting down."
|
193
|
+
# }, :ALL)
|
194
|
+
# end
|
195
|
+
# end
|
196
|
+
# sleep 1
|
197
|
+
# end
|
216
198
|
|
217
|
-
work("reset_node") do |res, node, wait|
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
199
|
+
# work("reset_node") do |res, node, wait|
|
200
|
+
# node[:node_mac] = node[:node_mac].downcase.gsub(/:/, '-')
|
201
|
+
# symlink_name = "/tftpboot/pxelinux.cfg/01-#{node[:node_mac]}"
|
202
|
+
# if File.exists?(symlink_name)
|
203
|
+
# File.delete(symlink_name)
|
204
|
+
# end
|
205
|
+
# begin
|
206
|
+
# debug "Rebooting node '#{node[:node_name]}' through ssh."
|
207
|
+
# ssh = Net::SSH.start(node[:node_ip], 'root')#, :password => @password)
|
208
|
+
# resp = ssh.exec!(REBOOT_CMD)
|
209
|
+
# ssh.close
|
210
|
+
# debug "Rebooting completed with ssh."
|
211
|
+
# res.inform(:status, {
|
212
|
+
# node_name: "#{node[:node_name].to_s}",
|
213
|
+
# current: :running,
|
214
|
+
# desired: :resetted
|
215
|
+
# }, :ALL)
|
216
|
+
# rescue
|
217
|
+
# begin
|
218
|
+
# debug "ssh failed, using CM card instead."
|
219
|
+
# debug "Reset_node url: http://#{node[:node_cm_ip].to_s}/reset"
|
220
|
+
# begin
|
221
|
+
# resp = open("http://#{node[:node_cm_ip].to_s}/reset")
|
222
|
+
# rescue
|
223
|
+
# res.inform(:error, {
|
224
|
+
# event_type: "HTTP",
|
225
|
+
# exit_code: "-1",
|
226
|
+
# node_name: "#{node[:node_name].to_s}",
|
227
|
+
# msg: "#{node[:name]} failed to reach cm, ip: #{node[:node_cm_ip].to_s}."
|
228
|
+
# }, :ALL)
|
229
|
+
# next
|
230
|
+
# end
|
249
231
|
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
232
|
+
# ans = res.parse_responce(resp, "//Response")
|
233
|
+
# if ans == 'ok'
|
234
|
+
# res.inform(:status, {
|
235
|
+
# node_name: "#{node[:node_name].to_s}",
|
236
|
+
# current: :resetted,
|
237
|
+
# desired: :resetted
|
238
|
+
# }, :ALL)
|
239
|
+
# end
|
240
|
+
# rescue
|
241
|
+
# res.inform(:error, {
|
242
|
+
# event_type: "HTTP",
|
243
|
+
# exit_code: "-1",
|
244
|
+
# node_name: "#{node[:node_name].to_s}",
|
245
|
+
# msg: "failed to reach cm, ip: #{node[:node_cm_ip].to_s}."
|
246
|
+
# }, :ALL)
|
247
|
+
# next
|
248
|
+
# end
|
249
|
+
# end
|
268
250
|
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
end
|
251
|
+
# if wait
|
252
|
+
# if res.wait_until_ping(node[:node_ip])
|
253
|
+
# res.inform(:status, {
|
254
|
+
# node_name: "#{node[:node_name].to_s}",
|
255
|
+
# current: :resetted,
|
256
|
+
# desired: :resetted
|
257
|
+
# }, :ALL)
|
258
|
+
# else
|
259
|
+
# res.inform(:error, {
|
260
|
+
# event_type: "TIME_OUT",
|
261
|
+
# exit_code: "-1",
|
262
|
+
# node_name: "#{node[:node_name].to_s}",
|
263
|
+
# msg: "Node '#{node[:node_name].to_s}' timed out while reseting."
|
264
|
+
# }, :ALL)
|
265
|
+
# end
|
266
|
+
# end
|
267
|
+
# sleep 1
|
268
|
+
# end
|
287
269
|
|
288
|
-
work("start_node_pxe") do |res, node|
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
270
|
+
# work("start_node_pxe") do |res, node|
|
271
|
+
# resp = res.get_status(node)
|
272
|
+
# node[:node_mac] = node[:node_mac].downcase.gsub(/:/, '-')
|
273
|
+
# if resp == :on
|
274
|
+
# symlink_name = "/tftpboot/pxelinux.cfg/01-#{node[:node_mac]}"
|
275
|
+
# if !File.exists?("#{symlink_name}")
|
276
|
+
# File.symlink("/tftpboot/pxelinux.cfg/#{@config[:pxeSymLinkConfFile]}", "#{symlink_name}")
|
277
|
+
# end
|
278
|
+
# debug "Start_node_pxe RESET: http://#{node[:node_cm_ip].to_s}/reset"
|
279
|
+
# begin
|
280
|
+
# open("http://#{node[:node_cm_ip].to_s}/reset")
|
281
|
+
# rescue
|
282
|
+
# res.inform(:error, {
|
283
|
+
# event_type: "HTTP",
|
284
|
+
# exit_code: "-1",
|
285
|
+
# node_name: "#{node[:node_name].to_s}",
|
286
|
+
# msg: "failed to reach cm, ip: #{node[:node_cm_ip].to_s}."
|
287
|
+
# }, :ALL)
|
288
|
+
# next
|
289
|
+
# end
|
290
|
+
# elsif resp == :off
|
291
|
+
# symlink_name = "/tftpboot/pxelinux.cfg/01-#{node[:node_mac]}"
|
292
|
+
# if !File.exists?("#{symlink_name}")
|
293
|
+
# File.symlink("/tftpboot/pxelinux.cfg/#{@config[:pxeSymLinkConfFile]}", "#{symlink_name}")
|
294
|
+
# end
|
295
|
+
# debug "Start_node_pxe ON: http://#{node[:node_cm_ip].to_s}/on"
|
296
|
+
# begin
|
297
|
+
# open("http://#{node[:node_cm_ip].to_s}/on")
|
298
|
+
# rescue
|
299
|
+
# res.inform(:error, {
|
300
|
+
# event_type: "HTTP",
|
301
|
+
# exit_code: "-1",
|
302
|
+
# node_name: "#{node[:node_name].to_s}",
|
303
|
+
# msg: "failed to reach cm, ip: #{node[:node_cm_ip].to_s}."
|
304
|
+
# }, :ALL)
|
305
|
+
# next
|
306
|
+
# end
|
307
|
+
# elsif resp == :started_on_pxe
|
308
|
+
# debug "Start_node_pxe STARTED: http://#{node[:node_cm_ip].to_s}/reset"
|
309
|
+
# begin
|
310
|
+
# open("http://#{node[:node_cm_ip].to_s}/reset")
|
311
|
+
# rescue
|
312
|
+
# res.inform(:error, {
|
313
|
+
# event_type: "HTTP",
|
314
|
+
# exit_code: "-1",
|
315
|
+
# node_name: "#{node[:node_name].to_s}",
|
316
|
+
# msg: "failed to reach cm, ip: #{node[:node_cm_ip].to_s}."
|
317
|
+
# }, :ALL)
|
318
|
+
# next
|
319
|
+
# end
|
320
|
+
# end
|
339
321
|
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
end
|
322
|
+
# if res.wait_until_ping(node[:node_ip])
|
323
|
+
# res.inform(:status, {
|
324
|
+
# node_name: "#{node[:node_name].to_s}",
|
325
|
+
# current: :pxe_on,
|
326
|
+
# desired: :pxe_on
|
327
|
+
# }, :ALL)
|
328
|
+
# else
|
329
|
+
# node[:node_mac] = node[:node_mac].downcase.gsub(/:/, '-')
|
330
|
+
# symlink_name = "/tftpboot/pxelinux.cfg/01-#{node[:node_mac]}"
|
331
|
+
# if File.exists?(symlink_name)
|
332
|
+
# File.delete(symlink_name)
|
333
|
+
# end
|
334
|
+
# res.inform(:error, {
|
335
|
+
# event_type: "TIME_OUT",
|
336
|
+
# exit_code: "-1",
|
337
|
+
# node_name: "#{node[:node_name].to_s}",
|
338
|
+
# msg: "Node '#{node[:node_name].to_s}' timed out while trying to boot on PXE."
|
339
|
+
# }, :ALL)
|
340
|
+
# end
|
341
|
+
# sleep 1
|
342
|
+
# end
|
361
343
|
|
362
|
-
work("start_node_pxe_off") do |res, node, action|
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
344
|
+
# work("start_node_pxe_off") do |res, node, action|
|
345
|
+
# node[:node_mac] = node[:node_mac].downcase.gsub(/:/, '-')
|
346
|
+
# symlink_name = "/tftpboot/pxelinux.cfg/01-#{node[:node_mac]}"
|
347
|
+
# if File.exists?(symlink_name)
|
348
|
+
# File.delete(symlink_name)
|
349
|
+
# end
|
350
|
+
# if action == "reset"
|
351
|
+
# debug "Start_node_pxe_off RESET: http://#{node[:node_cm_ip].to_s}/reset"
|
352
|
+
# begin
|
353
|
+
# open("http://#{node[:node_cm_ip].to_s}/reset")
|
354
|
+
# rescue
|
355
|
+
# res.inform(:error, {
|
356
|
+
# event_type: "HTTP",
|
357
|
+
# exit_code: "-1",
|
358
|
+
# node_name: "#{node[:node_name].to_s}",
|
359
|
+
# msg: "failed to reach cm, ip: #{node[:node_cm_ip].to_s}."
|
360
|
+
# }, :ALL)
|
361
|
+
# next
|
362
|
+
# end
|
381
363
|
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
364
|
+
# t = 0
|
365
|
+
# if res.wait_until_ping(node[:node_ip])
|
366
|
+
# res.inform(:status, {
|
367
|
+
# node_name: "#{node[:node_name].to_s}",
|
368
|
+
# current: :pxe_off,
|
369
|
+
# desired: :pxe_off
|
370
|
+
# }, :ALL)
|
371
|
+
# else
|
372
|
+
# res.inform(:error, {
|
373
|
+
# event_type: "TIME_OUT",
|
374
|
+
# exit_code: "-1",
|
375
|
+
# node_name: "#{node[:node_name].to_s}",
|
376
|
+
# msg: "Node '#{node[:node_name].to_s}' timed out while booting."
|
377
|
+
# }, :ALL)
|
378
|
+
# end
|
379
|
+
# elsif action == "shutdown"
|
380
|
+
# debug "Start_node_pxe_off SHUTDOWN: http://#{node[:node_cm_ip].to_s}/off"
|
381
|
+
# begin
|
382
|
+
# open("http://#{node[:node_cm_ip].to_s}/off")
|
383
|
+
# rescue
|
384
|
+
# res.inform(:error, {
|
385
|
+
# event_type: "HTTP",
|
386
|
+
# exit_code: "-1",
|
387
|
+
# node_name: "#{node[:node_name].to_s}",
|
388
|
+
# msg: "failed to reach cm, ip: #{node[:node_cm_ip].to_s}."
|
389
|
+
# }, :ALL)
|
390
|
+
# next
|
391
|
+
# end
|
410
392
|
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
end
|
393
|
+
# if res.wait_until_no_ping(node[:node_ip])
|
394
|
+
# res.inform(:status, {
|
395
|
+
# node_name: "#{node[:node_name].to_s}",
|
396
|
+
# current: :pxe_off,
|
397
|
+
# desired: :pxe_off
|
398
|
+
# }, :ALL)
|
399
|
+
# else
|
400
|
+
# res.inform(:error, {
|
401
|
+
# event_type: "TIME_OUT",
|
402
|
+
# exit_code: "-1",
|
403
|
+
# node_name: "#{node[:node_name].to_s}",
|
404
|
+
# msg: "Node '#{node[:node_name].to_s}' timed out while shutting down."
|
405
|
+
# }, :ALL)
|
406
|
+
# end
|
407
|
+
# end
|
408
|
+
# sleep 1
|
409
|
+
# end
|
428
410
|
|
429
|
-
#this is used by other methods in this scope
|
430
|
-
work("wait_until_ping") do |res, ip|
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
end
|
411
|
+
# #this is used by other methods in this scope
|
412
|
+
# work("wait_until_ping") do |res, ip|
|
413
|
+
# t = 0
|
414
|
+
# resp = false
|
415
|
+
# loop do
|
416
|
+
# sleep 2
|
417
|
+
# status = system("ping #{ip} -c 2 -w 2")
|
418
|
+
# if t < @timeout
|
419
|
+
# if status == true
|
420
|
+
# resp = true
|
421
|
+
# break
|
422
|
+
# end
|
423
|
+
# else
|
424
|
+
# resp = false
|
425
|
+
# break
|
426
|
+
# end
|
427
|
+
# t += 2
|
428
|
+
# end
|
429
|
+
# resp
|
430
|
+
# end
|
449
431
|
|
450
|
-
#this is used by other methods in this scope
|
451
|
-
work("wait_until_no_ping") do |res, ip|
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
end
|
432
|
+
# #this is used by other methods in this scope
|
433
|
+
# work("wait_until_no_ping") do |res, ip|
|
434
|
+
# t = 0
|
435
|
+
# resp = false
|
436
|
+
# loop do
|
437
|
+
# sleep 2
|
438
|
+
# status = system("ping #{ip} -c 2 -w 2")
|
439
|
+
# if t < @timeout
|
440
|
+
# if status == false
|
441
|
+
# resp = true
|
442
|
+
# break
|
443
|
+
# end
|
444
|
+
# else
|
445
|
+
# resp = false
|
446
|
+
# break
|
447
|
+
# end
|
448
|
+
# t += 2
|
449
|
+
# end
|
450
|
+
# resp
|
451
|
+
# end
|
470
452
|
|
471
|
-
#this is used by other methods in this scope
|
472
|
-
work("get_status") do |res, node|
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
453
|
+
# #this is used by other methods in this scope
|
454
|
+
# work("get_status") do |res, node|
|
455
|
+
# debug "http://#{node[:node_cm_ip].to_s}/state"
|
456
|
+
# resp = open("http://#{node[:node_cm_ip].to_s}/state")
|
457
|
+
# resp = res.parse_responce(resp, "//Response//line//value")
|
458
|
+
# debug "state response: #{resp}"
|
477
459
|
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
end
|
460
|
+
# if resp == 'on'
|
461
|
+
# symlink_name = "/tftpboot/pxelinux.cfg/01-#{node[:node_mac]}"
|
462
|
+
# if File.exists?("#{symlink_name}")
|
463
|
+
# :on_pxe
|
464
|
+
# else
|
465
|
+
# :on
|
466
|
+
# end
|
467
|
+
# elsif resp == 'off'
|
468
|
+
# :off
|
469
|
+
# end
|
470
|
+
# end
|
489
471
|
|
490
|
-
work("parse_responce") do |res, input, path|
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
end
|
472
|
+
# work("parse_responce") do |res, input, path|
|
473
|
+
# input = input.string if input.kind_of? StringIO
|
474
|
+
# if input[0] == "<"
|
475
|
+
# output = Nokogiri::XML(input).xpath(path).text.strip
|
476
|
+
# else
|
477
|
+
# output = input.strip
|
478
|
+
# end
|
479
|
+
# output
|
480
|
+
# end
|
499
481
|
end
|