opennebula-cli 5.12.10 → 5.13.80.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/bin/oneacct +9 -4
  3. data/bin/oneacl +8 -5
  4. data/bin/onecluster +10 -7
  5. data/bin/onedatastore +10 -7
  6. data/bin/oneflow +85 -13
  7. data/bin/oneflow-template +45 -8
  8. data/bin/onegroup +10 -7
  9. data/bin/onehook +10 -7
  10. data/bin/onehost +8 -5
  11. data/bin/oneimage +99 -8
  12. data/bin/onemarket +10 -7
  13. data/bin/onemarketapp +117 -10
  14. data/bin/onesecgroup +13 -7
  15. data/bin/oneshowback +18 -10
  16. data/bin/onetemplate +12 -8
  17. data/bin/oneuser +30 -7
  18. data/bin/onevcenter +10 -18
  19. data/bin/onevdc +10 -7
  20. data/bin/onevm +146 -11
  21. data/bin/onevmgroup +13 -7
  22. data/bin/onevnet +8 -5
  23. data/bin/onevntemplate +11 -7
  24. data/bin/onevrouter +10 -7
  25. data/bin/onezone +10 -7
  26. data/lib/cli_helper.rb +4 -6
  27. data/lib/command_parser.rb +1 -1
  28. data/lib/one_helper/oneacct_helper.rb +8 -17
  29. data/lib/one_helper/oneacl_helper.rb +1 -1
  30. data/lib/one_helper/onecluster_helper.rb +1 -1
  31. data/lib/one_helper/onedatastore_helper.rb +11 -1
  32. data/lib/one_helper/oneflow_helper.rb +20 -5
  33. data/lib/one_helper/oneflowtemplate_helper.rb +28 -2
  34. data/lib/one_helper/onegroup_helper.rb +1 -1
  35. data/lib/one_helper/onehook_helper.rb +1 -1
  36. data/lib/one_helper/onehost_helper.rb +1 -5
  37. data/lib/one_helper/oneimage_helper.rb +7 -7
  38. data/lib/one_helper/onemarket_helper.rb +1 -1
  39. data/lib/one_helper/onemarketapp_helper.rb +494 -96
  40. data/lib/one_helper/onequota_helper.rb +1 -1
  41. data/lib/one_helper/onesecgroup_helper.rb +1 -1
  42. data/lib/one_helper/onetemplate_helper.rb +12 -1
  43. data/lib/one_helper/oneuser_helper.rb +11 -3
  44. data/lib/one_helper/onevcenter_helper.rb +176 -146
  45. data/lib/one_helper/onevdc_helper.rb +1 -1
  46. data/lib/one_helper/onevm_helper.rb +4 -3
  47. data/lib/one_helper/onevmgroup_helper.rb +1 -1
  48. data/lib/one_helper/onevnet_helper.rb +1 -1
  49. data/lib/one_helper/onevntemplate_helper.rb +1 -1
  50. data/lib/one_helper/onevrouter_helper.rb +1 -20
  51. data/lib/one_helper/onezone_helper.rb +12 -1
  52. data/lib/one_helper.rb +398 -37
  53. data/share/schemas/xsd/acct.xsd +179 -0
  54. data/share/schemas/xsd/acl_pool.xsd +22 -0
  55. data/share/schemas/xsd/api_info.xsd +43 -0
  56. data/share/schemas/xsd/cluster.xsd +34 -0
  57. data/share/schemas/xsd/cluster_pool.xsd +12 -0
  58. data/share/schemas/xsd/datastore.xsd +67 -0
  59. data/share/schemas/xsd/datastore_pool.xsd +12 -0
  60. data/share/schemas/xsd/document.xsd +42 -0
  61. data/share/schemas/xsd/document_pool.xsd +12 -0
  62. data/share/schemas/xsd/group.xsd +179 -0
  63. data/share/schemas/xsd/group_pool.xsd +194 -0
  64. data/share/schemas/xsd/hook.xsd +59 -0
  65. data/share/schemas/xsd/hook_message_api.xsd +14 -0
  66. data/share/schemas/xsd/hook_message_retry.xsd +12 -0
  67. data/share/schemas/xsd/hook_message_state.xsd +25 -0
  68. data/share/schemas/xsd/hook_pool.xsd +12 -0
  69. data/share/schemas/xsd/host.xsd +164 -0
  70. data/share/schemas/xsd/host_pool.xsd +12 -0
  71. data/share/schemas/xsd/image.xsd +123 -0
  72. data/share/schemas/xsd/image_pool.xsd +12 -0
  73. data/share/schemas/xsd/index.xsd +49 -0
  74. data/share/schemas/xsd/marketplace.xsd +44 -0
  75. data/share/schemas/xsd/marketplace_pool.xsd +12 -0
  76. data/share/schemas/xsd/marketplaceapp.xsd +56 -0
  77. data/share/schemas/xsd/marketplaceapp_pool.xsd +12 -0
  78. data/share/schemas/xsd/opennebula_configuration.xsd +412 -0
  79. data/share/schemas/xsd/raftstatus.xsd +18 -0
  80. data/share/schemas/xsd/security_group.xsd +74 -0
  81. data/share/schemas/xsd/security_group_pool.xsd +12 -0
  82. data/share/schemas/xsd/showback.xsd +29 -0
  83. data/share/schemas/xsd/user.xsd +186 -0
  84. data/share/schemas/xsd/user_pool.xsd +201 -0
  85. data/share/schemas/xsd/vdc.xsd +76 -0
  86. data/share/schemas/xsd/vdc_pool.xsd +12 -0
  87. data/share/schemas/xsd/vm.xsd +251 -0
  88. data/share/schemas/xsd/vm_group.xsd +59 -0
  89. data/share/schemas/xsd/vm_group_pool.xsd +12 -0
  90. data/share/schemas/xsd/vm_pool.xsd +114 -0
  91. data/share/schemas/xsd/vmtemplate.xsd +52 -0
  92. data/share/schemas/xsd/vmtemplate_pool.xsd +12 -0
  93. data/share/schemas/xsd/vnet.xsd +137 -0
  94. data/share/schemas/xsd/vnet_pool.xsd +85 -0
  95. data/share/schemas/xsd/vntemplate.xsd +50 -0
  96. data/share/schemas/xsd/vntemplate_pool.xsd +12 -0
  97. data/share/schemas/xsd/vrouter.xsd +49 -0
  98. data/share/schemas/xsd/vrouter_pool.xsd +12 -0
  99. data/share/schemas/xsd/zone.xsd +40 -0
  100. data/share/schemas/xsd/zone_pool.xsd +36 -0
  101. metadata +68 -7
  102. data/lib/one_helper/oneprovision_helper.rb +0 -362
data/bin/onevcenter CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
4
+ # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
5
5
  # #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
7
7
  # not use this file except in compliance with the License. You may obtain #
@@ -29,9 +29,12 @@ else
29
29
  end
30
30
 
31
31
  if File.directory?(GEMS_LOCATION)
32
- $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
33
- require 'rubygems'
34
- Gem.use_paths(File.realpath(GEMS_LOCATION))
32
+ real_gems_path = File.realpath(GEMS_LOCATION)
33
+ if !defined?(Gem) || Gem.path != [real_gems_path]
34
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
35
+ require 'rubygems'
36
+ Gem.use_paths(real_gems_path)
37
+ end
35
38
  end
36
39
 
37
40
  $LOAD_PATH << RUBY_LIB_LOCATION
@@ -257,21 +260,10 @@ CommandParser::CmdParser.new(ARGV) do
257
260
  importer = VCenterDriver::VcImporter.new_child(helper.client,
258
261
  vi_client,
259
262
  options[:object])
263
+ importer.retrieve_resources(helper.parse_opts(options))
264
+ indexes = importer.get_indexes(args.first)
260
265
 
261
- if options[:object] == "networks" && !args.first.nil?
262
- indexes = args.first
263
- else
264
- importer.retrieve_resources(helper.parse_opts(options))
265
- indexes = importer.get_indexes(args.first)
266
- end
267
-
268
- if indexes.nil?
269
- raise "Could not get any unimported #{options[:object]}"\
270
- " resources info in host: #{options[:host]} with"\
271
- " this input: #{args.first}"
272
- end
273
-
274
- importer.process_import(indexes, options)
266
+ importer.process_import(indexes)
275
267
 
276
268
  importer.stdout
277
269
  rescue StandardError => e
data/bin/onevdc CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
4
+ # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
5
5
  # #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
7
7
  # not use this file except in compliance with the License. You may obtain #
@@ -27,9 +27,12 @@ else
27
27
  end
28
28
 
29
29
  if File.directory?(GEMS_LOCATION)
30
- $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
31
- require 'rubygems'
32
- Gem.use_paths(File.realpath(GEMS_LOCATION))
30
+ real_gems_path = File.realpath(GEMS_LOCATION)
31
+ if !defined?(Gem) || Gem.path != [real_gems_path]
32
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
33
+ require 'rubygems'
34
+ Gem.use_paths(real_gems_path)
35
+ end
33
36
  end
34
37
 
35
38
  $LOAD_PATH << RUBY_LIB_LOCATION
@@ -53,8 +56,8 @@ CommandParser::CmdParser.new(ARGV) do
53
56
  ########################################################################
54
57
  set :option, CommandParser::OPTIONS + OpenNebulaHelper::CLIENT_OPTIONS
55
58
 
56
- list_options = CLIHelper::OPTIONS
57
- list_options << OpenNebulaHelper::XML
59
+ list_options = CLIHelper::OPTIONS
60
+ list_options += OpenNebulaHelper::FORMAT
58
61
  list_options << OpenNebulaHelper::NUMERIC
59
62
  list_options << OpenNebulaHelper::DESCRIBE
60
63
 
@@ -297,7 +300,7 @@ CommandParser::CmdParser.new(ARGV) do
297
300
  Shows information for the given VDC
298
301
  EOT
299
302
 
300
- command :show, show_desc, :vdcid, :options => OpenNebulaHelper::XML do
303
+ command :show, show_desc, :vdcid, :options => OpenNebulaHelper::FORMAT do
301
304
  helper.show_resource(args[0], options)
302
305
  end
303
306
  end
data/bin/onevm CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
4
+ # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
5
5
  # #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
7
7
  # not use this file except in compliance with the License. You may obtain #
@@ -27,9 +27,12 @@ else
27
27
  end
28
28
 
29
29
  if File.directory?(GEMS_LOCATION)
30
- $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
31
- require 'rubygems'
32
- Gem.use_paths(File.realpath(GEMS_LOCATION))
30
+ real_gems_path = File.realpath(GEMS_LOCATION)
31
+ if !defined?(Gem) || Gem.path != [real_gems_path]
32
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
33
+ require 'rubygems'
34
+ Gem.use_paths(real_gems_path)
35
+ end
33
36
  end
34
37
 
35
38
  $LOAD_PATH << RUBY_LIB_LOCATION
@@ -37,6 +40,8 @@ $LOAD_PATH << RUBY_LIB_LOCATION + '/cli'
37
40
 
38
41
  require 'command_parser'
39
42
  require 'one_helper/onevm_helper'
43
+ require 'one_helper/onedatastore_helper'
44
+ require 'opennebula/virtual_machine_ext'
40
45
 
41
46
  CommandParser::CmdParser.new(ARGV) do
42
47
  usage '`onevm` <command> [<args>] [<options>]'
@@ -176,6 +181,32 @@ CommandParser::CmdParser.new(ARGV) do
176
181
  :description => 'lock all actions'
177
182
  }
178
183
 
184
+ LOGGER = {
185
+ :name => 'logger',
186
+ :large => '--logger logger',
187
+ :format => String,
188
+ :description => 'Set logger to STDOUT or FILE'
189
+ }
190
+
191
+ KEEP = {
192
+ :name => 'keep',
193
+ :large => '--keep-backup',
194
+ :description => 'Keep previous backup when creating a new one'
195
+ }
196
+
197
+ ONESHOT = {
198
+ :name => 'oneshot',
199
+ :large => '--oneshot',
200
+ :description => 'Take an snapshot of the VM without saving backup info'
201
+ }
202
+
203
+ MARKET = {
204
+ :name => 'market',
205
+ :large => '--market market_id',
206
+ :format => Integer,
207
+ :description => 'Market to save oneshot'
208
+ }
209
+
179
210
  ########################################################################
180
211
  # Global Options
181
212
  ########################################################################
@@ -1152,7 +1183,7 @@ CommandParser::CmdParser.new(ARGV) do
1152
1183
  EOT
1153
1184
 
1154
1185
  command :show, show_desc, :vmid,
1155
- :options => [OpenNebulaHelper::XML,
1186
+ :options => [OpenNebulaHelper::FORMAT,
1156
1187
  OpenNebulaHelper::DECRYPT,
1157
1188
  OneVMHelper::ALL_TEMPLATE] do
1158
1189
  helper.show_resource(args[0], options)
@@ -1210,7 +1241,11 @@ CommandParser::CmdParser.new(ARGV) do
1210
1241
 
1211
1242
  command :save, save_desc, :vmid, :name, :options => [PERSISTENT] do
1212
1243
  helper.perform_action(args[0], options, 'Saving VM') do |vm|
1213
- res = vm.save_as_template(args[1], options[:persistent])
1244
+ vm.extend(VirtualMachineExt)
1245
+
1246
+ res = vm.save_as_template(args[1],
1247
+ '',
1248
+ :persistent => options[:persistent])
1214
1249
 
1215
1250
  if !OpenNebula.is_error?(res)
1216
1251
  puts "Template ID: #{res}"
@@ -1221,15 +1256,16 @@ CommandParser::CmdParser.new(ARGV) do
1221
1256
  end
1222
1257
 
1223
1258
  updateconf_desc = <<-EOT.unindent
1224
- Updates the configuration of a VM. The VM cannot be in an active (running)
1225
- state, valid states are: pending, failure, poweroff, undeploy, hold or
1226
- cloning.
1259
+ Updates the configuration of a VM. Valid states are: running, pending,
1260
+ failure, poweroff, undeploy, hold or cloning.
1261
+ In running state only changes in CONTEXT take effect immediately,
1262
+ other values may need a VM restart.
1227
1263
 
1228
1264
  This command accepts a template file or opens an editor, the full list of
1229
1265
  configuration attributes are:
1230
1266
 
1231
- OS = ["ARCH", "MACHINE", "KERNEL", "INITRD", "BOOTLOADER", "BOOT"]
1232
- FEATURES = ["ACPI", "PAE", "APIC", "LOCALTIME", "HYPERV", "GUEST_AGENT"]
1267
+ OS = ["ARCH", "MACHINE", "KERNEL", "INITRD", "BOOTLOADER", "BOOT", "UUID"]
1268
+ FEATURES = ["ACPI", "PAE", "APIC", "LOCALTIME", "HYPERV", "GUEST_AGENT", "IOTHREADS"]
1233
1269
  INPUT = ["TYPE", "BUS"]
1234
1270
  GRAPHICS = ["TYPE", "LISTEN", "PASSWD", "KEYMAP" ]
1235
1271
  RAW = ["DATA", "DATA_VMX", "TYPE"]
@@ -1383,6 +1419,105 @@ CommandParser::CmdParser.new(ARGV) do
1383
1419
  0
1384
1420
  end
1385
1421
 
1422
+ backup_vm_desc = <<-EOT.unindent
1423
+ Creates a VM backup and stores it in the marketplace
1424
+ EOT
1425
+
1426
+ command :backup,
1427
+ backup_vm_desc,
1428
+ :vmid,
1429
+ :options => [LOGGER, KEEP, ONESHOT, MARKET] do
1430
+ require 'logger'
1431
+
1432
+ if options.key?(:oneshot) && !options.key?(:market)
1433
+ STDERR.puts 'ERROR: no market given'
1434
+ exit(-1)
1435
+ end
1436
+
1437
+ helper.perform_action(args[0], options, 'Backup') do |vm|
1438
+ vm.extend(OpenNebula::VirtualMachineExt)
1439
+
1440
+ # If logger is specified use it, if not use STDOUT
1441
+ options[:logger].nil? ? log_to = STDOUT : log_to = options[:logger]
1442
+
1443
+ # Read user options
1444
+ keep = options.key?(:keep)
1445
+ logger = Logger.new(log_to)
1446
+ format = '%Y-%m-%d %H:%M:%S'
1447
+
1448
+ logger.formatter = proc do |severity, datetime, _p, msg|
1449
+ "#{datetime.strftime(format)} #{severity.ljust(5)} : #{msg}\n"
1450
+ end
1451
+
1452
+ if options.key?(:oneshot)
1453
+ binfo = {}
1454
+ binfo[:name] = "VM #{vm.id} BACKUP - " \
1455
+ "#{Time.now.strftime('%Y%m%d_%k%M')}"
1456
+ binfo[:freq] = 1
1457
+ binfo[:last] = Time.now.to_i - 100
1458
+ binfo[:market] = options[:market]
1459
+ end
1460
+
1461
+ begin
1462
+ rc = vm.backup(keep, logger, binfo)
1463
+
1464
+ if OpenNebula.is_error?(rc)
1465
+ STDERR.puts rc.message
1466
+ exit(-1)
1467
+ else
1468
+ 0
1469
+ end
1470
+ rescue StandardError => e
1471
+ STDERR.puts e
1472
+ exit(-1)
1473
+ end
1474
+ end
1475
+ end
1476
+
1477
+ restore_vm_desc = <<-EOT.unindent
1478
+ Restores a VM from a previous backup
1479
+ EOT
1480
+
1481
+ command :restore,
1482
+ restore_vm_desc,
1483
+ :vmid,
1484
+ :options => [OneDatastoreHelper::DATASTORE, LOGGER] do
1485
+ require 'logger'
1486
+
1487
+ unless options[:datastore]
1488
+ STDERR.puts 'ERROR: no datastore given'
1489
+ exit(-1)
1490
+ end
1491
+
1492
+ helper.perform_action(args[0], options, 'Restore') do |vm|
1493
+ vm.extend(OpenNebula::VirtualMachineExt)
1494
+
1495
+ # If logger is specified use it, if not use STDOUT
1496
+ options[:logger].nil? ? log_to = STDOUT : log_to = options[:logger]
1497
+ logger = Logger.new(log_to)
1498
+ format = '%Y-%m-%d %H:%M:%S'
1499
+
1500
+ logger.formatter = proc do |severity, datetime, _p, msg|
1501
+ "#{datetime.strftime(format)} #{severity.ljust(5)} : #{msg}\n"
1502
+ end
1503
+
1504
+ begin
1505
+ rc = vm.restore(options[:datastore], logger)
1506
+
1507
+ if OpenNebula.is_error?(rc)
1508
+ STDERR.puts rc.message
1509
+ exit(-1)
1510
+ else
1511
+ puts "ID: #{rc}"
1512
+ 0
1513
+ end
1514
+ rescue StandardError => e
1515
+ STDERR.puts e
1516
+ exit(-1)
1517
+ end
1518
+ end
1519
+ end
1520
+
1386
1521
  # Deprecated commands
1387
1522
 
1388
1523
  deprecated_command(:shutdown, 'terminate')
data/bin/onevmgroup CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
4
+ # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
5
5
  # #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
7
7
  # not use this file except in compliance with the License. You may obtain #
@@ -27,9 +27,12 @@ else
27
27
  end
28
28
 
29
29
  if File.directory?(GEMS_LOCATION)
30
- $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
31
- require 'rubygems'
32
- Gem.use_paths(File.realpath(GEMS_LOCATION))
30
+ real_gems_path = File.realpath(GEMS_LOCATION)
31
+ if !defined?(Gem) || Gem.path != [real_gems_path]
32
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
33
+ require 'rubygems'
34
+ Gem.use_paths(real_gems_path)
35
+ end
33
36
  end
34
37
 
35
38
  $LOAD_PATH << RUBY_LIB_LOCATION
@@ -77,8 +80,8 @@ CommandParser::CmdParser.new(ARGV) do
77
80
  ########################################################################
78
81
  set :option, CommandParser::OPTIONS + OpenNebulaHelper::CLIENT_OPTIONS
79
82
 
80
- list_options = CLIHelper::OPTIONS
81
- list_options << OpenNebulaHelper::XML
83
+ list_options = CLIHelper::OPTIONS
84
+ list_options += OpenNebulaHelper::FORMAT
82
85
  list_options << OpenNebulaHelper::NUMERIC
83
86
  list_options << OpenNebulaHelper::DESCRIBE
84
87
 
@@ -148,7 +151,10 @@ CommandParser::CmdParser.new(ARGV) do
148
151
  Shows information for the given VM Group
149
152
  EOT
150
153
 
151
- command :show, show_desc, :vmgroupid, :options => OpenNebulaHelper::XML do
154
+ command :show,
155
+ show_desc,
156
+ :vmgroupid,
157
+ :options => OpenNebulaHelper::FORMAT do
152
158
  helper.show_resource(args[0], options)
153
159
  end
154
160
 
data/bin/onevnet CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
4
+ # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
5
5
  # #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
7
7
  # not use this file except in compliance with the License. You may obtain #
@@ -27,9 +27,12 @@ else
27
27
  end
28
28
 
29
29
  if File.directory?(GEMS_LOCATION)
30
- $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
31
- require 'rubygems'
32
- Gem.use_paths(File.realpath(GEMS_LOCATION))
30
+ real_gems_path = File.realpath(GEMS_LOCATION)
31
+ if !defined?(Gem) || Gem.path != [real_gems_path]
32
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
33
+ require 'rubygems'
34
+ Gem.use_paths(real_gems_path)
35
+ end
33
36
  end
34
37
 
35
38
  $LOAD_PATH << RUBY_LIB_LOCATION
@@ -320,7 +323,7 @@ CommandParser::CmdParser.new(ARGV) do
320
323
  EOT
321
324
 
322
325
  command :show, show_desc, :vnetid,
323
- :options => [OpenNebulaHelper::XML,
326
+ :options => [OpenNebulaHelper::FORMAT,
324
327
  OpenNebulaHelper::DECRYPT,
325
328
  OneVNetHelper::SHOW_AR] do
326
329
  helper.show_resource(args[0], options)
data/bin/onevntemplate CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
4
+ # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
5
5
  # #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
7
7
  # not use this file except in compliance with the License. You may obtain #
@@ -27,9 +27,12 @@ else
27
27
  end
28
28
 
29
29
  if File.directory?(GEMS_LOCATION)
30
- $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
31
- require 'rubygems'
32
- Gem.use_paths(File.realpath(GEMS_LOCATION))
30
+ real_gems_path = File.realpath(GEMS_LOCATION)
31
+ if !defined?(Gem) || Gem.path != [real_gems_path]
32
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
33
+ require 'rubygems'
34
+ Gem.use_paths(real_gems_path)
35
+ end
33
36
  end
34
37
 
35
38
  $LOAD_PATH << RUBY_LIB_LOCATION
@@ -78,8 +81,8 @@ CommandParser::CmdParser.new(ARGV) do
78
81
  ########################################################################
79
82
  set :option, CommandParser::OPTIONS + OpenNebulaHelper::CLIENT_OPTIONS
80
83
 
81
- list_options = CLIHelper::OPTIONS
82
- list_options << OpenNebulaHelper::XML
84
+ list_options = CLIHelper::OPTIONS
85
+ list_options += OpenNebulaHelper::FORMAT
83
86
  list_options << OpenNebulaHelper::NUMERIC
84
87
  list_options << OpenNebulaHelper::DESCRIBE
85
88
 
@@ -313,7 +316,8 @@ CommandParser::CmdParser.new(ARGV) do
313
316
  EOT
314
317
 
315
318
  command :show, show_desc, :templateid,
316
- :options => [OpenNebulaHelper::XML, OneTemplateHelper::EXTENDED] do
319
+ :options => [OpenNebulaHelper::FORMAT,
320
+ OneTemplateHelper::EXTENDED] do
317
321
  helper.show_resource(args[0], options)
318
322
  end
319
323
 
data/bin/onevrouter CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
4
+ # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
5
5
  # #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
7
7
  # not use this file except in compliance with the License. You may obtain #
@@ -27,9 +27,12 @@ else
27
27
  end
28
28
 
29
29
  if File.directory?(GEMS_LOCATION)
30
- $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
31
- require 'rubygems'
32
- Gem.use_paths(File.realpath(GEMS_LOCATION))
30
+ real_gems_path = File.realpath(GEMS_LOCATION)
31
+ if !defined?(Gem) || Gem.path != [real_gems_path]
32
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
33
+ require 'rubygems'
34
+ Gem.use_paths(real_gems_path)
35
+ end
33
36
  end
34
37
 
35
38
  $LOAD_PATH << RUBY_LIB_LOCATION
@@ -79,8 +82,8 @@ CommandParser::CmdParser.new(ARGV) do
79
82
  ########################################################################
80
83
  set :option, CommandParser::OPTIONS + OpenNebulaHelper::CLIENT_OPTIONS
81
84
 
82
- list_options = CLIHelper::OPTIONS
83
- list_options << OpenNebulaHelper::XML
85
+ list_options = CLIHelper::OPTIONS
86
+ list_options += OpenNebulaHelper::FORMAT
84
87
  list_options << OpenNebulaHelper::NUMERIC
85
88
  list_options << OpenNebulaHelper::DESCRIBE
86
89
 
@@ -339,7 +342,7 @@ CommandParser::CmdParser.new(ARGV) do
339
342
  EOT
340
343
 
341
344
  command :show, show_desc, :vrouterid,
342
- :options => [OpenNebulaHelper::XML, OneVMHelper::ALL_TEMPLATE] do
345
+ :options => [OpenNebulaHelper::FORMAT, OneVMHelper::ALL_TEMPLATE] do
343
346
  helper.show_resource(args[0], options)
344
347
  end
345
348
 
data/bin/onezone CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
4
+ # Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
5
5
  # #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
7
7
  # not use this file except in compliance with the License. You may obtain #
@@ -27,9 +27,12 @@ else
27
27
  end
28
28
 
29
29
  if File.directory?(GEMS_LOCATION)
30
- $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
31
- require 'rubygems'
32
- Gem.use_paths(File.realpath(GEMS_LOCATION))
30
+ real_gems_path = File.realpath(GEMS_LOCATION)
31
+ if !defined?(Gem) || Gem.path != [real_gems_path]
32
+ $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
33
+ require 'rubygems'
34
+ Gem.use_paths(real_gems_path)
35
+ end
33
36
  end
34
37
 
35
38
  $LOAD_PATH << RUBY_LIB_LOCATION
@@ -68,8 +71,8 @@ CommandParser::CmdParser.new(ARGV) do
68
71
  ########################################################################
69
72
  set :option, CommandParser::OPTIONS + OpenNebulaHelper::CLIENT_OPTIONS
70
73
 
71
- list_options = CLIHelper::OPTIONS
72
- list_options << OpenNebulaHelper::XML
74
+ list_options = CLIHelper::OPTIONS
75
+ list_options += OpenNebulaHelper::FORMAT
73
76
  list_options << OpenNebulaHelper::NUMERIC
74
77
  list_options << OpenNebulaHelper::DESCRIBE
75
78
 
@@ -208,7 +211,7 @@ CommandParser::CmdParser.new(ARGV) do
208
211
  Shows information for the given Zone
209
212
  EOT
210
213
 
211
- command :show, show_desc, :zoneid, :options => OpenNebulaHelper::XML do
214
+ command :show, show_desc, :zoneid, :options => OpenNebulaHelper::FORMAT do
212
215
  helper.show_resource(args[0], options)
213
216
  end
214
217
 
data/lib/cli_helper.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2021, 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 #
@@ -181,7 +181,7 @@ module CLIHelper
181
181
  ANSI_YELLOW = "\33[33m"
182
182
 
183
183
  # CLI states
184
- OK_STATES = %w[runn rdy on configured SUCCESS RUNNING]
184
+ OK_STATES = %w[runn rdy on SUCCESS RUNNING]
185
185
  BAD_STATES = %w[fail
186
186
  err
187
187
  error
@@ -189,7 +189,7 @@ module CLIHelper
189
189
  FAILED_DEPLOYING
190
190
  FAILED_UNDEPLOYING
191
191
  FAILED_SCALING]
192
- REGULAR_STATES = %w[pending WARNING]
192
+ REGULAR_STATES = %w[PENDING DEPLOYING CONFIGURING WARNING]
193
193
 
194
194
  # Set state color
195
195
  #
@@ -599,9 +599,7 @@ module CLIHelper
599
599
  end
600
600
  end
601
601
 
602
- if options
603
- filter_data!(res_data, options) if options[:filter]
604
- end
602
+ filter_data!(res_data, options) if options && options[:filter]
605
603
 
606
604
  res_data
607
605
  end
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2021, 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-2020, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2021, 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 #
@@ -91,28 +91,19 @@ class AcctHelper < OpenNebulaHelper::OneHelper
91
91
  :format => String
92
92
  }
93
93
 
94
- XML = {
95
- :name => "xml",
96
- :short => "-x",
97
- :large => "--xml",
98
- :description => "Show the resource in xml format"
99
- }
100
-
101
- JSON = {
102
- :name => "json",
103
- :short => "-j",
104
- :large => "--json",
105
- :description => "Show the resource in json format"
106
- }
107
-
108
94
  SPLIT={
109
95
  :name => "split",
110
96
  :large => "--split",
111
97
  :description => "Split the output in a table for each VM"
112
98
  }
113
99
 
114
- ACCT_OPTIONS = [START_TIME_ACCT, END_TIME_ACCT, USERFILTER, GROUP, HOST, XPATH, XML, JSON, SPLIT]
115
- SHOWBACK_OPTIONS = [START_TIME_SHOWBACK, END_TIME_SHOWBACK, USERFILTER, GROUP, XML, JSON]
100
+ ACCT_OPTIONS = [START_TIME_ACCT, END_TIME_ACCT, USERFILTER, GROUP, HOST, XPATH, SPLIT]
101
+ SHOWBACK_OPTIONS = [START_TIME_SHOWBACK, END_TIME_SHOWBACK, USERFILTER, GROUP]
102
+
103
+ ACCT_OPTIONS << OpenNebulaHelper::XML
104
+ ACCT_OPTIONS << OpenNebulaHelper::JSON
105
+
106
+ SHOWBACK_OPTIONS += OpenNebulaHelper::FORMAT
116
107
 
117
108
  ACCT_TABLE = CLIHelper::ShowTable.new(self.table_conf("oneacct.yaml"), nil) do
118
109
  column :UID, "User ID", :size=>4 do |d|
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2021, 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-2020, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2021, 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-2020, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2021, 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 #
@@ -28,6 +28,16 @@ class OneDatastoreHelper < OpenNebulaHelper::OneHelper
28
28
  }
29
29
  }
30
30
 
31
+ FILE_DATASTORE = {
32
+ :name => "file_datastore",
33
+ :large => "--file-datastore id|name" ,
34
+ :description => "Selects the file datastore",
35
+ :format => String,
36
+ :proc => lambda { |o, options|
37
+ OpenNebulaHelper.rname_to_id(o, "DATASTORE")
38
+ }
39
+ }
40
+
31
41
  def self.rname
32
42
  "DATASTORE"
33
43
  end