opennebula-cli 5.12.0 → 5.12.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d3699c3c2d650493465035066057a79c20a59f40
4
- data.tar.gz: 1577fe3f9e9ca3af5db399a0d9bc3587ad81cea4
3
+ metadata.gz: bf6e5e798b363cb760c687cb5fd21a53f172e79f
4
+ data.tar.gz: 6c49c0c55816e6f9cdc9560b0339d87fdf5f03c9
5
5
  SHA512:
6
- metadata.gz: 7c85e13cf698bcb599380d24b4eff94fc8c5ea157947ba42ec4bf2cd56bbf83043a4bc660fe78da567e35b3c4f0b9780fcbc1105886d79bc05d21e6495fdb295
7
- data.tar.gz: 334c79870dd8a1dde30dfd971f0007d8f925cb1bccc870d863a0e86509f9840671754a4a4b17ec51d21f29cd458997e4a99140c3aa325c210018120e6e8012a9
6
+ metadata.gz: 1555cc93d12c2358037c19491fd81f12a94554038a9fe8b720222a0a687ce4cd97149bef414f00784d70df774182cde5c10f0431a796af418b700d5cca7b04e2
7
+ data.tar.gz: 09174b70d83b62c5cedab69f75c6d1b29adee105153ae80970e2fda19a0a77d5152ba1d56d17b2bd1bfa49a0d3216c7e8a9fc528e012af9d9c327202c93fa0e2
@@ -27,8 +27,9 @@ else
27
27
  end
28
28
 
29
29
  if File.directory?(GEMS_LOCATION)
30
- Gem.use_paths(GEMS_LOCATION)
31
- $LOAD_PATH.reject! {|l| l =~ /(vendor|site)_ruby/ }
30
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
31
+ require 'rubygems'
32
+ Gem.use_paths(File.realpath(GEMS_LOCATION))
32
33
  end
33
34
 
34
35
  $LOAD_PATH << RUBY_LIB_LOCATION
data/bin/oneacl CHANGED
@@ -27,8 +27,9 @@ else
27
27
  end
28
28
 
29
29
  if File.directory?(GEMS_LOCATION)
30
- Gem.use_paths(GEMS_LOCATION)
31
- $LOAD_PATH.reject! {|l| l =~ /(vendor|site)_ruby/ }
30
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
31
+ require 'rubygems'
32
+ Gem.use_paths(File.realpath(GEMS_LOCATION))
32
33
  end
33
34
 
34
35
  $LOAD_PATH << RUBY_LIB_LOCATION
@@ -27,8 +27,9 @@ else
27
27
  end
28
28
 
29
29
  if File.directory?(GEMS_LOCATION)
30
- Gem.use_paths(GEMS_LOCATION)
31
- $LOAD_PATH.reject! {|l| l =~ /(vendor|site)_ruby/ }
30
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
31
+ require 'rubygems'
32
+ Gem.use_paths(File.realpath(GEMS_LOCATION))
32
33
  end
33
34
 
34
35
  $LOAD_PATH << RUBY_LIB_LOCATION
@@ -27,8 +27,9 @@ else
27
27
  end
28
28
 
29
29
  if File.directory?(GEMS_LOCATION)
30
- Gem.use_paths(GEMS_LOCATION)
31
- $LOAD_PATH.reject! {|l| l =~ /(vendor|site)_ruby/ }
30
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
31
+ require 'rubygems'
32
+ Gem.use_paths(File.realpath(GEMS_LOCATION))
32
33
  end
33
34
 
34
35
  $LOAD_PATH << RUBY_LIB_LOCATION
@@ -27,8 +27,9 @@ else
27
27
  end
28
28
 
29
29
  if File.directory?(GEMS_LOCATION)
30
- Gem.use_paths(GEMS_LOCATION)
31
- $LOAD_PATH.reject! {|l| l =~ /(vendor|site)_ruby/ }
30
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
31
+ require 'rubygems'
32
+ Gem.use_paths(File.realpath(GEMS_LOCATION))
32
33
  end
33
34
 
34
35
  $LOAD_PATH << RUBY_LIB_LOCATION
@@ -29,8 +29,9 @@ else
29
29
  end
30
30
 
31
31
  if File.directory?(GEMS_LOCATION)
32
- Gem.use_paths(GEMS_LOCATION)
33
- $LOAD_PATH.reject! {|l| l =~ /(vendor|site)_ruby/ }
32
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
33
+ require 'rubygems'
34
+ Gem.use_paths(File.realpath(GEMS_LOCATION))
34
35
  end
35
36
 
36
37
  $LOAD_PATH << RUBY_LIB_LOCATION
@@ -27,8 +27,9 @@ else
27
27
  end
28
28
 
29
29
  if File.directory?(GEMS_LOCATION)
30
- Gem.use_paths(GEMS_LOCATION)
31
- $LOAD_PATH.reject! {|l| l =~ /(vendor|site)_ruby/ }
30
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
31
+ require 'rubygems'
32
+ Gem.use_paths(File.realpath(GEMS_LOCATION))
32
33
  end
33
34
 
34
35
  $LOAD_PATH << RUBY_LIB_LOCATION
@@ -27,8 +27,9 @@ else
27
27
  end
28
28
 
29
29
  if File.directory?(GEMS_LOCATION)
30
- Gem.use_paths(GEMS_LOCATION)
31
- $LOAD_PATH.reject! {|l| l =~ /(vendor|site)_ruby/ }
30
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
31
+ require 'rubygems'
32
+ Gem.use_paths(File.realpath(GEMS_LOCATION))
32
33
  end
33
34
 
34
35
  $LOAD_PATH << RUBY_LIB_LOCATION
@@ -29,8 +29,9 @@ else
29
29
  end
30
30
 
31
31
  if File.directory?(GEMS_LOCATION)
32
- Gem.use_paths(GEMS_LOCATION)
33
- $LOAD_PATH.reject! {|l| l =~ /(vendor|site)_ruby/ }
32
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
33
+ require 'rubygems'
34
+ Gem.use_paths(File.realpath(GEMS_LOCATION))
34
35
  end
35
36
 
36
37
  $LOAD_PATH << RUBY_LIB_LOCATION
@@ -27,8 +27,9 @@ else
27
27
  end
28
28
 
29
29
  if File.directory?(GEMS_LOCATION)
30
- Gem.use_paths(GEMS_LOCATION)
31
- $LOAD_PATH.reject! {|l| l =~ /(vendor|site)_ruby/ }
30
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
31
+ require 'rubygems'
32
+ Gem.use_paths(File.realpath(GEMS_LOCATION))
32
33
  end
33
34
 
34
35
  $LOAD_PATH << RUBY_LIB_LOCATION
@@ -27,8 +27,9 @@ else
27
27
  end
28
28
 
29
29
  if File.directory?(GEMS_LOCATION)
30
- Gem.use_paths(GEMS_LOCATION)
31
- $LOAD_PATH.reject! {|l| l =~ /(vendor|site)_ruby/ }
30
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
31
+ require 'rubygems'
32
+ Gem.use_paths(File.realpath(GEMS_LOCATION))
32
33
  end
33
34
 
34
35
  $LOAD_PATH << RUBY_LIB_LOCATION
@@ -29,8 +29,9 @@ else
29
29
  end
30
30
 
31
31
  if File.directory?(GEMS_LOCATION)
32
- Gem.use_paths(GEMS_LOCATION)
33
- $LOAD_PATH.reject! {|l| l =~ /(vendor|site)_ruby/ }
32
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
33
+ require 'rubygems'
34
+ Gem.use_paths(File.realpath(GEMS_LOCATION))
34
35
  end
35
36
 
36
37
  $LOAD_PATH << RUBY_LIB_LOCATION
@@ -27,8 +27,9 @@ else
27
27
  end
28
28
 
29
29
  if File.directory?(GEMS_LOCATION)
30
- Gem.use_paths(GEMS_LOCATION)
31
- $LOAD_PATH.reject! {|l| l =~ /(vendor|site)_ruby/ }
30
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
31
+ require 'rubygems'
32
+ Gem.use_paths(File.realpath(GEMS_LOCATION))
32
33
  end
33
34
 
34
35
  $LOAD_PATH << RUBY_LIB_LOCATION
@@ -27,8 +27,9 @@ else
27
27
  end
28
28
 
29
29
  if File.directory?(GEMS_LOCATION)
30
- Gem.use_paths(GEMS_LOCATION)
31
- $LOAD_PATH.reject! {|l| l =~ /(vendor|site)_ruby/ }
30
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
31
+ require 'rubygems'
32
+ Gem.use_paths(File.realpath(GEMS_LOCATION))
32
33
  end
33
34
 
34
35
  $LOAD_PATH << RUBY_LIB_LOCATION
@@ -27,8 +27,9 @@ else
27
27
  end
28
28
 
29
29
  if File.directory?(GEMS_LOCATION)
30
- Gem.use_paths(GEMS_LOCATION)
31
- $LOAD_PATH.reject! {|l| l =~ /(vendor|site)_ruby/ }
30
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
31
+ require 'rubygems'
32
+ Gem.use_paths(File.realpath(GEMS_LOCATION))
32
33
  end
33
34
 
34
35
  $LOAD_PATH << RUBY_LIB_LOCATION
@@ -27,8 +27,9 @@ else
27
27
  end
28
28
 
29
29
  if File.directory?(GEMS_LOCATION)
30
- Gem.use_paths(GEMS_LOCATION)
31
- $LOAD_PATH.reject! {|l| l =~ /(vendor|site)_ruby/ }
30
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
31
+ require 'rubygems'
32
+ Gem.use_paths(File.realpath(GEMS_LOCATION))
32
33
  end
33
34
 
34
35
  $LOAD_PATH << RUBY_LIB_LOCATION
@@ -29,8 +29,9 @@ else
29
29
  end
30
30
 
31
31
  if File.directory?(GEMS_LOCATION)
32
- Gem.use_paths(GEMS_LOCATION)
33
- $LOAD_PATH.reject! {|l| l =~ /(vendor|site)_ruby/ }
32
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
33
+ require 'rubygems'
34
+ Gem.use_paths(File.realpath(GEMS_LOCATION))
34
35
  end
35
36
 
36
37
  $LOAD_PATH << RUBY_LIB_LOCATION
data/bin/onevdc CHANGED
@@ -27,8 +27,9 @@ else
27
27
  end
28
28
 
29
29
  if File.directory?(GEMS_LOCATION)
30
- Gem.use_paths(GEMS_LOCATION)
31
- $LOAD_PATH.reject! {|l| l =~ /(vendor|site)_ruby/ }
30
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
31
+ require 'rubygems'
32
+ Gem.use_paths(File.realpath(GEMS_LOCATION))
32
33
  end
33
34
 
34
35
  $LOAD_PATH << RUBY_LIB_LOCATION
data/bin/onevm CHANGED
@@ -27,8 +27,9 @@ else
27
27
  end
28
28
 
29
29
  if File.directory?(GEMS_LOCATION)
30
- Gem.use_paths(GEMS_LOCATION)
31
- $LOAD_PATH.reject! {|l| l =~ /(vendor|site)_ruby/ }
30
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
31
+ require 'rubygems'
32
+ Gem.use_paths(File.realpath(GEMS_LOCATION))
32
33
  end
33
34
 
34
35
  $LOAD_PATH << RUBY_LIB_LOCATION
@@ -1297,6 +1298,86 @@ CommandParser::CmdParser.new(ARGV) do
1297
1298
  end
1298
1299
  end
1299
1300
 
1301
+ ########################### Charters Management ############################
1302
+
1303
+ create_chart_desc = <<-EOT.unindent
1304
+ Adds a charter to the VM, these are some consecutive scheduled actions
1305
+
1306
+ You can configure the actions in /etc/one/cli/onevm.yaml
1307
+ EOT
1308
+
1309
+ command :'create-chart', create_chart_desc, [:range, :vmid_list] do
1310
+ charters = helper.get_charters
1311
+
1312
+ if charters.nil?
1313
+ STDERR.puts 'No charters found on configuration file'
1314
+ exit(-1)
1315
+ end
1316
+
1317
+ acc_t = 0
1318
+ acc_w = 0
1319
+
1320
+ charters.each do |action, time|
1321
+ sched = "+#{time[:time].to_i + acc_t}"
1322
+
1323
+ helper.schedule_actions(args[0],
1324
+ { :schedule => sched },
1325
+ action.to_s,
1326
+ time[:warning][:time] + acc_w)
1327
+
1328
+ acc_t += time[:time].to_i
1329
+ acc_w += time[:warning][:time].to_i
1330
+ end
1331
+
1332
+ 0
1333
+ end
1334
+
1335
+ delete_chart_desc = <<-EOT.unindent
1336
+ Deletes a charter from the VM
1337
+ EOT
1338
+
1339
+ command :'delete-chart', delete_chart_desc, :vmid, :sched_id do
1340
+ helper.perform_action(args[0], {}, 'Charter deleted') do |vm|
1341
+ rc = vm.info
1342
+
1343
+ if OpenNebula.is_error?(rc)
1344
+ STDERR.puts "Error #{rc.message}"
1345
+ exit(-1)
1346
+ end
1347
+
1348
+ xpath = "USER_TEMPLATE/SCHED_ACTION[ID=#{args[1]}]"
1349
+
1350
+ unless vm.retrieve_elements(xpath)
1351
+ STDERR.puts "Sched action #{args[1]} not found"
1352
+ exit(-1)
1353
+ end
1354
+
1355
+ vm.delete_element(xpath)
1356
+ rc = vm.update(vm.user_template_str)
1357
+
1358
+ if OpenNebula.is_error?(rc)
1359
+ STDERR.puts "Error deleting: #{rc.message}"
1360
+ exit(-1)
1361
+ end
1362
+ end
1363
+
1364
+ 0
1365
+ end
1366
+
1367
+ update_chart_desc = <<-EOT.unindent
1368
+ Updates a charter from a VM
1369
+ EOT
1370
+
1371
+ command :'update-chart',
1372
+ update_chart_desc,
1373
+ :vmid,
1374
+ :sched_id,
1375
+ [:file, nil] do
1376
+ helper.update_schedule_action(args[0], args[1], args[2])
1377
+
1378
+ 0
1379
+ end
1380
+
1300
1381
  # Deprecated commands
1301
1382
 
1302
1383
  deprecated_command(:shutdown, 'terminate')
@@ -27,8 +27,9 @@ else
27
27
  end
28
28
 
29
29
  if File.directory?(GEMS_LOCATION)
30
- Gem.use_paths(GEMS_LOCATION)
31
- $LOAD_PATH.reject! {|l| l =~ /(vendor|site)_ruby/ }
30
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
31
+ require 'rubygems'
32
+ Gem.use_paths(File.realpath(GEMS_LOCATION))
32
33
  end
33
34
 
34
35
  $LOAD_PATH << RUBY_LIB_LOCATION
@@ -27,8 +27,9 @@ else
27
27
  end
28
28
 
29
29
  if File.directory?(GEMS_LOCATION)
30
- Gem.use_paths(GEMS_LOCATION)
31
- $LOAD_PATH.reject! {|l| l =~ /(vendor|site)_ruby/ }
30
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
31
+ require 'rubygems'
32
+ Gem.use_paths(File.realpath(GEMS_LOCATION))
32
33
  end
33
34
 
34
35
  $LOAD_PATH << RUBY_LIB_LOCATION
@@ -350,43 +351,9 @@ CommandParser::CmdParser.new(ARGV) do
350
351
  Update Address Range variables. SIZE, IP, MAC and TYPE cannot be updated
351
352
  EOT
352
353
 
353
- command :updatear, update_ar_desc, :vnetid, :ar_id, [:file, nil] do
354
- helper.perform_action(args[0], options, 'modified') do |obj|
355
- rc = obj.info
356
-
357
- if OpenNebula.is_error?(rc)
358
- puts rc.message
359
- exit(-1)
360
- end
361
-
362
- obj.delete_element("AR_POOL/AR[AR_ID!=#{args[1]}]")
363
- obj.delete_element('AR_POOL/AR/LEASES')
364
- obj.delete_element('AR_POOL/AR/USED_LEASES')
365
- obj.delete_element('AR_POOL/AR/MAC_END')
366
- obj.delete_element('AR_POOL/AR/IP_END')
367
- obj.delete_element('AR_POOL/AR/IP6_ULA')
368
- obj.delete_element('AR_POOL/AR/IP6_ULA_END')
369
- obj.delete_element('AR_POOL/AR/IP6_GLOBAL')
370
- obj.delete_element('AR_POOL/AR/IP6_GLOBAL_END')
371
-
372
- if obj.template_like_str('AR_POOL').empty?
373
- puts "Address Range #{args[1]} does not exist for " \
374
- "Virtual Network #{args[0]}"
375
- exit(-1)
376
- end
377
-
378
- str = OpenNebulaHelper.update_template_helper(false,
379
- args[0],
380
- obj,
381
- args[2],
382
- 'AR_POOL',
383
- false)
384
-
385
- helper.set_client(options)
386
- obj = helper.retrieve_resource(obj.id)
387
-
388
- obj.update_ar(str)
389
- end
354
+ command :updatear, update_ar_desc, :vnetid, :ar_id, [:file, nil],
355
+ :options => OpenNebulaHelper::APPEND do
356
+ helper.update_ar(args[0], args[1], args[2], options)
390
357
  end
391
358
 
392
359
  rename_desc = <<-EOT.unindent
@@ -27,8 +27,9 @@ else
27
27
  end
28
28
 
29
29
  if File.directory?(GEMS_LOCATION)
30
- Gem.use_paths(GEMS_LOCATION)
31
- $LOAD_PATH.reject! {|l| l =~ /(vendor|site)_ruby/ }
30
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
31
+ require 'rubygems'
32
+ Gem.use_paths(File.realpath(GEMS_LOCATION))
32
33
  end
33
34
 
34
35
  $LOAD_PATH << RUBY_LIB_LOCATION
@@ -27,8 +27,9 @@ else
27
27
  end
28
28
 
29
29
  if File.directory?(GEMS_LOCATION)
30
- Gem.use_paths(GEMS_LOCATION)
31
- $LOAD_PATH.reject! {|l| l =~ /(vendor|site)_ruby/ }
30
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
31
+ require 'rubygems'
32
+ Gem.use_paths(File.realpath(GEMS_LOCATION))
32
33
  end
33
34
 
34
35
  $LOAD_PATH << RUBY_LIB_LOCATION
@@ -27,8 +27,9 @@ else
27
27
  end
28
28
 
29
29
  if File.directory?(GEMS_LOCATION)
30
- Gem.use_paths(GEMS_LOCATION)
31
- $LOAD_PATH.reject! {|l| l =~ /(vendor|site)_ruby/ }
30
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
31
+ require 'rubygems'
32
+ Gem.use_paths(File.realpath(GEMS_LOCATION))
32
33
  end
33
34
 
34
35
  $LOAD_PATH << RUBY_LIB_LOCATION
@@ -295,6 +295,11 @@ module CommandParser
295
295
  cmd[:arity]+=1 unless args.include?(nil)
296
296
  cmd[:args_format] << args
297
297
  elsif args.instance_of?(Hash) && args[:options]
298
+ if args[:options].is_a? Array
299
+ args[:options].flatten!
300
+ args[:options] = args[:options].sort_by {|o| o[:name] }
301
+ end
302
+
298
303
  cmd[:options] << args[:options]
299
304
  else
300
305
  cmd[:arity]+=1
@@ -679,7 +684,9 @@ module CommandParser
679
684
  def print_options
680
685
  puts "## OPTIONS"
681
686
 
682
- shown_opts = Array.new
687
+ shown_opts = []
688
+ options = []
689
+
683
690
  @command_list.each do |key|
684
691
  value = @commands[key]
685
692
 
@@ -688,14 +695,17 @@ module CommandParser
688
695
  next
689
696
  else
690
697
  shown_opts << o[:name]
691
-
692
- print_option(o)
698
+ options << o
693
699
  end
694
700
  end
695
701
  end
696
702
 
697
- @available_options.each do |o|
698
- print_option o
703
+ options << @available_options
704
+ options.flatten!
705
+ options = options.sort_by {|o| o[:name] }
706
+
707
+ options.each do |o|
708
+ print_option(o)
699
709
  end
700
710
  end
701
711
 
@@ -724,6 +734,8 @@ module CommandParser
724
734
  else
725
735
  puts "## COMMANDS"
726
736
 
737
+ @command_list.sort! if @command_list
738
+
727
739
  @command_list.each do |key|
728
740
  value = @commands[key]
729
741
  printf cmd_format5, "* #{key} "
@@ -766,6 +778,9 @@ module CommandParser
766
778
 
767
779
  cmd_format5 = "#{' '*3}%s"
768
780
  cmd_format10 = "#{' '*8}%s"
781
+
782
+ @formats = @formats.sort_by {|key, _| key } if @formats
783
+
769
784
  @formats.each{ |key,value|
770
785
  printf cmd_format5, "* #{key}"
771
786
  puts
@@ -406,7 +406,11 @@ class OneFlowHelper < OpenNebulaHelper::OneHelper
406
406
 
407
407
  column :TIME, '', :left, :size => 67 do |d|
408
408
  if d['start_time']
409
- Time.parse(d['start_time']).to_s
409
+ if !d['start_time'].match(/^\d+$/)
410
+ Time.parse(d['start_time']).to_s
411
+ else
412
+ d['start_time']
413
+ end
410
414
  else
411
415
  d['recurrence']
412
416
  end
@@ -237,11 +237,11 @@ class OneVcenterHelper < OpenNebulaHelper::OneHelper
237
237
  d[:import_id]
238
238
  end
239
239
 
240
- column :REF, "ref", :left, :size=>config[:REF] || 15 do |d|
240
+ column :REF, "ref", :left, :adjust, :size=>config[:REF] || 15 do |d|
241
241
  d[:ref]
242
242
  end
243
243
 
244
- column :NAME, "Name", :left, :size=>config[:NAME] || 20 do |d|
244
+ column :NAME, "Name", :left, :expand, :size=>config[:NAME] || 20 do |d|
245
245
  d[:name] || d[:simple_name]
246
246
  end
247
247
 
@@ -250,7 +250,7 @@ class OneVcenterHelper < OpenNebulaHelper::OneHelper
250
250
  d[:one_ids] || d[:cluster].to_s
251
251
  end
252
252
 
253
- column :PATH, "PATH", :left, :size=>config[:PATH] || 10 do |d|
253
+ column :PATH, "PATH", :left, :expand, :size=>config[:PATH] || 10 do |d|
254
254
  d[:path]
255
255
  end
256
256
 
@@ -354,7 +354,7 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
354
354
 
355
355
  column :MEM, 'Memory asigned to the VM', :size => 7 do |d|
356
356
  OpenNebulaHelper.unit_to_str(d['TEMPLATE']['MEMORY'].to_i,
357
- options)
357
+ options, 'M')
358
358
  end
359
359
 
360
360
  column :HOST, 'Host where the VM is running',
@@ -402,7 +402,7 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
402
402
  table
403
403
  end
404
404
 
405
- def schedule_actions(ids, options, action)
405
+ def schedule_actions(ids, options, action, warning = nil)
406
406
  # Verbose by default
407
407
  options[:verbose] = true
408
408
 
@@ -453,18 +453,74 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
453
453
  id = ids.max + 1
454
454
  end
455
455
 
456
+ sched = options[:schedule]
457
+
458
+ # If the action is set to be executed from VM start to an specific
459
+ # amount of time later, we should preserve the + symbol
460
+ if ((sched.is_a? String) && !sched.include?('+')) ||
461
+ !(sched.is_a? String)
462
+ sched = sched.to_i
463
+ end
464
+
456
465
  tmp_str = vm.user_template_str
457
466
 
458
467
  tmp_str << "\nSCHED_ACTION = "
459
468
  tmp_str << "[ID = #{id}, ACTION = #{action}, "
469
+ tmp_str << "WARNING = #{warning}," if warning
460
470
  tmp_str << "ARGS = \"#{options[:args]}\"," if options[:args]
461
- tmp_str << "TIME = #{options[:schedule].to_i}"
471
+ tmp_str << "TIME = #{sched}"
462
472
  tmp_str << str_periodic << ']'
463
473
 
464
474
  vm.update(tmp_str)
465
475
  end
466
476
  end
467
477
 
478
+ # Update schedule action
479
+ #
480
+ # @param vm_id [Integer] Virtual Machine ID
481
+ # @param action_id [Integer] Sched action ID
482
+ # @param file [String] File path with update content
483
+ def update_schedule_action(vm_id, action_id, file)
484
+ perform_action(vm_id, {}, 'Sched action updated') do |vm|
485
+ rc = vm.info
486
+
487
+ if OpenNebula.is_error?(rc)
488
+ STDERR.puts "Error #{rc.message}"
489
+ exit(-1)
490
+ end
491
+
492
+ xpath = "USER_TEMPLATE/SCHED_ACTION[ID=#{action_id}]"
493
+
494
+ unless vm.retrieve_elements(xpath)
495
+ STDERR.puts "Sched action #{action_id} not found"
496
+ exit(-1)
497
+ end
498
+
499
+ # Get user information
500
+ if file
501
+ str = File.read(file)
502
+ else
503
+ str = OpenNebulaHelper.update_template(vm_id, vm, nil, xpath)
504
+ end
505
+
506
+ # Delete the current sched action
507
+ vm.delete_element(xpath)
508
+
509
+ # Add the modified sched action
510
+ tmp_str = vm.user_template_str
511
+ tmp_str << "\nSCHED_ACTION = ["
512
+ tmp_str << str.split("\n").join(',')
513
+ tmp_str << ']'
514
+
515
+ rc = vm.update(tmp_str)
516
+
517
+ if OpenNebula.is_error?(rc)
518
+ STDERR.puts "Error updating: #{rc.message}"
519
+ exit(-1)
520
+ end
521
+ end
522
+ end
523
+
468
524
  RECOVER_RETRY_STEPS = {
469
525
  :PROLOG_MIGRATE_FAILURE => :migrate,
470
526
  :PROLOG_MIGRATE_POWEROFF_FAILURE => :migrate,
@@ -602,6 +658,16 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
602
658
  end
603
659
  end
604
660
 
661
+ # Get charters configuration
662
+ #
663
+ # @return [Array]
664
+ # - action
665
+ # - time
666
+ # - warning
667
+ def get_charters
668
+ YAML.load_file(self.class.table_conf)[:charters]
669
+ end
670
+
605
671
  private
606
672
 
607
673
  def factory(id = nil)
@@ -1144,24 +1210,24 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
1144
1210
  CLIHelper.print_header(str_h1 % 'SCHEDULED ACTIONS', false)
1145
1211
 
1146
1212
  CLIHelper::ShowTable.new(nil, self) do
1147
- column :ID, '', :size => 2 do |d|
1213
+ column :ID, '', :adjust => true do |d|
1148
1214
  d['ID'] unless d.nil?
1149
1215
  end
1150
1216
 
1151
- column :ACTION, '', :left, :size => 15 do |d|
1217
+ column :ACTION, '', :adjust => true do |d|
1152
1218
  d['ACTION'] unless d.nil?
1153
1219
  end
1154
1220
 
1155
- column :ARGS, '', :left, :size => 15 do |d|
1221
+ column :ARGS, '', :adjust => true do |d|
1156
1222
  d['ARGS'] ? d['ARGS'] : '-'
1157
1223
  end
1158
1224
 
1159
- column :SCHEDULED, '', :size => 12 do |d|
1225
+ column :SCHEDULED, '', :adjust => true do |d|
1160
1226
  OpenNebulaHelper.time_to_str(d['TIME'], false) \
1161
1227
  unless d.nil?
1162
1228
  end
1163
1229
 
1164
- column :REPEAT, '', :size => 20 do |d|
1230
+ column :REPEAT, '', :adjust => true do |d|
1165
1231
  str_rep = ''
1166
1232
  if !d.nil? && d.key?('REPEAT')
1167
1233
  if d['REPEAT'] == '0'
@@ -1180,7 +1246,7 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
1180
1246
  str_rep unless d.nil?
1181
1247
  end
1182
1248
 
1183
- column :END, '', :size => 20 do |d|
1249
+ column :END, '', :adjust => true do |d|
1184
1250
  str_end = ''
1185
1251
  if !d.nil? && d.key?('END_TYPE')
1186
1252
  if d['END_TYPE'] == '0'
@@ -1197,25 +1263,50 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
1197
1263
  str_end unless d.nil?
1198
1264
  end
1199
1265
 
1200
- column :DONE, '', :size => 12 do |d|
1266
+ column :DONE, '', :adjust => true do |d|
1201
1267
  OpenNebulaHelper.time_to_str(d['DONE'], false) \
1202
1268
  unless d.nil?
1203
1269
  end
1204
1270
 
1205
- column :MESSAGE, '', :left, :adjust, :size => 35 do |d|
1206
- d['MESSAGE'] unless d.nil?
1271
+ column :MESSAGE, '', :size => 35 do |d|
1272
+ d['MESSAGE'] ? d['MESSAGE'] : '-'
1273
+ end
1274
+
1275
+ column :CHARTER, '', :left, :adjust, :size => 15 do |d|
1276
+ t1 = Time.now
1277
+ t2 = Time.at(vm['STIME'].to_i + d['TIME'].to_i)
1278
+
1279
+ days = ((t2 - t1) / (24 * 3600)).round(2)
1280
+ hours = ((t2 - t1) / 3600).round(2)
1281
+ minutes = ((t2 - t1) / 60).round(2)
1282
+
1283
+ if days > 1
1284
+ show = "In #{days} days"
1285
+ elsif days < 1 && hours > 1
1286
+ show = "In #{hours} hours"
1287
+ elsif minutes > 0
1288
+ show = "In #{minutes} minutes"
1289
+ else
1290
+ show = 'Already done'
1291
+ end
1292
+
1293
+ if (t1 - vm['STIME'].to_i).to_i > d['WARNING'].to_i
1294
+ "#{show} *"
1295
+ else
1296
+ show
1297
+ end
1207
1298
  end
1208
1299
  end.show([vm_hash['VM']['USER_TEMPLATE']['SCHED_ACTION']].flatten,
1209
1300
  {})
1210
1301
  end
1211
1302
 
1303
+ if !options[:all]
1304
+ vm.delete_element('/VM/USER_TEMPLATE/SCHED_ACTION')
1305
+ end
1306
+
1212
1307
  if vm.has_elements?('/VM/USER_TEMPLATE')
1213
1308
  puts
1214
1309
 
1215
- if !options[:all]
1216
- vm.delete_element('/VM/USER_TEMPLATE/SCHED_ACTION')
1217
- end
1218
-
1219
1310
  CLIHelper.print_header(str_h1 % 'USER TEMPLATE', false)
1220
1311
  puts vm.template_like_str('USER_TEMPLATE')
1221
1312
  end
@@ -13,7 +13,6 @@
13
13
  # See the License for the specific language governing permissions and #
14
14
  # limitations under the License. #
15
15
  #--------------------------------------------------------------------------- #
16
-
17
16
  require 'one_helper'
18
17
  require 'one_helper/onevm_helper'
19
18
 
@@ -215,6 +214,71 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
215
214
  orphans
216
215
  end
217
216
 
217
+ # Update VNet address range
218
+ #
219
+ # @param vnet_id [Intenger] Virtual Network ID
220
+ # @param ar_id [Intenger] Address Range ID
221
+ # @param file [String] Path to file to read
222
+ # @param options [Hash] User CLI options
223
+ def update_ar(vnet_id, ar_id, file, options)
224
+ perform_action(vnet_id, options, 'AR updated') do |obj|
225
+ rc = obj.info
226
+
227
+ if OpenNebula.is_error?(rc)
228
+ STDERR.puts rc.message
229
+ exit(-1)
230
+ end
231
+
232
+ obj.delete_element("AR_POOL/AR[AR_ID!=#{ar_id}]")
233
+ obj.delete_element('AR_POOL/AR/LEASES')
234
+ obj.delete_element('AR_POOL/AR/USED_LEASES')
235
+ obj.delete_element('AR_POOL/AR/MAC_END')
236
+ obj.delete_element('AR_POOL/AR/IP_END')
237
+ obj.delete_element('AR_POOL/AR/IP6_ULA')
238
+ obj.delete_element('AR_POOL/AR/IP6_ULA_END')
239
+ obj.delete_element('AR_POOL/AR/IP6_GLOBAL')
240
+ obj.delete_element('AR_POOL/AR/IP6_GLOBAL_END')
241
+
242
+ if obj.template_like_str('AR_POOL').empty?
243
+ STDERR.puts "Address Range #{ar_id} does not exist for " \
244
+ "Virtual Network #{vnet_id}"
245
+ exit(-1)
246
+ end
247
+
248
+ xpath = "AR_POOL/AR[AR_ID=#{ar_id}]"
249
+
250
+ if options[:append]
251
+ str = OpenNebulaHelper.append_template(vnet_id,
252
+ obj,
253
+ file,
254
+ xpath)
255
+ else
256
+ str = OpenNebulaHelper.update_template(vnet_id,
257
+ obj,
258
+ file,
259
+ xpath)
260
+ end
261
+
262
+ if options[:append]
263
+ # Insert element in current template
264
+ parts = obj.template_like_str('AR_POOL').split("\n")
265
+
266
+ # Insert it in second position, OpenNebula will sort it
267
+ parts.insert(1, "#{str.strip},")
268
+
269
+ parts = parts.join("\n")
270
+ str = parts
271
+ else
272
+ # Use the information from user
273
+ unless str.gsub(' ', '').match(/AR=\[/)
274
+ str = "AR=[\n#{str.split("\n").join(",\n")}]"
275
+ end
276
+ end
277
+
278
+ obj.update_ar(str)
279
+ end
280
+ end
281
+
218
282
  private
219
283
 
220
284
  def factory(id=nil)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opennebula-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.12.0
4
+ version: 5.12.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenNebula
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-14 00:00:00.000000000 Z
11
+ date: 2020-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opennebula
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 5.12.0
19
+ version: 5.12.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 5.12.0
26
+ version: 5.12.1
27
27
  description: Commands used to talk to OpenNebula
28
28
  email: contact@opennebula.io
29
29
  executables: