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.
@@ -9,9 +9,14 @@
9
9
  :entity_cert: /root/.omf/cm_factory.pem
10
10
  :entity_key: /root/.omf/cm_factory.pkey
11
11
 
12
+ # URL for the rest interface of the broker
13
+ :broker_url: https://nitlab.inf.uth.gr:8001
14
+
12
15
  #time (in seconds) before timeout error occurs
13
16
  :timeout: 80
17
+
14
18
  #operation mode for OmfCommon.init (development, production, etc)
15
19
  :operationMode: development
20
+
16
21
  #testbed xmpp topic
17
22
  :testbedTopic: am_controller
@@ -9,6 +9,9 @@
9
9
  :entity_cert: /root/.omf/frisbee_factory.pem
10
10
  :entity_key: /root/.omf/frisbee_factory.pkey
11
11
 
12
+ # URL for the rest interface of the broker
13
+ :broker_url: https://nitlab.inf.uth.gr:8001
14
+
12
15
  #operation Mode for OmfCommon.init (development, production, etc)
13
16
  :operationMode: development
14
17
 
@@ -29,8 +29,8 @@ module OmfRc::ResourceProxy::CMFactory
29
29
  next
30
30
  end
31
31
  nod = {}
32
- nod[:node_name] = value.node[:resource][:name]
33
- value.node[:resource][:interfaces].each do |i|
32
+ nod[:node_name] = value.node[:name]
33
+ value.node[:interfaces].each do |i|
34
34
  if i[:role] == "control"
35
35
  nod[:node_ip] = i[:ip][:address]
36
36
  nod[:node_mac] = i[:mac]
@@ -38,7 +38,7 @@ module OmfRc::ResourceProxy::CMFactory
38
38
  nod[:node_cm_ip] = i[:ip][:address]
39
39
  end
40
40
  end
41
- nod[:node_cm_ip] = value.node[:resource][:cmc][:ip][:address]
41
+ nod[:node_cm_ip] = value.node[:cmc][:ip][:address]
42
42
  # 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"}
43
43
 
44
44
  case value[:status].to_sym
@@ -53,65 +53,6 @@ module OmfRc::ResourceProxy::CMFactory
53
53
  end
54
54
  end
55
55
 
56
- work("wait_until_ping") do |res, ip|
57
- t = 0
58
- resp = false
59
- loop do
60
- sleep 2
61
- status = system("ping #{ip} -c 2 -w 2")
62
- if t < @timeout
63
- if status == true
64
- resp = true
65
- break
66
- end
67
- else
68
- resp = false
69
- break
70
- end
71
- t += 2
72
- end
73
- resp
74
- end
75
-
76
- work("wait_until_no_ping") do |res, ip|
77
- t = 0
78
- resp = false
79
- loop do
80
- sleep 2
81
- status = system("ping #{ip} -c 2 -w 2")
82
- if t < @timeout
83
- if status == false
84
- resp = true
85
- break
86
- end
87
- else
88
- resp = false
89
- break
90
- end
91
- t += 2
92
- end
93
- resp
94
- end
95
-
96
- #this is used by other methods in this scope
97
- work("get_status") do |res, node|
98
- debug "http://#{node[:node_cm_ip].to_s}/state"
99
- doc = Nokogiri::XML(open("http://#{node[:node_cm_ip].to_s}/state"))
100
- resp = doc.xpath("//Response//line//value").text.strip
101
- debug "state response: #{resp}"
102
-
103
- if resp == 'on'
104
- symlink_name = "/tftpboot/pxelinux.cfg/01-#{node[:node_mac]}"
105
- if File.exists?("#{symlink_name}")
106
- :on_pxe
107
- else
108
- :on
109
- end
110
- elsif resp == 'off'
111
- :off
112
- end
113
- end
114
-
115
56
  #this is used by the get status call
116
57
  work("status") do |res, node|
117
58
  debug "Status url: http://#{node[:node_cm_ip].to_s}/state"
@@ -127,14 +68,22 @@ module OmfRc::ResourceProxy::CMFactory
127
68
  next
128
69
  end
129
70
 
71
+ ans = doc.xpath("//Response//line//value").text
72
+ ans.strip!
73
+
130
74
  res.inform(:status, {
131
- current: "#{doc.xpath("//Response//line//value").text}",
75
+ current: "#{ans}",
132
76
  node_name: "#{node[:node_name].to_s}"
133
77
  }, :ALL)
134
78
  sleep 1 #this solves the getting stuck problem.
135
79
  end
136
80
 
137
81
  work("start_node") do |res, node, wait|
82
+ node[:node_mac] = node[:node_mac].downcase.gsub(/:/, '-')
83
+ symlink_name = "/tftpboot/pxelinux.cfg/01-#{node[:node_mac]}"
84
+ if File.exists?(symlink_name)
85
+ File.delete(symlink_name)
86
+ end
138
87
  debug "Start_node url: http://#{node[:node_cm_ip].to_s}/on"
139
88
  begin
140
89
  doc = Nokogiri::XML(open("http://#{node[:node_cm_ip].to_s}/on"))
@@ -143,17 +92,26 @@ module OmfRc::ResourceProxy::CMFactory
143
92
  event_type: "HTTP",
144
93
  exit_code: "-1",
145
94
  node_name: "#{node[:node_name].to_s}",
146
- msg: "failed to reach cm, ip: #{node[:node_cm_ip].to_s}."
95
+ msg: "#{node[:name]} failed to reach cm, ip: #{node[:node_cm_ip].to_s}."
147
96
  }, :ALL)
148
97
  next
149
98
  end
150
99
 
151
- if doc.xpath("//Response").text == 'ok'
100
+ ans = doc.xpath("//Response").text
101
+ ans.strip!
102
+
103
+ if ans == 'ok'
152
104
  res.inform(:status, {
153
105
  node_name: "#{node[:node_name].to_s}",
154
106
  current: :booting,
155
107
  desired: :running
156
108
  }, :ALL)
109
+ elsif ans == 'already on'
110
+ res.inform(:status, {
111
+ node_name: "#{node[:node_name].to_s}",
112
+ current: :running,
113
+ desired: :running
114
+ }, :ALL)
157
115
  end
158
116
 
159
117
  if wait
@@ -176,6 +134,11 @@ module OmfRc::ResourceProxy::CMFactory
176
134
  end
177
135
 
178
136
  work("stop_node") do |res, node, wait|
137
+ node[:node_mac] = node[:node_mac].downcase.gsub(/:/, '-')
138
+ symlink_name = "/tftpboot/pxelinux.cfg/01-#{node[:node_mac]}"
139
+ if File.exists?(symlink_name)
140
+ File.delete(symlink_name)
141
+ end
179
142
  begin
180
143
  debug "Shutting down node '#{node[:node_name]}' through ssh."
181
144
  ssh = Net::SSH.start(node[:node_ip], 'root')#, :password => @password)
@@ -192,12 +155,22 @@ module OmfRc::ResourceProxy::CMFactory
192
155
  debug "ssh failed, using CM card instead."
193
156
  debug "Stop_node url: http://#{node[:node_cm_ip].to_s}/off"
194
157
  doc = Nokogiri::XML(open("http://#{node[:node_cm_ip].to_s}/off"))
195
- if doc.xpath("//Response").text == 'ok'
158
+
159
+ ans = doc.xpath("//Response").text
160
+ ans.strip!
161
+
162
+ if ans == 'ok'
196
163
  res.inform(:status, {
197
164
  node_name: "#{node[:node_name].to_s}",
198
165
  current: :running,
199
166
  desired: :stopped
200
167
  }, :ALL)
168
+ elsif ans == 'already off'
169
+ res.inform(:status, {
170
+ node_name: "#{node[:node_name].to_s}",
171
+ current: :stopped,
172
+ desired: :stopped
173
+ }, :ALL)
201
174
  end
202
175
  rescue
203
176
  res.inform(:error, {
@@ -230,6 +203,11 @@ module OmfRc::ResourceProxy::CMFactory
230
203
  end
231
204
 
232
205
  work("reset_node") do |res, node, wait|
206
+ node[:node_mac] = node[:node_mac].downcase.gsub(/:/, '-')
207
+ symlink_name = "/tftpboot/pxelinux.cfg/01-#{node[:node_mac]}"
208
+ if File.exists?(symlink_name)
209
+ File.delete(symlink_name)
210
+ end
233
211
  begin
234
212
  debug "Rebooting node '#{node[:node_name]}' through ssh."
235
213
  ssh = Net::SSH.start(node[:node_ip], 'root')#, :password => @password)
@@ -249,7 +227,7 @@ module OmfRc::ResourceProxy::CMFactory
249
227
  if doc.xpath("//Response").text == 'ok'
250
228
  res.inform(:status, {
251
229
  node_name: "#{node[:node_name].to_s}",
252
- current: :running,
230
+ current: :resetted,
253
231
  desired: :resetted
254
232
  }, :ALL)
255
233
  end
@@ -285,6 +263,7 @@ module OmfRc::ResourceProxy::CMFactory
285
263
 
286
264
  work("start_node_pxe") do |res, node|
287
265
  resp = res.get_status(node)
266
+ node[:node_mac] = node[:node_mac].downcase.gsub(/:/, '-')
288
267
  if resp == :on
289
268
  symlink_name = "/tftpboot/pxelinux.cfg/01-#{node[:node_mac]}"
290
269
  if !File.exists?("#{symlink_name}")
@@ -341,6 +320,11 @@ module OmfRc::ResourceProxy::CMFactory
341
320
  desired: :pxe_on
342
321
  }, :ALL)
343
322
  else
323
+ node[:node_mac] = node[:node_mac].downcase.gsub(/:/, '-')
324
+ symlink_name = "/tftpboot/pxelinux.cfg/01-#{node[:node_mac]}"
325
+ if File.exists?(symlink_name)
326
+ File.delete(symlink_name)
327
+ end
344
328
  res.inform(:error, {
345
329
  event_type: "TIME_OUT",
346
330
  exit_code: "-1",
@@ -352,6 +336,7 @@ module OmfRc::ResourceProxy::CMFactory
352
336
  end
353
337
 
354
338
  work("start_node_pxe_off") do |res, node, action|
339
+ node[:node_mac] = node[:node_mac].downcase.gsub(/:/, '-')
355
340
  symlink_name = "/tftpboot/pxelinux.cfg/01-#{node[:node_mac]}"
356
341
  if File.exists?(symlink_name)
357
342
  File.delete(symlink_name)
@@ -416,4 +401,65 @@ module OmfRc::ResourceProxy::CMFactory
416
401
  end
417
402
  sleep 1
418
403
  end
404
+
405
+ #this is used by other methods in this scope
406
+ work("wait_until_ping") do |res, ip|
407
+ t = 0
408
+ resp = false
409
+ loop do
410
+ sleep 2
411
+ status = system("ping #{ip} -c 2 -w 2")
412
+ if t < @timeout
413
+ if status == true
414
+ resp = true
415
+ break
416
+ end
417
+ else
418
+ resp = false
419
+ break
420
+ end
421
+ t += 2
422
+ end
423
+ resp
424
+ end
425
+
426
+ #this is used by other methods in this scope
427
+ work("wait_until_no_ping") do |res, ip|
428
+ t = 0
429
+ resp = false
430
+ loop do
431
+ sleep 2
432
+ status = system("ping #{ip} -c 2 -w 2")
433
+ if t < @timeout
434
+ if status == false
435
+ resp = true
436
+ break
437
+ end
438
+ else
439
+ resp = false
440
+ break
441
+ end
442
+ t += 2
443
+ end
444
+ resp
445
+ end
446
+
447
+ #this is used by other methods in this scope
448
+ work("get_status") do |res, node|
449
+ debug "http://#{node[:node_cm_ip].to_s}/state"
450
+ doc = Nokogiri::XML(open("http://#{node[:node_cm_ip].to_s}/state"))
451
+ resp = doc.xpath("//Response//line//value").text.strip
452
+ debug "state response: #{resp}"
453
+
454
+ if resp == 'on'
455
+ symlink_name = "/tftpboot/pxelinux.cfg/01-#{node[:node_mac]}"
456
+ if File.exists?("#{symlink_name}")
457
+ :on_pxe
458
+ else
459
+ :on
460
+ end
461
+ elsif resp == 'off'
462
+ :off
463
+ end
464
+ end
419
465
  end
@@ -40,14 +40,14 @@ module OmfRc::ResourceProxy::Frisbee #frisbee client
40
40
  next
41
41
  end
42
42
  nod = {}
43
- nod[:node_name] = client.opts.node.resource.name
44
- client.opts.node.resource.interfaces.each do |i|
43
+ nod[:node_name] = client.opts.node.name
44
+ client.opts.node.interfaces.each do |i|
45
45
  if i[:role] == "control"
46
46
  nod[:node_ip] = i[:ip][:address]
47
47
  nod[:node_mac] = i[:mac]
48
48
  end
49
49
  end
50
- nod[:node_cm_ip] = client.opts.node.resource.cmc.ip.address
50
+ nod[:node_cm_ip] = client.opts.node.cmc.ip.address
51
51
  #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"}
52
52
  client.property.multicast_interface = nod[:node_ip]
53
53
  client.property.app_id = client.hrn.nil? ? client.uid : client.hrn
@@ -55,10 +55,11 @@ module OmfRc::ResourceProxy::Frisbee #frisbee client
55
55
  command = "#{client.property.binary_path} -i #{client.property.multicast_interface} -m #{client.property.multicast_address} -p #{client.property.port} #{client.property.hardrive}"
56
56
  debug "Executing command #{command}"
57
57
 
58
+ output = ''
58
59
  host = Net::Telnet.new("Host" => client.property.multicast_interface.to_s, "Timeout" => 200, "Prompt" => /[\w().-]*[\$#>:.]\s?(?:\(enable\))?\s*$/)
59
60
  host.cmd(command.to_s) do |c|
60
- if c != "\n" && (c[0,8] == "Progress" || c[0,5] == "Wrote")
61
- c = c.sub("\n","\n#{client.property.node_topic}: ")
61
+ if c[0,8] == "Progress"
62
+ c = c.split[1]
62
63
  client.inform(:status, {
63
64
  status_type: 'FRISBEE',
64
65
  event: "STDOUT",
@@ -66,6 +67,12 @@ module OmfRc::ResourceProxy::Frisbee #frisbee client
66
67
  node: client.property.node_topic,
67
68
  msg: "#{c.to_s}"
68
69
  }, :ALL)
70
+ elsif c[0,5] == "Wrote"
71
+ c = c.split("\n")
72
+ output = "#{c.first}\n#{c.last}"
73
+ elsif c[0,6] == "\nWrote"
74
+ c = c.split("\n")
75
+ output = "#{c[1]}\n#{c.last}"
69
76
  end
70
77
  end
71
78
 
@@ -74,7 +81,7 @@ module OmfRc::ResourceProxy::Frisbee #frisbee client
74
81
  event: "EXIT",
75
82
  app: client.property.app_id,
76
83
  node: client.property.node_topic,
77
- msg: 'frisbee client completed.'
84
+ msg: output
78
85
  }, :ALL)
79
86
  host.close
80
87
  end
@@ -40,8 +40,8 @@ module OmfRc::ResourceProxy::ImagezipClient #Imagezip client
40
40
  end
41
41
 
42
42
  nod = {}
43
- nod[:node_name] = client.opts.node.resource.name
44
- client.opts.node.resource.interfaces.each do |i|
43
+ nod[:node_name] = client.opts.node.name
44
+ client.opts.node.interfaces.each do |i|
45
45
  if i[:role] == "control"
46
46
  nod[:node_ip] = i[:ip][:address]
47
47
  nod[:node_mac] = i[:mac]
@@ -49,25 +49,27 @@ module OmfRc::ResourceProxy::ImagezipClient #Imagezip client
49
49
  nod[:node_cm_ip] = i[:ip][:address]
50
50
  end
51
51
  end
52
- nod[:node_cm_ip] = client.opts.node.resource.cmc.ip.address
52
+ nod[:node_cm_ip] = client.opts.node.cmc.ip.address
53
53
 
54
54
  client.property.app_id = client.hrn.nil? ? client.uid : client.hrn
55
55
 
56
56
  command = "#{client.property.binary_path} -o -z1 #{client.property.hardrive} - | /bin/nc -q 0 #{client.property.ip} #{client.property.port}"
57
57
  debug "Executing command #{command}"
58
58
  # 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"}
59
-
59
+ summary = ''
60
60
  host = Net::Telnet.new("Host" => nod[:node_ip], "Timeout" => false)#, "Prompt" => /[\w().-]*[\$#>:.]\s?(?:\(enable\))?\s*$/)
61
61
  host.cmd(command.to_s) do |c|
62
- if c.to_s != "\n" && c[0,5] != "\n/usr" && c.to_s != "." && c.to_s != ".." && c.to_s != "..."
63
- #puts '__' + c.to_s + '__'
64
- client.inform(:status, {
65
- status_type: 'IMAGEZIP',
66
- event: "STDOUT",
67
- app: client.property.app_id,
68
- node: client.property.node_topic,
69
- msg: "#{c.to_s}"
70
- }, :ALL)
62
+ # if c.to_s != "\n" && c[0,5] != "\n/usr" && c.to_s != "." && c.to_s != ".." && c.to_s != "..."
63
+ # puts '---------(' + c.to_s + ')-----------'
64
+ if c.include? 'compressed'
65
+ summary = c
66
+ # client.inform(:status, {
67
+ # status_type: 'IMAGEZIP',
68
+ # event: "STDOUT",
69
+ # app: client.property.app_id,
70
+ # node: client.property.node_topic,
71
+ # msg: "#{c.to_s}"
72
+ # }, :ALL)
71
73
  end
72
74
  end
73
75
 
@@ -76,7 +78,7 @@ module OmfRc::ResourceProxy::ImagezipClient #Imagezip client
76
78
  event: "EXIT",
77
79
  app: client.property.app_id,
78
80
  node: client.property.node_topic,
79
- msg: 'imagezip client completed.'
81
+ msg: summary
80
82
  }, :ALL)
81
83
  host.close
82
84
  end
@@ -25,6 +25,8 @@ module OmfRc::ResourceProxy::ImagezipServer #Imagezip server
25
25
 
26
26
  hook :after_initial_configured do |server|
27
27
  server.property.app_id = server.hrn.nil? ? server.uid : server.hrn
28
+ server.property.image_name = server.property.image_name.nil? ? @fconf[:imageDir] + '/' + @fconf[:defaultImage] : server.property.image_name
29
+ server.property.image_name = server.property.image_name.start_with?('/') ? server.property.image_name : @fconf[:imageDir] + '/' + server.property.image_name
28
30
 
29
31
  @app = ExecApp.new(server.property.app_id, server.build_command_line, server.property.map_err_to_out) do |event_type, app_id, msg|
30
32
  server.process_event(server, event_type, app_id, msg)
@@ -36,10 +38,10 @@ module OmfRc::ResourceProxy::ImagezipServer #Imagezip server
36
38
  end
37
39
 
38
40
  def process_event(res, event_type, app_id, msg)
39
- logger.info "Frisbeed: App Event from '#{app_id}' - #{event_type}: '#{msg}'"
41
+ logger.info "ImagezipServer: App Event from '#{app_id}' - #{event_type}: '#{msg}'"
40
42
  if event_type == 'EXIT' #maybe i should inform you for every event_type, we'll see.
41
43
  res.inform(:status, {
42
- status_type: 'IMAGEZIP',
44
+ status_type: 'IMAGEZIP_SERVER',
43
45
  event: event_type.to_s.upcase,
44
46
  app: app_id,
45
47
  exit_code: msg,
@@ -47,7 +49,7 @@ module OmfRc::ResourceProxy::ImagezipServer #Imagezip server
47
49
  }, :ALL)
48
50
  elsif event_type == 'STDOUT'
49
51
  res.inform(:status, {
50
- status_type: 'IMAGEZIP',
52
+ status_type: 'IMAGEZIP_SERVER',
51
53
  event: event_type.to_s.upcase,
52
54
  app: app_id,
53
55
  exit_code: msg,
@@ -23,11 +23,29 @@ module OmfRc::ResourceProxy::User
23
23
  FileUtils.mkdir_p(path)
24
24
  end
25
25
 
26
- File.write("#{path}/cert.pem", value)
26
+ File.write("#{path}/user_cert.pem", value)
27
+
28
+ path = "/home/#{res.property.username}/.omf/etc"
29
+ unless File.directory?(path)#create the directory if it doesn't exist (it will never exist)
30
+ FileUtils.mkdir_p(path)
31
+ end
32
+
33
+ conf_file = File.read('/etc/nitos_testbed_rc/omf_script_conf.yaml')
34
+ conf_file.sub!(' script_user', " #{res.property.username}")
35
+ conf_file.sub!(' testserver', " #{res.topics.first.address.split('@').last}")
36
+
37
+ File.write("#{path}/omf_script_conf.yaml", conf_file)
38
+
39
+ cmd = "chown -R #{res.property.username}:#{res.property.username} /home/#{res.property.username}"
40
+ system(cmd)
27
41
  end
28
42
 
29
43
  configure :auth_keys do |res, value|
30
- File.open("/home/#{res.property.username}/.ssh/authorized_keys", 'w') do |file|
44
+ path = "/home/#{res.property.username}/.ssh"
45
+ unless File.directory?(path)#create the directory if it doesn't exist (it will never exist)
46
+ FileUtils.mkdir_p(path)
47
+ end
48
+ File.open("#{path}/authorized_keys", 'w') do |file|
31
49
  value.each do |v|
32
50
  file.puts v
33
51
  end
@@ -44,6 +62,73 @@ module OmfRc::ResourceProxy::User
44
62
  ExecApp.new(user.property.app_id, user.build_command_line, user.property.map_err_to_out) do |event_type, app_id, msg|
45
63
  user.process_event(user, event_type, app_id, msg)
46
64
  end
65
+
66
+ # user.add_user
67
+
68
+ end
69
+
70
+ work('add_user') do |user|
71
+ cmd = "#{user.property.binary_path} -d /home/#{user.property.username} -s /bin/bash #{user.property.username}"
72
+ puts "exec command: #{cmd}"
73
+ # result = system(cmd)
74
+ out = IO.popen(cmd)
75
+ result = true
76
+ if result
77
+ key = OpenSSL::PKey::RSA.new(2048)
78
+ pub_key = key.public_key
79
+ path = "/home/#{user.property.username}/.ssh/"
80
+ unless File.directory?(path)#create the directory if it doesn't exist (it will never exist)
81
+ FileUtils.mkdir_p(path)
82
+ end
83
+ File.write("#{path}/pub_key.pem", pub_key.to_pem)
84
+ File.write("#{path}/key.pem", key.to_pem)
85
+ sleep 1
86
+ user.inform(:status, {
87
+ status_type: 'APP_EVENT',
88
+ event: 'EXIT',
89
+ exit_code: 0,
90
+ msg: 'User created',
91
+ uid: user.uid, # do we really need this? Should be identical to 'src'
92
+ pub_key: pub_key.to_s
93
+ }, :ALL)
94
+ else #error returned
95
+ if $?.exitstatus == 9 #user already exists error
96
+ path = "/home/#{user.property.username}/.ssh/"
97
+
98
+ if File.exists?("#{path}/pub_key.pem") && File.exists?("#{path}/key.pem")#if keys exist just read the pub_key for the inform
99
+ file = File.open("#{path}/pub_key.pem", "rb")
100
+ pub_key = file.read
101
+ file.close
102
+ else
103
+ key = OpenSSL::PKey::RSA.new(2048)
104
+ pub_key = key.public_key
105
+ path = "/home/#{user.property.username}/.ssh/"
106
+ unless File.directory?(path)#create the directory if it doesn't exist (it will never exist)
107
+ FileUtils.mkdir_p(path)
108
+ end
109
+ File.write("#{path}/pub_key.pem", pub_key.to_pem)
110
+ File.write("#{path}/key.pem", key.to_pem)
111
+ end
112
+ sleep 1
113
+ user.inform(:status, {
114
+ status_type: 'APP_EVENT',
115
+ event: 'EXIT',
116
+ exit_code: 0,
117
+ msg: 'User already exists, ssh keys created.',
118
+ uid: user.uid, # do we really need this? Should be identical to 'src'
119
+ pub_key: pub_key.to_s
120
+ }, :ALL)
121
+ else
122
+ user.inform(:status, {
123
+ status_type: 'APP_EVENT',
124
+ event: 'EXIT',
125
+ exit_code: -1,
126
+ msg: 'User creation failed',
127
+ uid: user.uid, # do we really need this? Should be identical to 'src'
128
+ pub_key: pub_key.to_s
129
+ }, :ALL)
130
+ end
131
+ end
47
132
  end
48
133
 
49
134
  # This method processes an event coming from the application instance, which
@@ -70,18 +155,18 @@ module OmfRc::ResourceProxy::User
70
155
  FileUtils.mkdir_p(path)
71
156
  end
72
157
 
73
- File.write("#{path}/pub_key.pem", pub_key.to_pem)
74
- File.write("#{path}/key.pem", key.to_pem)
158
+ File.write("#{path}/id_rsa.pub", pub_key.to_pem)
159
+ File.write("#{path}/id_rsa", key.to_pem)
75
160
 
76
161
  res.inform(:status, {
77
- status_type: 'APP_EVENT',
78
- event: event_type.to_s.upcase,
79
- app: app_id,
80
- exit_code: msg,
81
- msg: msg,
82
- uid: res.uid, # do we really need this? Should be identical to 'src'
83
- pub_key: pub_key
84
- }, :ALL)
162
+ status_type: 'APP_EVENT',
163
+ event: event_type.to_s.upcase,
164
+ app: app_id,
165
+ exit_code: msg,
166
+ msg: msg,
167
+ uid: res.uid, # do we really need this? Should be identical to 'src'
168
+ pub_key: pub_key.to_pem
169
+ }, :ALL)
85
170
  else #if msg!=0 then the application failed to complete
86
171
  path = "/home/#{res.property.username}/.ssh/"
87
172
  if File.exists?("#{path}/pub_key.pem") && File.exists?("#{path}/key.pem")#if keys exist just read the pub_key for the inform
@@ -98,36 +183,37 @@ module OmfRc::ResourceProxy::User
98
183
  FileUtils.mkdir_p(path)
99
184
  end
100
185
 
101
- File.write("#{path}/pub_key.pem", pub_key.to_pem)
102
- File.write("#{path}/key.pem", key.to_pem)
186
+ File.write("#{path}/id_rsa.pub", pub_key.to_pem)
187
+ File.write("#{path}/id_rsa", key.to_pem)
103
188
  end
104
189
  res.inform(:status, {
105
- status_type: 'APP_EVENT',
106
- event: event_type.to_s.upcase,
107
- app: app_id,
108
- exit_code: msg,
109
- msg: msg,
110
- uid: res.uid, # do we really need this? Should be identical to 'src'
111
- pub_key: pub_key
112
- }, :ALL)
190
+ status_type: 'APP_EVENT',
191
+ event: event_type.to_s.upcase,
192
+ app: app_id,
193
+ exit_code: msg,
194
+ msg: msg,
195
+ uid: res.uid, # do we really need this? Should be identical to 'src'
196
+ pub_key: pub_key.to_pem
197
+ }, :ALL)
113
198
  end
114
199
  else
115
- res.inform(:status, {
116
- status_type: 'APP_EVENT',
117
- event: event_type.to_s.upcase,
118
- app: app_id,
119
- msg: msg,
120
- uid: res.uid
121
- }, :ALL)
200
+ # puts "(((((((((((((( error: #{msg} ))))))))))))))))))"
201
+ # res.inform(:status, {
202
+ # status_type: 'APP_EVENT',
203
+ # event: event_type.to_s.upcase,
204
+ # app: app_id,
205
+ # msg: msg,
206
+ # uid: res.uid
207
+ # }, :ALL)
122
208
  end
123
209
  end
124
210
 
125
211
  # Build the command line, which will be used to add a new user.
126
212
  #
127
213
  work('build_command_line') do |res|
128
- cmd_line = "env -i " # Start with a 'clean' environment
129
- cmd_line += res.property.binary_path + " " # the /usr/sbin/useradd
130
- cmd_line += " -m -s /bin/bash #{res.property.username}" # the username, -m for adding folder -s for default shell to /bin/bash, removed -d /home/#{res.property.username}
214
+ # cmd_line = "env -i " # Start with a 'clean' environment
215
+ cmd_line = res.property.binary_path + " " # the /usr/sbin/useradd
216
+ cmd_line += "-d /home/#{res.property.username} -s /bin/bash #{res.property.username}" # the username, -m for adding folder -s for default shell to /bin/bash, removed -d /home/#{res.property.username}
131
217
  cmd_line
132
218
  end
133
219
  end
@@ -7,7 +7,7 @@ module OmfRc::ResourceProxy::UserFactory
7
7
  register_proxy :user_factory
8
8
 
9
9
  configure :deluser do |res, value|
10
- cmd = 'userdel -r ' + value[:username]
10
+ cmd = '/usr/sbin/userdel -r -f ' + value[:username]
11
11
  system cmd
12
12
  end
13
13
  end
data/lib/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module NITOS
2
2
  module TestbedRc
3
- VERSION = "1.0.0.pre.4"
3
+ VERSION = "1.0.0.pre.5"
4
4
  end
5
5
  end
@@ -19,8 +19,8 @@ Gem::Specification.new do |s|
19
19
  s.require_paths = ["lib"]
20
20
 
21
21
  # specify any dependencies here; for example:
22
- s.add_runtime_dependency "omf_common", "~> 6.1.2.pre.5"
23
- s.add_runtime_dependency "omf_rc", "~> 6.1.2.pre.5"
22
+ s.add_runtime_dependency "omf_common", "~> 6.1.3"
23
+ s.add_runtime_dependency "omf_rc", "~> 6.1.3"
24
24
  s.add_runtime_dependency "nokogiri", "~> 1.6.0"
25
25
  s.add_development_dependency "net-ssh", "~> 2.8.0"
26
26
  end