opennebula-cli 6.4.7 → 6.5.80.pre

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.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/bin/oneacct +2 -2
  3. data/bin/oneacl +1 -1
  4. data/bin/onecluster +1 -1
  5. data/bin/onedatastore +1 -1
  6. data/bin/oneflow +2 -3
  7. data/bin/oneflow-template +2 -2
  8. data/bin/onegroup +1 -1
  9. data/bin/onehook +1 -1
  10. data/bin/onehost +1 -1
  11. data/bin/oneimage +52 -3
  12. data/bin/oneirb +1 -1
  13. data/bin/onelog +1 -1
  14. data/bin/onemarket +1 -1
  15. data/bin/onemarketapp +1 -1
  16. data/bin/onesecgroup +1 -1
  17. data/bin/oneshowback +2 -2
  18. data/bin/onetemplate +1 -1
  19. data/bin/oneuser +4 -4
  20. data/bin/onevcenter +2 -2
  21. data/bin/onevdc +1 -1
  22. data/bin/onevm +146 -161
  23. data/bin/onevmgroup +1 -1
  24. data/bin/onevnet +16 -4
  25. data/bin/onevntemplate +1 -1
  26. data/bin/onevrouter +1 -1
  27. data/bin/onezone +6 -2
  28. data/lib/cli_helper.rb +20 -20
  29. data/lib/command_parser.rb +1 -1
  30. data/lib/one_helper/oneacct_helper.rb +1 -1
  31. data/lib/one_helper/oneacl_helper.rb +1 -1
  32. data/lib/one_helper/onecluster_helper.rb +1 -1
  33. data/lib/one_helper/onedatastore_helper.rb +1 -1
  34. data/lib/one_helper/oneflow_helper.rb +2 -2
  35. data/lib/one_helper/oneflowtemplate_helper.rb +2 -2
  36. data/lib/one_helper/onegroup_helper.rb +1 -1
  37. data/lib/one_helper/onehook_helper.rb +1 -1
  38. data/lib/one_helper/onehost_helper.rb +15 -60
  39. data/lib/one_helper/oneimage_helper.rb +73 -12
  40. data/lib/one_helper/onemarket_helper.rb +1 -1
  41. data/lib/one_helper/onemarketapp_helper.rb +3 -3
  42. data/lib/one_helper/onequota_helper.rb +1 -1
  43. data/lib/one_helper/onesecgroup_helper.rb +1 -1
  44. data/lib/one_helper/onetemplate_helper.rb +1 -2
  45. data/lib/one_helper/oneuser_helper.rb +1 -1
  46. data/lib/one_helper/onevcenter_helper.rb +7 -7
  47. data/lib/one_helper/onevdc_helper.rb +1 -1
  48. data/lib/one_helper/onevm_helper.rb +68 -57
  49. data/lib/one_helper/onevmgroup_helper.rb +1 -1
  50. data/lib/one_helper/onevnet_helper.rb +37 -3
  51. data/lib/one_helper/onevntemplate_helper.rb +1 -1
  52. data/lib/one_helper/onevrouter_helper.rb +1 -1
  53. data/lib/one_helper/onezone_helper.rb +1 -1
  54. data/lib/one_helper.rb +7 -8
  55. data/share/schemas/xsd/acct.xsd +28 -0
  56. data/share/schemas/xsd/hook_message_state.xsd +5 -1
  57. data/share/schemas/xsd/host.xsd +5 -38
  58. data/share/schemas/xsd/image.xsd +18 -0
  59. data/share/schemas/xsd/opennebula_configuration.xsd +2 -0
  60. data/share/schemas/xsd/vm.xsd +30 -0
  61. data/share/schemas/xsd/vnet.xsd +28 -0
  62. data/share/schemas/xsd/vnet_pool.xsd +28 -0
  63. metadata +26 -26
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -297,7 +297,7 @@ class OneFlowHelper < OpenNebulaHelper::OneHelper
297
297
 
298
298
  CLIHelper.print_header(str_h1 % 'PERMISSIONS', false)
299
299
 
300
- ['OWNER', 'GROUP', 'OTHER'].each do |e|
300
+ %w[OWNER GROUP OTHER].each do |e|
301
301
  mask = '---'
302
302
  permissions_hash = document['PERMISSIONS']
303
303
  mask[0] = 'u' if permissions_hash["#{e}_U"] == '1'
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -157,7 +157,7 @@ class OneFlowTemplateHelper < OpenNebulaHelper::OneHelper
157
157
 
158
158
  CLIHelper.print_header(str_h1 % 'PERMISSIONS', false)
159
159
 
160
- ['OWNER', 'GROUP', 'OTHER'].each do |e|
160
+ %w[OWNER GROUP OTHER].each do |e|
161
161
  mask = '---'
162
162
  permissions_hash = document['PERMISSIONS']
163
163
  mask[0] = 'u' if permissions_hash["#{e}_U"] == '1'
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -14,6 +14,7 @@
14
14
  # limitations under the License. #
15
15
  #--------------------------------------------------------------------------- #
16
16
 
17
+ require 'HostSyncManager'
17
18
  require 'one_helper'
18
19
  require 'one_helper/onevm_helper'
19
20
  require 'rubygems'
@@ -268,12 +269,11 @@ class OneHostHelper < OpenNebulaHelper::OneHelper
268
269
 
269
270
  cluster_id = options[:cluster]
270
271
 
271
- # Get remote_dir (implies oneadmin group)
272
272
  rc = OpenNebula::System.new(@client).get_configuration
273
273
  return -1, rc.message if OpenNebula.is_error?(rc)
274
274
 
275
275
  conf = rc
276
- remote_dir = conf['SCRIPTS_REMOTE_DIR']
276
+ sync_manager = HostSyncManager.new(conf)
277
277
 
278
278
  # Verify the existence of REMOTES_LOCATION
279
279
  if !File.directory? REMOTES_LOCATION
@@ -363,21 +363,13 @@ class OneHostHelper < OpenNebulaHelper::OneHelper
363
363
 
364
364
  print_update_info(total - size, total, host['NAME'])
365
365
 
366
- if options[:ssh]
367
- sync_cmd = "ssh #{host['NAME']}" \
368
- " rm -rf '#{remote_dir}' 2>/dev/null;" \
369
- " mkdir -p '#{remote_dir}' 2>/dev/null &&" \
370
- " scp -rp #{REMOTES_LOCATION}/*" \
371
- " #{host['NAME']}:#{remote_dir} 2> /dev/null"
372
- else
373
- sync_cmd = "rsync -Laz --delete #{REMOTES_LOCATION}/" \
374
- " #{host['NAME']}:#{remote_dir}/"
375
- end
376
-
377
366
  retries = 3
378
367
 
379
368
  begin
380
- `#{sync_cmd} 2>/dev/null`
369
+ copy_method = options[:ssh] ? :ssh : :rsync
370
+ rc = sync_manager.update_remotes(host['NAME'],
371
+ nil,
372
+ copy_method)
381
373
  rescue IOError
382
374
  # Workaround for broken Ruby 2.5
383
375
  # https://github.com/OpenNebula/one/issues/3229
@@ -387,7 +379,7 @@ class OneHostHelper < OpenNebulaHelper::OneHelper
387
379
  end
388
380
  end
389
381
 
390
- if $CHILD_STATUS.nil? || !$CHILD_STATUS.success?
382
+ if rc != 0
391
383
  error_lock.synchronize do
392
384
  host_errors << host['NAME']
393
385
  end
@@ -468,10 +460,10 @@ class OneHostHelper < OpenNebulaHelper::OneHelper
468
460
  n_elems = options[:n_elems] || 8
469
461
 
470
462
  # Different available size units
471
- units = ['K', 'M', 'G', 'T']
463
+ units = %w[K M G T]
472
464
 
473
465
  # Attrs that need units conversion
474
- attrs = ['FREE_MEMORY', 'USED_MEMORY']
466
+ attrs = %w[FREE_MEMORY USED_MEMORY]
475
467
 
476
468
  if unit && !units.include?(unit)
477
469
  STDERR.puts "Invalid unit `#{unit}`"
@@ -692,14 +684,7 @@ class OneHostHelper < OpenNebulaHelper::OneHelper
692
684
  end
693
685
 
694
686
  if numa_nodes && !numa_nodes.empty?
695
- begin
696
- monitoring_numa =
697
- host.to_hash['HOST']['MONITORING']['NUMA_NODE']
698
- rescue StandardError
699
- monitoring_numa = nil
700
- end
701
-
702
- print_numa_nodes(numa_nodes, monitoring_numa)
687
+ print_numa_nodes(numa_nodes)
703
688
  end
704
689
 
705
690
  puts
@@ -784,36 +769,14 @@ class OneHostHelper < OpenNebulaHelper::OneHelper
784
769
  table.show(pcis)
785
770
  end
786
771
 
787
- def print_numa_nodes(numa_nodes, monitoring)
772
+ def print_numa_nodes(numa_nodes)
788
773
  numa_nodes = get_numa_data(numa_nodes)
789
774
 
790
- merge_numa_monitoring(numa_nodes, monitoring)
791
-
792
775
  print_numa_cores(numa_nodes)
793
776
  print_numa_memory(numa_nodes)
794
777
  print_numa_hugepages(numa_nodes)
795
778
  end
796
779
 
797
- def merge_numa_monitoring(numa_nodes, monitoring)
798
- return if monitoring.nil?
799
-
800
- monitoring = [monitoring] if monitoring.class == Hash
801
-
802
- numa_nodes.each do |node|
803
- mon_node = monitoring.find {|x| x['NODE_ID'] == node['NODE_ID'] }
804
-
805
- next if mon_node.nil?
806
-
807
- node['MEMORY']['FREE'] = mon_node['MEMORY']['FREE']
808
- node['MEMORY']['USED'] = mon_node['MEMORY']['USED']
809
-
810
- node['HUGEPAGE'].each do |hp|
811
- mon_hp = mon_node['HUGEPAGE'].find {|x| x['SIZE'] == hp['SIZE'] }
812
- hp['FREE'] = mon_hp['FREE']
813
- end
814
- end
815
- end
816
-
817
780
  def get_numa_data(numa_nodes)
818
781
  numa_nodes = [numa_nodes] if numa_nodes.class == Hash
819
782
 
@@ -923,11 +886,7 @@ class OneHostHelper < OpenNebulaHelper::OneHelper
923
886
  end
924
887
 
925
888
  column :USED_REAL, 'Used memory', :size => 20, :left => true do |d|
926
- if d['MEMORY']['USED'].nil?
927
- '-'
928
- else
929
- OpenNebulaHelper.unit_to_str(d['MEMORY']['USED'].to_i, {})
930
- end
889
+ OpenNebulaHelper.unit_to_str(d['MEMORY']['USED'].to_i, {})
931
890
  end
932
891
 
933
892
  column :USED_ALLOCATED, 'U memory',
@@ -936,11 +895,7 @@ class OneHostHelper < OpenNebulaHelper::OneHelper
936
895
  end
937
896
 
938
897
  column :FREE, 'Free memory', :size => 8, :left => true do |d|
939
- if d['MEMORY']['FREE'].nil?
940
- '-'
941
- else
942
- OpenNebulaHelper.unit_to_str(d['MEMORY']['FREE'].to_i, {})
943
- end
898
+ OpenNebulaHelper.unit_to_str(d['MEMORY']['FREE'].to_i, {})
944
899
  end
945
900
 
946
901
  default :NODE_ID, :TOTAL, :USED_REAL, :USED_ALLOCATED, :FREE
@@ -978,7 +933,7 @@ class OneHostHelper < OpenNebulaHelper::OneHelper
978
933
  end
979
934
 
980
935
  column :FREE, 'Free pages', :size => 8, :left => true do |d|
981
- d['HUGEPAGE']['FREE'] || '-'
936
+ d['HUGEPAGE']['FREE']
982
937
  end
983
938
 
984
939
  column :USED, 'allocated pages', :size => 8, :left => true do |d|
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -22,7 +22,7 @@ class OneImageHelper < OpenNebulaHelper::OneHelper
22
22
 
23
23
  # This list contains prefixes that should skip adding user home to the path
24
24
  # This must have the same content as the case $FROM in downloader.sh
25
- PREFIXES = ['http', 'https', 'ssh', 's3', 'rbd', 'vcenter', 'lxd', 'docker', 'dockerfile']
25
+ PREFIXES = %w[http https ssh s3 rbd vcenter lxd docker dockerfile]
26
26
 
27
27
  TEMPLATE_OPTIONS=[
28
28
  {
@@ -67,7 +67,7 @@ class OneImageHelper < OpenNebulaHelper::OneHelper
67
67
  :format => String,
68
68
  :proc => lambda do |o, _options|
69
69
  prefix=o.strip.downcase
70
- if ['hd', 'sd', 'xvd', 'vd'].include? prefix
70
+ if %w[hd sd xvd vd].include? prefix
71
71
  [0, prefix]
72
72
  else
73
73
  [-1, 'The prefix must be hd, sd, xvd or vd']
@@ -328,7 +328,7 @@ class OneImageHelper < OpenNebulaHelper::OneHelper
328
328
 
329
329
  CLIHelper.print_header(str_h1 % 'PERMISSIONS', false)
330
330
 
331
- ['OWNER', 'GROUP', 'OTHER'].each do |e|
331
+ %w[OWNER GROUP OTHER].each do |e|
332
332
  mask = '---'
333
333
  mask[0] = 'u' if image["PERMISSIONS/#{e}_U"] == '1'
334
334
  mask[1] = 'm' if image["PERMISSIONS/#{e}_M"] == '1'
@@ -348,18 +348,36 @@ class OneImageHelper < OpenNebulaHelper::OneHelper
348
348
  CLIHelper.print_header(str_h1 % 'IMAGE TEMPLATE', false)
349
349
  puts image.template_str
350
350
 
351
- puts
352
- CLIHelper.print_header('VIRTUAL MACHINES', false)
353
- puts
354
-
355
351
  vms=image.retrieve_elements('VMS/ID')
356
352
 
357
353
  return unless vms
358
354
 
359
- vms.map! {|e| e.to_i }
360
- onevm_helper=OneVMHelper.new
361
- onevm_helper.client=@client
362
- onevm_helper.list_pool({ :ids=>vms, :no_pager => true }, false)
355
+ if image.type_str.casecmp('backup').zero?
356
+ CLIHelper.print_header(str_h1 % 'BACKUP INFORMATION', false)
357
+ puts format(str, 'VM', vms[0])
358
+
359
+ if image.has_elements?('/IMAGE/BACKUP_INCREMENTS/INCREMENT')
360
+ puts format(str, 'TYPE', 'INCREMENTAL')
361
+
362
+ puts
363
+
364
+ CLIHelper.print_header('BACKUP INCREMENTS', false)
365
+ format_backup_increments(image)
366
+ else
367
+ puts format(str, 'TYPE', 'FULL')
368
+ end
369
+ else
370
+ puts
371
+ CLIHelper.print_header('VIRTUAL MACHINES', false)
372
+ puts
373
+
374
+ vms.map! {|e| e.to_i }
375
+ onevm_helper=OneVMHelper.new
376
+ onevm_helper.client=@client
377
+ onevm_helper.list_pool({ :ids=>vms, :no_pager => true },
378
+ false)
379
+
380
+ end
363
381
  end
364
382
 
365
383
  def format_snapshots(image)
@@ -412,6 +430,49 @@ class OneImageHelper < OpenNebulaHelper::OneHelper
412
430
  table.show(image_snapshots)
413
431
  end
414
432
 
433
+ def format_backup_increments(image)
434
+ table=CLIHelper::ShowTable.new(nil, self) do
435
+ column :ID, 'Increment ID', :size=>3 do |d|
436
+ d['ID']
437
+ end
438
+
439
+ column :PID, 'Parent increment ID', :size=>3 do |d|
440
+ d['PARENT_ID']
441
+ end
442
+
443
+ column :TYPE, 'T', :size=>1 do |d|
444
+ d['TYPE'][0]
445
+ end
446
+
447
+ column :SIZE, '', :left, :size=>8 do |d|
448
+ if d['SIZE']
449
+ OpenNebulaHelper.unit_to_str(
450
+ d['SIZE'].to_i,
451
+ {},
452
+ 'M'
453
+ )
454
+ else
455
+ '-'
456
+ end
457
+ end
458
+
459
+ column :DATE, 'Creation date', :size=>15 do |d|
460
+ OpenNebulaHelper.time_to_str(d['DATE'])
461
+ end
462
+
463
+ column :SOURCE, 'Backup source', :left, :size=>37 do |d|
464
+ d['SOURCE']
465
+ end
466
+
467
+ default :ID, :PID, :TYPE, :SIZE, :DATE, :SOURCE
468
+ end
469
+
470
+ ihash = image.to_hash
471
+ increments = [ihash['IMAGE']['BACKUP_INCREMENTS']['INCREMENT']].flatten
472
+
473
+ table.show(increments)
474
+ end
475
+
415
476
  class << self
416
477
 
417
478
  def create_image_variables(options, name)
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -60,7 +60,7 @@ class OneMarketPlaceAppHelper < OpenNebulaHelper::OneHelper
60
60
  }
61
61
 
62
62
  # Available market place mads to import apps on them
63
- MARKETS = ['http', 's3']
63
+ MARKETS = %w[http s3]
64
64
 
65
65
  def self.rname
66
66
  'MARKETPLACEAPP'
@@ -413,7 +413,7 @@ class OneMarketPlaceAppHelper < OpenNebulaHelper::OneHelper
413
413
 
414
414
  CLIHelper.print_header(str_h1 % 'PERMISSIONS', false)
415
415
 
416
- ['OWNER', 'GROUP', 'OTHER'].each do |e|
416
+ %w[OWNER GROUP OTHER].each do |e|
417
417
  mask = '---'
418
418
  mask[0] = 'u' if app["PERMISSIONS/#{e}_U"] == '1'
419
419
  mask[1] = 'm' if app["PERMISSIONS/#{e}_M"] == '1'
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -53,7 +53,6 @@ EOT
53
53
 
54
54
  RECURSIVE={
55
55
  :name => "recursive",
56
- :short => "-R",
57
56
  :large => "--recursive",
58
57
  :description => "Applies the action to the template plus any "+
59
58
  "image defined in DISK"
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -58,20 +58,20 @@ class OneVcenterHelper < OpenNebulaHelper::OneHelper
58
58
  #
59
59
  TABLE = {
60
60
  VOBJECT::DATASTORE => {
61
- :struct => ['DATASTORE_LIST', 'DATASTORE'],
61
+ :struct => %w[DATASTORE_LIST DATASTORE],
62
62
  :columns =>
63
63
  { :IMID => 5, :REF => 15, :NAME => 50, :CLUSTERS => 10 },
64
64
  :cli => [:host],
65
65
  :dialogue => ->(arg) {}
66
66
  },
67
67
  VOBJECT::TEMPLATE => {
68
- :struct => ['TEMPLATE_LIST', 'TEMPLATE'],
68
+ :struct => %w[TEMPLATE_LIST TEMPLATE],
69
69
  :columns => { :IMID => 5, :REF => 10, :NAME => 50 },
70
70
  :cli => [:host],
71
71
  :dialogue => ->(arg) { OneVcenterHelper.template_dialogue(arg) }
72
72
  },
73
73
  VOBJECT::NETWORK => {
74
- :struct => ['NETWORK_LIST', 'NETWORK'],
74
+ :struct => %w[NETWORK_LIST NETWORK],
75
75
  :columns => {
76
76
  :IMID => 5,
77
77
  :REF => 15,
@@ -82,13 +82,13 @@ class OneVcenterHelper < OpenNebulaHelper::OneHelper
82
82
  :dialogue => ->(arg) { OneVcenterHelper.network_dialogue(arg) }
83
83
  },
84
84
  VOBJECT::IMAGE => {
85
- :struct => ['IMAGE_LIST', 'IMAGE'],
85
+ :struct => %w[IMAGE_LIST IMAGE],
86
86
  :columns => { :IMID => 5, :REF => 35, :PATH => 60 },
87
87
  :cli => [:host, :datastore],
88
88
  :dialogue => ->(arg) {}
89
89
  },
90
90
  VOBJECT::HOST => {
91
- :struct => ['HOST_LIST', 'HOST'],
91
+ :struct => %w[HOST_LIST HOST],
92
92
  :columns => { :DATACENTER => 10, :NAME => 30, :REF => 35 },
93
93
  :cli => [],
94
94
  :dialogue => ->(arg) {}
@@ -471,7 +471,7 @@ class OneVcenterHelper < OpenNebulaHelper::OneHelper
471
471
  ' do you want to create (IPv[4],IPv[6], [E]thernet)? '
472
472
  type_answer = ask.call(question, 'ether')
473
473
 
474
- supported_types = ['4', '6', 'ether', 'e', 'ip4', 'ip6']
474
+ supported_types = %w[4 6 ether e ip4 ip6]
475
475
  if !supported_types.include?(type_answer)
476
476
  type_answer = 'e'
477
477
  STDOUT.puts " Type [#{type_answer}] not supported,"\
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -117,7 +117,21 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
117
117
  :large => '--schedule TIME',
118
118
  :description => 'Schedules this action to be executed after' \
119
119
  'the given time. For example: onevm resume 0 --schedule "09/23 14:15"',
120
- :format => Time
120
+ :format => String,
121
+ :proc => lambda {|o, options|
122
+ if o[0] == '+'
123
+ options[:schedule] = o
124
+ elsif o == 'now'
125
+ options[:schedule] = Time.now.to_i
126
+ else
127
+ begin
128
+ options[:schedule] = Time.parse(o).to_i
129
+ rescue StandardError
130
+ STDERR.puts "Error parsing time spec: #{o}"
131
+ exit(-1)
132
+ end
133
+ end
134
+ }
121
135
  }
122
136
 
123
137
  WEEKLY = {
@@ -408,10 +422,13 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
408
422
  # Verbose by default
409
423
  options[:verbose] = true
410
424
 
411
- perform_actions(
412
- ids, options,
413
- "#{action} scheduled at #{options[:schedule]}"
414
- ) do |vm|
425
+ message = if options[:schedule].class == Integer
426
+ "#{action} scheduled at #{Time.at(options[:schedule])}"
427
+ else
428
+ "#{action} scheduled after #{options[:schedule]}s from start"
429
+ end
430
+
431
+ perform_actions( ids, options, message) do |vm|
415
432
 
416
433
  str_periodic = ''
417
434
 
@@ -440,28 +457,14 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
440
457
  str_periodic << ', END_TYPE = 0'
441
458
  end
442
459
 
443
- sched = options[:schedule]
444
-
445
- # If the action is set to be executed from VM start to an specific
446
- # amount of time later, we should preserve the + symbol
447
- if ((sched.is_a? String) && !sched.include?('+')) ||
448
- !(sched.is_a? String)
449
- sched = sched.to_i
450
- end
451
-
452
460
  tmp_str = "SCHED_ACTION = ["
453
461
  tmp_str << "ACTION = #{action}, "
454
462
  tmp_str << "WARNING = #{warning}," if warning
455
463
  tmp_str << "ARGS = \"#{options[:args]}\"," if options[:args]
456
- tmp_str << "TIME = #{sched}"
464
+ tmp_str << "TIME = #{options[:schedule]}"
457
465
  tmp_str << str_periodic << ']'
458
466
 
459
- rc = vm.sched_action_add(tmp_str)
460
-
461
- if OpenNebula.is_error?(rc)
462
- STDERR.puts rc.message
463
- return -1
464
- end
467
+ vm.sched_action_add(tmp_str)
465
468
  end
466
469
  end
467
470
 
@@ -1347,42 +1350,31 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
1347
1350
  end
1348
1351
  str_end unless d.nil?
1349
1352
  end
1350
-
1351
- column :DONE, '', :adjust => true do |d|
1352
- OpenNebulaHelper.time_to_str(d['DONE'], false) \
1353
- unless d.nil?
1354
- end
1355
-
1356
- column :MESSAGE, '', :size => 35 do |d|
1357
- d['MESSAGE'] ? d['MESSAGE'] : '-'
1358
- end
1359
-
1360
- column :CHARTER, '', :left, :adjust, :size => 15 do |d|
1361
- t1 = Time.now
1362
- t2 = d['TIME'].to_i
1363
- t2 += vm['STIME'].to_i unless d['TIME'] =~ /^[0-9].*/
1364
-
1365
- t2 = Time.at(t2)
1366
-
1367
- days = ((t2 - t1) / (24 * 3600)).round(2)
1368
- hours = ((t2 - t1) / 3600).round(2)
1369
- minutes = ((t2 - t1) / 60).round(2)
1370
-
1371
- if days > 1
1372
- show = "In #{days} days"
1373
- elsif days <= 1 && hours > 1
1374
- show = "In #{hours} hours"
1375
- elsif minutes > 0
1376
- show = "In #{minutes} minutes"
1353
+ column :STATUS, '', :left, :size => 50 do |d|
1354
+ if d['DONE'] && !d['REPEAT']
1355
+ "Done on #{OpenNebulaHelper.time_to_str(d['DONE'], false)}"
1356
+ elsif d['MESSAGE']
1357
+ "Error! #{d['MESSAGE']}"
1377
1358
  else
1378
- show = 'Already done'
1379
- end
1380
-
1381
- wrn = d['WARNING']
1382
- if !wrn.nil? && (t1 - vm['STIME'].to_i).to_i > wrn.to_i
1383
- "#{show} *"
1384
- else
1385
- show
1359
+ t1 = Time.now
1360
+ t2 = d['TIME'].to_i
1361
+ t2 += vm['STIME'].to_i unless d['TIME'] =~ /^[0-9].*/
1362
+
1363
+ t2 = Time.at(t2)
1364
+
1365
+ days = ((t2 - t1) / (24 * 3600)).round(2)
1366
+ hours = ((t2 - t1) / 3600).round(2)
1367
+ minutes = ((t2 - t1) / 60).round(2)
1368
+
1369
+ if days > 1
1370
+ "Next in #{days} days"
1371
+ elsif days <= 1 && hours > 1
1372
+ "Next in #{hours} hours"
1373
+ elsif minutes > 0
1374
+ "Next in #{minutes} minutes"
1375
+ else
1376
+ "Overdue!"
1377
+ end
1386
1378
  end
1387
1379
  end
1388
1380
  end.show([vm_hash['VM']['TEMPLATE']['SCHED_ACTION']].flatten,
@@ -1393,6 +1385,8 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
1393
1385
  vm.delete_element('/VM/TEMPLATE/SCHED_ACTION')
1394
1386
  end
1395
1387
 
1388
+ print_backups(vm, vm_hash)
1389
+
1396
1390
  if vm.has_elements?('/VM/USER_TEMPLATE')
1397
1391
  puts
1398
1392
 
@@ -1426,6 +1420,23 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
1426
1420
  puts vm.template_str
1427
1421
  end
1428
1422
 
1423
+ def print_backups(vm, vm_hash)
1424
+ if vm.has_elements?('/VM/BACKUPS/BACKUP_CONFIG')
1425
+ puts
1426
+ CLIHelper.print_header('%-80s' % 'BACKUP CONFIGURATION', false)
1427
+ puts vm.template_like_str('BACKUPS/BACKUP_CONFIG')
1428
+ end
1429
+
1430
+ if vm.has_elements?('/VM/BACKUPS/BACKUP_IDS')
1431
+ puts
1432
+ CLIHelper.print_header('%-80s' % 'VM BACKUPS', false)
1433
+
1434
+ ids = [vm_hash['VM']['BACKUPS']['BACKUP_IDS']['ID']].flatten
1435
+
1436
+ puts format('IMAGE IDS: %s', ids.join(','))
1437
+ end
1438
+ end
1439
+
1429
1440
  def print_numa_nodes(numa_nodes)
1430
1441
  puts
1431
1442
  CLIHelper.print_header('NUMA NODES', false)