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.
@@ -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
- debug "Received message '#{value.inspect}'"
22
- if error_msg = value.error_msg
23
- res.inform(:error,{
24
- event_type: "AUTH",
25
- exit_code: "-1",
26
- node_name: value[:node],
27
- msg: error_msg
28
- }, :ALL)
29
- next
30
- end
31
- # if value.ignore_msg
32
- # #just ignore this message, another resource controller should take care of this message
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
- case value[:status].to_sym
50
- when :on then res.start_node(nod, value[:wait])
51
- when :off then res.stop_node(nod, value[:wait])
52
- when :reset then res.reset_node(nod, value[:wait])
53
- when :start_on_pxe then res.start_node_pxe(nod)
54
- when :start_without_pxe then res.start_node_pxe_off(nod, value[:last_action])
55
- when :get_status then res.status(nod)
56
- else
57
- res.log_inform_warn "Cannot switch node to unknown state '#{value[:status].to_s}'!"
58
- end
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
- debug "Status url: http://#{node[:node_cm_ip].to_s}/state"
64
- begin
65
- resp = open("http://#{node[:node_cm_ip].to_s}/state")
66
- rescue
67
- res.inform(:error, {
68
- event_type: "HTTP",
69
- exit_code: "-1",
70
- node_name: "#{node[:node_name].to_s}",
71
- msg: "failed to reach cm, ip: #{node[:node_cm_ip].to_s}."
72
- }, :ALL)
73
- next
74
- end
75
- ans = res.parse_responce(resp, "//Response//line//value")
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
- res.inform(:status, {
78
- current: "#{ans}",
79
- node_name: "#{node[:node_name].to_s}"
80
- }, :ALL)
81
- sleep 1 #this solves the getting stuck problem.
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
- node[:node_mac] = node[:node_mac].downcase.gsub(/:/, '-')
86
- symlink_name = "/tftpboot/pxelinux.cfg/01-#{node[:node_mac]}"
87
- if File.exists?(symlink_name)
88
- File.delete(symlink_name)
89
- end
90
- debug "Start_node url: http://#{node[:node_cm_ip].to_s}/on"
91
- begin
92
- resp = open("http://#{node[:node_cm_ip].to_s}/on")
93
- rescue
94
- res.inform(:error, {
95
- event_type: "HTTP",
96
- exit_code: "-1",
97
- node_name: "#{node[:node_name].to_s}",
98
- msg: "#{node[:name]} failed to reach cm, ip: #{node[:node_cm_ip].to_s}."
99
- }, :ALL)
100
- next
101
- end
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
- ans = res.parse_responce(resp, "//Response")
85
+ # ans = res.parse_responce(resp, "//Response")
104
86
 
105
- if ans == 'ok'
106
- res.inform(:status, {
107
- node_name: "#{node[:node_name].to_s}",
108
- current: :booting,
109
- desired: :running
110
- }, :ALL)
111
- elsif ans == 'already on'
112
- res.inform(:status, {
113
- node_name: "#{node[:node_name].to_s}",
114
- current: :running,
115
- desired: :running
116
- }, :ALL)
117
- end
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
- if wait
120
- if res.wait_until_ping(node[:node_ip])
121
- res.inform(:status, {
122
- node_name: "#{node[:node_name].to_s}",
123
- current: :running,
124
- desired: :running
125
- }, :ALL)
126
- else
127
- res.inform(:error, {
128
- event_type: "TIME_OUT",
129
- exit_code: "-1",
130
- node_name: "#{node[:node_name].to_s}",
131
- msg: "Node '#{node[:node_name].to_s}' timed out while booting."
132
- }, :ALL)
133
- end
134
- end
135
- sleep 1
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
- node[:node_mac] = node[:node_mac].downcase.gsub(/:/, '-')
140
- symlink_name = "/tftpboot/pxelinux.cfg/01-#{node[:node_mac]}"
141
- if File.exists?(symlink_name)
142
- File.delete(symlink_name)
143
- end
144
- begin
145
- debug "Shutting down node '#{node[:node_name]}' through ssh."
146
- ssh = Net::SSH.start(node[:node_ip], 'root')#, :password => @password)
147
- resp = ssh.exec!(SHUTDOWN_CMD)
148
- ssh.close
149
- debug "shutting down completed with ssh."
150
- res.inform(:status, {
151
- node_name: "#{node[:node_name].to_s}",
152
- current: :running,
153
- desired: :stopped
154
- }, :ALL)
155
- rescue
156
- begin
157
- debug "ssh failed, using CM card instead."
158
- debug "Stop_node url: http://#{node[:node_cm_ip].to_s}/off"
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
- begin
161
- resp = open("http://#{node[:node_cm_ip].to_s}/off")
162
- rescue
163
- res.inform(:error, {
164
- event_type: "HTTP",
165
- exit_code: "-1",
166
- node_name: "#{node[:node_name].to_s}",
167
- msg: "#{node[:name]} failed to reach cm, ip: #{node[:node_cm_ip].to_s}."
168
- }, :ALL)
169
- next
170
- end
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
- ans = res.parse_responce(resp, "//Response")
154
+ # ans = res.parse_responce(resp, "//Response")
173
155
 
174
- if ans == 'ok'
175
- res.inform(:status, {
176
- node_name: "#{node[:node_name].to_s}",
177
- current: :running,
178
- desired: :stopped
179
- }, :ALL)
180
- elsif ans == 'already off'
181
- res.inform(:status, {
182
- node_name: "#{node[:node_name].to_s}",
183
- current: :stopped,
184
- desired: :stopped
185
- }, :ALL)
186
- end
187
- rescue
188
- res.inform(:error, {
189
- event_type: "HTTP",
190
- exit_code: "-1",
191
- node_name: "#{node[:node_name].to_s}",
192
- msg: "failed to reach cm, ip: #{node[:node_cm_ip].to_s}."
193
- }, :ALL)
194
- next
195
- end
196
- end
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
- if wait
199
- if res.wait_until_no_ping(node[:node_ip])
200
- res.inform(:status, {
201
- node_name: "#{node[:node_name].to_s}",
202
- current: :stopped,
203
- desired: :stopped
204
- }, :ALL)
205
- else
206
- res.inform(:error, {
207
- event_type: "TIME_OUT",
208
- exit_code: "-1",
209
- node_name: "#{node[:node_name].to_s}",
210
- msg: "Node '#{node[:node_name].to_s}' timed out while shutting down."
211
- }, :ALL)
212
- end
213
- end
214
- sleep 1
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
- node[:node_mac] = node[:node_mac].downcase.gsub(/:/, '-')
219
- symlink_name = "/tftpboot/pxelinux.cfg/01-#{node[:node_mac]}"
220
- if File.exists?(symlink_name)
221
- File.delete(symlink_name)
222
- end
223
- begin
224
- debug "Rebooting node '#{node[:node_name]}' through ssh."
225
- ssh = Net::SSH.start(node[:node_ip], 'root')#, :password => @password)
226
- resp = ssh.exec!(REBOOT_CMD)
227
- ssh.close
228
- debug "Rebooting completed with ssh."
229
- res.inform(:status, {
230
- node_name: "#{node[:node_name].to_s}",
231
- current: :running,
232
- desired: :resetted
233
- }, :ALL)
234
- rescue
235
- begin
236
- debug "ssh failed, using CM card instead."
237
- debug "Reset_node url: http://#{node[:node_cm_ip].to_s}/reset"
238
- begin
239
- resp = open("http://#{node[:node_cm_ip].to_s}/reset")
240
- rescue
241
- res.inform(:error, {
242
- event_type: "HTTP",
243
- exit_code: "-1",
244
- node_name: "#{node[:node_name].to_s}",
245
- msg: "#{node[:name]} failed to reach cm, ip: #{node[:node_cm_ip].to_s}."
246
- }, :ALL)
247
- next
248
- end
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
- ans = res.parse_responce(resp, "//Response")
251
- if ans == 'ok'
252
- res.inform(:status, {
253
- node_name: "#{node[:node_name].to_s}",
254
- current: :resetted,
255
- desired: :resetted
256
- }, :ALL)
257
- end
258
- rescue
259
- res.inform(:error, {
260
- event_type: "HTTP",
261
- exit_code: "-1",
262
- node_name: "#{node[:node_name].to_s}",
263
- msg: "failed to reach cm, ip: #{node[:node_cm_ip].to_s}."
264
- }, :ALL)
265
- next
266
- end
267
- end
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
- if wait
270
- if res.wait_until_ping(node[:node_ip])
271
- res.inform(:status, {
272
- node_name: "#{node[:node_name].to_s}",
273
- current: :resetted,
274
- desired: :resetted
275
- }, :ALL)
276
- else
277
- res.inform(:error, {
278
- event_type: "TIME_OUT",
279
- exit_code: "-1",
280
- node_name: "#{node[:node_name].to_s}",
281
- msg: "Node '#{node[:node_name].to_s}' timed out while reseting."
282
- }, :ALL)
283
- end
284
- end
285
- sleep 1
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
- resp = res.get_status(node)
290
- node[:node_mac] = node[:node_mac].downcase.gsub(/:/, '-')
291
- if resp == :on
292
- symlink_name = "/tftpboot/pxelinux.cfg/01-#{node[:node_mac]}"
293
- if !File.exists?("#{symlink_name}")
294
- File.symlink("/tftpboot/pxelinux.cfg/#{@config[:pxeSymLinkConfFile]}", "#{symlink_name}")
295
- end
296
- debug "Start_node_pxe RESET: http://#{node[:node_cm_ip].to_s}/reset"
297
- begin
298
- open("http://#{node[:node_cm_ip].to_s}/reset")
299
- rescue
300
- res.inform(:error, {
301
- event_type: "HTTP",
302
- exit_code: "-1",
303
- node_name: "#{node[:node_name].to_s}",
304
- msg: "failed to reach cm, ip: #{node[:node_cm_ip].to_s}."
305
- }, :ALL)
306
- next
307
- end
308
- elsif resp == :off
309
- symlink_name = "/tftpboot/pxelinux.cfg/01-#{node[:node_mac]}"
310
- if !File.exists?("#{symlink_name}")
311
- File.symlink("/tftpboot/pxelinux.cfg/#{@config[:pxeSymLinkConfFile]}", "#{symlink_name}")
312
- end
313
- debug "Start_node_pxe ON: http://#{node[:node_cm_ip].to_s}/on"
314
- begin
315
- open("http://#{node[:node_cm_ip].to_s}/on")
316
- rescue
317
- res.inform(:error, {
318
- event_type: "HTTP",
319
- exit_code: "-1",
320
- node_name: "#{node[:node_name].to_s}",
321
- msg: "failed to reach cm, ip: #{node[:node_cm_ip].to_s}."
322
- }, :ALL)
323
- next
324
- end
325
- elsif resp == :started_on_pxe
326
- debug "Start_node_pxe STARTED: http://#{node[:node_cm_ip].to_s}/reset"
327
- begin
328
- open("http://#{node[:node_cm_ip].to_s}/reset")
329
- rescue
330
- res.inform(:error, {
331
- event_type: "HTTP",
332
- exit_code: "-1",
333
- node_name: "#{node[:node_name].to_s}",
334
- msg: "failed to reach cm, ip: #{node[:node_cm_ip].to_s}."
335
- }, :ALL)
336
- next
337
- end
338
- end
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
- if res.wait_until_ping(node[:node_ip])
341
- res.inform(:status, {
342
- node_name: "#{node[:node_name].to_s}",
343
- current: :pxe_on,
344
- desired: :pxe_on
345
- }, :ALL)
346
- else
347
- node[:node_mac] = node[:node_mac].downcase.gsub(/:/, '-')
348
- symlink_name = "/tftpboot/pxelinux.cfg/01-#{node[:node_mac]}"
349
- if File.exists?(symlink_name)
350
- File.delete(symlink_name)
351
- end
352
- res.inform(:error, {
353
- event_type: "TIME_OUT",
354
- exit_code: "-1",
355
- node_name: "#{node[:node_name].to_s}",
356
- msg: "Node '#{node[:node_name].to_s}' timed out while trying to boot on PXE."
357
- }, :ALL)
358
- end
359
- sleep 1
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
- node[:node_mac] = node[:node_mac].downcase.gsub(/:/, '-')
364
- symlink_name = "/tftpboot/pxelinux.cfg/01-#{node[:node_mac]}"
365
- if File.exists?(symlink_name)
366
- File.delete(symlink_name)
367
- end
368
- if action == "reset"
369
- debug "Start_node_pxe_off RESET: http://#{node[:node_cm_ip].to_s}/reset"
370
- begin
371
- open("http://#{node[:node_cm_ip].to_s}/reset")
372
- rescue
373
- res.inform(:error, {
374
- event_type: "HTTP",
375
- exit_code: "-1",
376
- node_name: "#{node[:node_name].to_s}",
377
- msg: "failed to reach cm, ip: #{node[:node_cm_ip].to_s}."
378
- }, :ALL)
379
- next
380
- end
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
- t = 0
383
- if res.wait_until_ping(node[:node_ip])
384
- res.inform(:status, {
385
- node_name: "#{node[:node_name].to_s}",
386
- current: :pxe_off,
387
- desired: :pxe_off
388
- }, :ALL)
389
- else
390
- res.inform(:error, {
391
- event_type: "TIME_OUT",
392
- exit_code: "-1",
393
- node_name: "#{node[:node_name].to_s}",
394
- msg: "Node '#{node[:node_name].to_s}' timed out while booting."
395
- }, :ALL)
396
- end
397
- elsif action == "shutdown"
398
- debug "Start_node_pxe_off SHUTDOWN: http://#{node[:node_cm_ip].to_s}/off"
399
- begin
400
- open("http://#{node[:node_cm_ip].to_s}/off")
401
- rescue
402
- res.inform(:error, {
403
- event_type: "HTTP",
404
- exit_code: "-1",
405
- node_name: "#{node[:node_name].to_s}",
406
- msg: "failed to reach cm, ip: #{node[:node_cm_ip].to_s}."
407
- }, :ALL)
408
- next
409
- end
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
- if res.wait_until_no_ping(node[:node_ip])
412
- res.inform(:status, {
413
- node_name: "#{node[:node_name].to_s}",
414
- current: :pxe_off,
415
- desired: :pxe_off
416
- }, :ALL)
417
- else
418
- res.inform(:error, {
419
- event_type: "TIME_OUT",
420
- exit_code: "-1",
421
- node_name: "#{node[:node_name].to_s}",
422
- msg: "Node '#{node[:node_name].to_s}' timed out while shutting down."
423
- }, :ALL)
424
- end
425
- end
426
- sleep 1
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
- t = 0
432
- resp = false
433
- loop do
434
- sleep 2
435
- status = system("ping #{ip} -c 2 -w 2")
436
- if t < @timeout
437
- if status == true
438
- resp = true
439
- break
440
- end
441
- else
442
- resp = false
443
- break
444
- end
445
- t += 2
446
- end
447
- resp
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
- t = 0
453
- resp = false
454
- loop do
455
- sleep 2
456
- status = system("ping #{ip} -c 2 -w 2")
457
- if t < @timeout
458
- if status == false
459
- resp = true
460
- break
461
- end
462
- else
463
- resp = false
464
- break
465
- end
466
- t += 2
467
- end
468
- resp
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
- debug "http://#{node[:node_cm_ip].to_s}/state"
474
- resp = open("http://#{node[:node_cm_ip].to_s}/state")
475
- resp = res.parse_responce(resp, "//Response//line//value")
476
- debug "state response: #{resp}"
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
- if resp == 'on'
479
- symlink_name = "/tftpboot/pxelinux.cfg/01-#{node[:node_mac]}"
480
- if File.exists?("#{symlink_name}")
481
- :on_pxe
482
- else
483
- :on
484
- end
485
- elsif resp == 'off'
486
- :off
487
- end
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
- input = input.string if input.kind_of? StringIO
492
- if input[0] == "<"
493
- output = Nokogiri::XML(input).xpath(path).text.strip
494
- else
495
- output = input.strip
496
- end
497
- output
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