opennebula-cli 5.12.13 → 5.13.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 (102) hide show
  1. checksums.yaml +5 -5
  2. data/bin/oneacct +5 -14
  3. data/bin/oneacl +4 -15
  4. data/bin/onecluster +6 -17
  5. data/bin/onedatastore +6 -17
  6. data/bin/oneflow +81 -23
  7. data/bin/oneflow-template +51 -27
  8. data/bin/onegroup +6 -17
  9. data/bin/onehook +6 -17
  10. data/bin/onehost +4 -15
  11. data/bin/oneimage +95 -18
  12. data/bin/onemarket +6 -17
  13. data/bin/onemarketapp +113 -20
  14. data/bin/onesecgroup +9 -17
  15. data/bin/oneshowback +14 -20
  16. data/bin/onetemplate +8 -18
  17. data/bin/oneuser +26 -17
  18. data/bin/onevcenter +6 -28
  19. data/bin/onevdc +6 -17
  20. data/bin/onevm +142 -21
  21. data/bin/onevmgroup +9 -17
  22. data/bin/onevnet +4 -15
  23. data/bin/onevntemplate +7 -17
  24. data/bin/onevrouter +6 -17
  25. data/bin/onezone +6 -17
  26. data/lib/cli_helper.rb +7 -10
  27. data/lib/command_parser.rb +1 -1
  28. data/lib/one_helper/oneacct_helper.rb +9 -22
  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 +9 -9
  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 +92 -30
  102. data/lib/one_helper/oneprovision_helper.rb +0 -362
data/bin/onehost CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2023, 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 #
@@ -28,25 +28,14 @@ else
28
28
  REMOTES_LOCATION = ONE_LOCATION + '/var/remotes/'
29
29
  end
30
30
 
31
- # %%RUBYGEMS_SETUP_BEGIN%%
32
31
  if File.directory?(GEMS_LOCATION)
33
32
  real_gems_path = File.realpath(GEMS_LOCATION)
34
33
  if !defined?(Gem) || Gem.path != [real_gems_path]
35
34
  $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
36
-
37
- # Suppress warnings from Rubygems
38
- # https://github.com/OpenNebula/one/issues/5379
39
- begin
40
- verb = $VERBOSE
41
- $VERBOSE = nil
42
- require 'rubygems'
43
- Gem.use_paths(real_gems_path)
44
- ensure
45
- $VERBOSE = verb
46
- end
35
+ require 'rubygems'
36
+ Gem.use_paths(real_gems_path)
47
37
  end
48
38
  end
49
- # %%RUBYGEMS_SETUP_END%%
50
39
 
51
40
  $LOAD_PATH << RUBY_LIB_LOCATION
52
41
  $LOAD_PATH << RUBY_LIB_LOCATION + '/cli'
@@ -297,7 +286,7 @@ CommandParser::CmdParser.new(ARGV) do
297
286
  EOT
298
287
 
299
288
  command :show, show_desc, :hostid,
300
- :options => [OpenNebulaHelper::XML, OpenNebulaHelper::DECRYPT] do
289
+ :options => [OpenNebulaHelper::FORMAT, OpenNebulaHelper::DECRYPT] do
301
290
  helper.show_resource(args[0], options)
302
291
  end
303
292
 
data/bin/oneimage CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2023, 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 #
@@ -26,29 +26,19 @@ else
26
26
  GEMS_LOCATION = ONE_LOCATION + '/share/gems'
27
27
  end
28
28
 
29
- # %%RUBYGEMS_SETUP_BEGIN%%
30
29
  if File.directory?(GEMS_LOCATION)
31
30
  real_gems_path = File.realpath(GEMS_LOCATION)
32
31
  if !defined?(Gem) || Gem.path != [real_gems_path]
33
32
  $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
34
-
35
- # Suppress warnings from Rubygems
36
- # https://github.com/OpenNebula/one/issues/5379
37
- begin
38
- verb = $VERBOSE
39
- $VERBOSE = nil
40
- require 'rubygems'
41
- Gem.use_paths(real_gems_path)
42
- ensure
43
- $VERBOSE = verb
44
- end
33
+ require 'rubygems'
34
+ Gem.use_paths(real_gems_path)
45
35
  end
46
36
  end
47
- # %%RUBYGEMS_SETUP_END%%
48
37
 
49
38
  $LOAD_PATH << RUBY_LIB_LOCATION
50
39
  $LOAD_PATH << RUBY_LIB_LOCATION + '/cli'
51
40
 
41
+ require 'tempfile'
52
42
  require 'command_parser'
53
43
  require 'one_helper/oneimage_helper'
54
44
  require 'one_helper/onedatastore_helper'
@@ -87,17 +77,25 @@ CommandParser::CmdParser.new(ARGV) do
87
77
  :description => 'lock all actions'
88
78
  }
89
79
 
80
+ NO_CONTEXT = {
81
+ :name => 'no_context',
82
+ :large => '--no-context',
83
+ :description => 'Do not add context when building from Dockerfile'
84
+ }
85
+
90
86
  ########################################################################
91
87
  # Global Options
92
88
  ########################################################################
93
89
  set :option, CommandParser::OPTIONS + OpenNebulaHelper::CLIENT_OPTIONS
94
90
 
95
- list_options = CLIHelper::OPTIONS
96
- list_options << OpenNebulaHelper::XML
91
+ list_options = CLIHelper::OPTIONS
92
+ list_options += OpenNebulaHelper::FORMAT
97
93
  list_options << OpenNebulaHelper::NUMERIC
98
94
  list_options << OpenNebulaHelper::DESCRIBE
99
95
 
100
- CREATE_OPTIONS = [OneDatastoreHelper::DATASTORE, OneImageHelper::IMAGE]
96
+ CREATE_OPTIONS = [OneDatastoreHelper::DATASTORE,
97
+ OneImageHelper::IMAGE,
98
+ NO_CONTEXT]
101
99
 
102
100
  ########################################################################
103
101
  # Formatters for arguments
@@ -182,6 +180,15 @@ CommandParser::CmdParser.new(ARGV) do
182
180
  next -1
183
181
  end
184
182
 
183
+ # Add context information when building image (just working on Docker)
184
+ if (options.key? :no_context) && options[:path]
185
+ if options[:path].include?('?')
186
+ options[:path] << '&context=no'
187
+ else
188
+ options[:path] << '?context=no'
189
+ end
190
+ end
191
+
185
192
  helper.create_resource(options) do |image|
186
193
  begin
187
194
  if args[0]
@@ -404,7 +411,8 @@ CommandParser::CmdParser.new(ARGV) do
404
411
  Shows information for the given Image
405
412
  EOT
406
413
 
407
- command :show, show_desc, :imageid, :options => OpenNebulaHelper::XML do
414
+ command :show, show_desc, :imageid,
415
+ :options => [OpenNebulaHelper::FORMAT, OpenNebulaHelper::DECRYPT] do
408
416
  helper.show_resource(args[0], options)
409
417
  end
410
418
 
@@ -464,4 +472,73 @@ CommandParser::CmdParser.new(ARGV) do
464
472
 
465
473
  return 0
466
474
  end
475
+
476
+ dockerfile_desc = <<-EOT.unindent
477
+ Create an image based on a Dockerfile
478
+ EOT
479
+
480
+ command :dockerfile,
481
+ dockerfile_desc,
482
+ :options => CREATE_OPTIONS +
483
+ OneImageHelper::TEMPLATE_OPTIONS do
484
+ # Check user options
485
+ unless options[:datastore]
486
+ STDERR.puts 'Datastore to save the image is mandatory: '
487
+ STDERR.puts '\t -d datastore_id'
488
+ exit(-1)
489
+ end
490
+
491
+ unless options[:name]
492
+ STDERR.puts 'No name provided'
493
+ exit(-1)
494
+ end
495
+
496
+ unless options[:size]
497
+ STDERR.puts 'No size given'
498
+ exit(-1)
499
+ end
500
+
501
+ # Prepare editor
502
+ tmp = Tempfile.new('dockerfile')
503
+
504
+ if ENV['EDITOR']
505
+ editor_path = ENV['EDITOR']
506
+ else
507
+ editor_path = EDITOR_PATH
508
+ end
509
+
510
+ system("#{editor_path} #{tmp.path}")
511
+
512
+ unless $CHILD_STATUS.exitstatus.zero?
513
+ STDERR.puts('Editor not defined')
514
+ exit(-1)
515
+ end
516
+
517
+ tmp.close
518
+
519
+ # Create image
520
+ helper.create_resource(options) do |image|
521
+ begin
522
+ b64 = Base64.strict_encode64(File.read(tmp.path))
523
+ options[:path] = "dockerfile:///?fileb64=#{b64}&" \
524
+ "size=#{options[:size]}"
525
+
526
+ options[:path] << '&context=no' if options.key?(:no_context)
527
+
528
+ res = OneImageHelper.create_image_template(options)
529
+
530
+ if res.first != 0
531
+ STDERR.puts res.last
532
+ next -1
533
+ end
534
+
535
+ template = res.last
536
+
537
+ image.allocate(template, options[:datastore], false)
538
+ rescue StandardError => e
539
+ STDERR.puts e.message
540
+ exit(-1)
541
+ end
542
+ end
543
+ end
467
544
  end
data/bin/onemarket CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2023, 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 #
@@ -26,25 +26,14 @@ else
26
26
  GEMS_LOCATION = ONE_LOCATION + '/share/gems'
27
27
  end
28
28
 
29
- # %%RUBYGEMS_SETUP_BEGIN%%
30
29
  if File.directory?(GEMS_LOCATION)
31
30
  real_gems_path = File.realpath(GEMS_LOCATION)
32
31
  if !defined?(Gem) || Gem.path != [real_gems_path]
33
32
  $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
34
-
35
- # Suppress warnings from Rubygems
36
- # https://github.com/OpenNebula/one/issues/5379
37
- begin
38
- verb = $VERBOSE
39
- $VERBOSE = nil
40
- require 'rubygems'
41
- Gem.use_paths(real_gems_path)
42
- ensure
43
- $VERBOSE = verb
44
- end
33
+ require 'rubygems'
34
+ Gem.use_paths(real_gems_path)
45
35
  end
46
36
  end
47
- # %%RUBYGEMS_SETUP_END%%
48
37
 
49
38
  $LOAD_PATH << RUBY_LIB_LOCATION
50
39
  $LOAD_PATH << RUBY_LIB_LOCATION + '/cli'
@@ -67,8 +56,8 @@ CommandParser::CmdParser.new(ARGV) do
67
56
  ########################################################################
68
57
  set :option, CommandParser::OPTIONS + OpenNebulaHelper::CLIENT_OPTIONS
69
58
 
70
- list_options = CLIHelper::OPTIONS
71
- list_options << OpenNebulaHelper::XML
59
+ list_options = CLIHelper::OPTIONS
60
+ list_options += OpenNebulaHelper::FORMAT
72
61
  list_options << OpenNebulaHelper::NUMERIC
73
62
  list_options << OpenNebulaHelper::DESCRIBE
74
63
 
@@ -168,7 +157,7 @@ CommandParser::CmdParser.new(ARGV) do
168
157
  EOT
169
158
 
170
159
  command :show, show_desc,
171
- :marketplaceid, :options => OpenNebulaHelper::XML do
160
+ :marketplaceid, :options => OpenNebulaHelper::FORMAT do
172
161
  helper.show_resource(args[0], options)
173
162
  end
174
163
 
data/bin/onemarketapp CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2023, 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 #
@@ -28,25 +28,14 @@ else
28
28
  VAR_LOCATION = ONE_LOCATION + '/var'
29
29
  end
30
30
 
31
- # %%RUBYGEMS_SETUP_BEGIN%%
32
31
  if File.directory?(GEMS_LOCATION)
33
32
  real_gems_path = File.realpath(GEMS_LOCATION)
34
33
  if !defined?(Gem) || Gem.path != [real_gems_path]
35
34
  $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
36
-
37
- # Suppress warnings from Rubygems
38
- # https://github.com/OpenNebula/one/issues/5379
39
- begin
40
- verb = $VERBOSE
41
- $VERBOSE = nil
42
- require 'rubygems'
43
- Gem.use_paths(real_gems_path)
44
- ensure
45
- $VERBOSE = verb
46
- end
35
+ require 'rubygems'
36
+ Gem.use_paths(real_gems_path)
47
37
  end
48
38
  end
49
- # %%RUBYGEMS_SETUP_END%%
50
39
 
51
40
  $LOAD_PATH << RUBY_LIB_LOCATION
52
41
  $LOAD_PATH << RUBY_LIB_LOCATION + '/cli'
@@ -56,6 +45,9 @@ require 'one_helper/onemarketapp_helper'
56
45
  require 'one_helper/onemarket_helper'
57
46
  require 'one_helper/onedatastore_helper'
58
47
 
48
+ require 'vcenter_driver'
49
+ CONFIG = VCenterConf.new
50
+
59
51
  CommandParser::CmdParser.new(ARGV) do
60
52
  usage '`onemarket` <command> [<args>] [<options>]'
61
53
  version OpenNebulaHelper::ONE_VERSION
@@ -97,20 +89,56 @@ CommandParser::CmdParser.new(ARGV) do
97
89
  :description => 'DockerHub image tag (default latest)'
98
90
  }
99
91
 
92
+ YES = {
93
+ :name => 'yes',
94
+ :large => '--yes',
95
+ :description => 'Import associated VM templates/images',
96
+ :proc => lambda do |_, options|
97
+ options[:yes] = 'yes'
98
+ end
99
+ }
100
+
101
+ NO = {
102
+ :name => 'no',
103
+ :large => '--no',
104
+ :description => 'Do not import/export associated VM templates/images',
105
+ :proc => lambda do |_, options|
106
+ options[:no] = 'no'
107
+ end
108
+ }
109
+
110
+ TEMPLATE = {
111
+ :name => 'template',
112
+ :large => '--template template_id ',
113
+ :description => 'Associate with VM template',
114
+ :format => Integer
115
+ }
116
+
117
+ MARKET = {
118
+ :name => 'market',
119
+ :large => '--market market_id',
120
+ :format => Integer,
121
+ :description => 'Market to import all objects'
122
+ }
123
+
100
124
  ########################################################################
101
125
  # Global Options
102
126
  ########################################################################
103
127
  set :option, CommandParser::OPTIONS + OpenNebulaHelper::CLIENT_OPTIONS
104
128
 
105
- list_options = CLIHelper::OPTIONS
106
- list_options << OpenNebulaHelper::XML
129
+ list_options = CLIHelper::OPTIONS
130
+ list_options += OpenNebulaHelper::FORMAT
107
131
  list_options << OpenNebulaHelper::NUMERIC
108
132
  list_options << OpenNebulaHelper::DESCRIBE
109
133
 
110
134
  CREATE_OPTIONS = [OneMarketPlaceHelper::MARKETPLACE]
111
135
  EXPORT_OPTIONS = [OneDatastoreHelper::DATASTORE,
136
+ OneDatastoreHelper::FILE_DATASTORE,
112
137
  OneMarketPlaceAppHelper::VMNAME,
113
- TAG]
138
+ TAG,
139
+ NO,
140
+ TEMPLATE]
141
+ IMPORT_OPTIONS = [YES, NO, MARKET, OneMarketPlaceAppHelper::VMNAME]
114
142
 
115
143
  ########################################################################
116
144
  # Formatters for arguments
@@ -189,6 +217,60 @@ CommandParser::CmdParser.new(ARGV) do
189
217
  end
190
218
  end
191
219
 
220
+ import_desc = <<-EOT.unindent
221
+ Imports a service template into the marketplace
222
+ EOT
223
+
224
+ command [:'service-template', :import],
225
+ import_desc,
226
+ :service_template_id,
227
+ :options => IMPORT_OPTIONS do
228
+ helper.import(args[0], ServiceTemplate) do |id|
229
+ helper.import_service_template(id, options)
230
+ end
231
+ end
232
+
233
+ vm_import_desc = <<-EOT.unindent
234
+ Imports a VM template into the marketplace
235
+ EOT
236
+
237
+ command [:'vm-template', :import],
238
+ vm_import_desc,
239
+ :vm_template_id,
240
+ :options => IMPORT_OPTIONS do
241
+ helper.import(args[0], TemplatePool) do |id|
242
+ helper.import_vm_template(id, options)
243
+ end
244
+ end
245
+
246
+ vm_import_desc = <<-EOT.unindent
247
+ Imports a VM into the marketplace
248
+ EOT
249
+
250
+ command [:vm, :import],
251
+ vm_import_desc,
252
+ :vm_id,
253
+ :options => IMPORT_OPTIONS do
254
+ t_id = helper.save_as_template(
255
+ helper.get_obj_id(args[0], VirtualMachinePool)
256
+ )
257
+
258
+ if OpenNebula.is_error?(t_id)
259
+ STDERR.puts t_id.message
260
+ exit(-1)
261
+ else
262
+ helper.import(t_id, TemplatePool) do |id|
263
+ helper.import_vm_template(id, options)
264
+ end
265
+ end
266
+
267
+ puts
268
+ puts 'To delete saved template use: ' \
269
+ "`onetemplate delete #{t_id} --recursive`"
270
+
271
+ 0
272
+ end
273
+
192
274
  export_desc = <<-EOT.unindent
193
275
  Exports the marketplace app to the OpenNebula cloud
194
276
  EOT
@@ -197,20 +279,31 @@ CommandParser::CmdParser.new(ARGV) do
197
279
  helper.perform_action(args[0], options, 'exported') do |obj|
198
280
  tag ="tag=#{options[:tag]}" if options[:tag]
199
281
 
282
+ obj.extend(MarketPlaceAppExt)
283
+
200
284
  rc = obj.export(
201
285
  :dsid => options[:datastore],
202
286
  :name => args[1],
203
287
  :vmtemplate_name => options[:vmname],
204
- :url_args => tag
288
+ :url_args => tag,
289
+ :notemplate => options[:no] == 'no',
290
+ :template => options[:template],
291
+ :default_template => CONFIG[:default_template]
205
292
  )
206
293
 
207
- next rc if OpenNebula.is_error?(rc)
294
+ if OpenNebula.is_error?(rc)
295
+ STDERR.puts rc.message
296
+ exit(-1)
297
+ end
208
298
 
209
299
  rc.each do |key, value|
300
+ next if value.nil? || value.empty? || key == :image_type
301
+
210
302
  puts key.to_s.upcase
211
303
  value.each do |id|
212
304
  if OpenNebula.is_error?(id)
213
305
  puts id.to_str
306
+ exit(-1)
214
307
  else
215
308
  puts " ID: #{id}"
216
309
  end
@@ -314,7 +407,7 @@ CommandParser::CmdParser.new(ARGV) do
314
407
  Shows information for the given marketplace app
315
408
  EOT
316
409
 
317
- command :show, show_desc, :appid, :options => OpenNebulaHelper::XML do
410
+ command :show, show_desc, :appid, :options => OpenNebulaHelper::FORMAT do
318
411
  helper.show_resource(args[0], options)
319
412
  end
320
413
 
data/bin/onesecgroup CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2023, 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 #
@@ -26,25 +26,14 @@ else
26
26
  GEMS_LOCATION = ONE_LOCATION + '/share/gems'
27
27
  end
28
28
 
29
- # %%RUBYGEMS_SETUP_BEGIN%%
30
29
  if File.directory?(GEMS_LOCATION)
31
30
  real_gems_path = File.realpath(GEMS_LOCATION)
32
31
  if !defined?(Gem) || Gem.path != [real_gems_path]
33
32
  $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
34
-
35
- # Suppress warnings from Rubygems
36
- # https://github.com/OpenNebula/one/issues/5379
37
- begin
38
- verb = $VERBOSE
39
- $VERBOSE = nil
40
- require 'rubygems'
41
- Gem.use_paths(real_gems_path)
42
- ensure
43
- $VERBOSE = verb
44
- end
33
+ require 'rubygems'
34
+ Gem.use_paths(real_gems_path)
45
35
  end
46
36
  end
47
- # %%RUBYGEMS_SETUP_END%%
48
37
 
49
38
  $LOAD_PATH << RUBY_LIB_LOCATION
50
39
  $LOAD_PATH << RUBY_LIB_LOCATION + '/cli'
@@ -67,8 +56,8 @@ CommandParser::CmdParser.new(ARGV) do
67
56
  ########################################################################
68
57
  set :option, CommandParser::OPTIONS + OpenNebulaHelper::CLIENT_OPTIONS
69
58
 
70
- list_options = CLIHelper::OPTIONS
71
- list_options << OpenNebulaHelper::XML
59
+ list_options = CLIHelper::OPTIONS
60
+ list_options += OpenNebulaHelper::FORMAT
72
61
  list_options << OpenNebulaHelper::NUMERIC
73
62
  list_options << OpenNebulaHelper::DESCRIBE
74
63
 
@@ -235,7 +224,10 @@ CommandParser::CmdParser.new(ARGV) do
235
224
  Shows information for the given Security Group
236
225
  EOT
237
226
 
238
- command :show, show_desc, :secgroupid, :options => OpenNebulaHelper::XML do
227
+ command :show,
228
+ show_desc,
229
+ :secgroupid,
230
+ :options => OpenNebulaHelper::FORMAT do
239
231
  helper.show_resource(args[0], options)
240
232
  end
241
233
  end
data/bin/oneshowback CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2023, 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 #
@@ -26,25 +26,14 @@ else
26
26
  GEMS_LOCATION = ONE_LOCATION + '/share/gems'
27
27
  end
28
28
 
29
- # %%RUBYGEMS_SETUP_BEGIN%%
30
29
  if File.directory?(GEMS_LOCATION)
31
30
  real_gems_path = File.realpath(GEMS_LOCATION)
32
31
  if !defined?(Gem) || Gem.path != [real_gems_path]
33
32
  $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
34
-
35
- # Suppress warnings from Rubygems
36
- # https://github.com/OpenNebula/one/issues/5379
37
- begin
38
- verb = $VERBOSE
39
- $VERBOSE = nil
40
- require 'rubygems'
41
- Gem.use_paths(real_gems_path)
42
- ensure
43
- $VERBOSE = verb
44
- end
33
+ require 'rubygems'
34
+ Gem.use_paths(real_gems_path)
45
35
  end
46
36
  end
47
- # %%RUBYGEMS_SETUP_END%%
48
37
 
49
38
  $LOAD_PATH << RUBY_LIB_LOCATION
50
39
  $LOAD_PATH << RUBY_LIB_LOCATION + '/cli'
@@ -106,27 +95,31 @@ CommandParser::CmdParser.new(ARGV) do
106
95
 
107
96
  pool = OpenNebula::VirtualMachinePool.new(helper.client)
108
97
 
109
- if options[:json] || options[:xml]
98
+ if options[:json] || options[:xml] || options[:yaml]
110
99
  xml_str = pool.showback_xml(filter_flag, common_opts)
111
100
  if OpenNebula.is_error?(xml_str)
112
101
  puts xml_str.message
113
102
  exit(-1)
114
103
  end
115
104
 
116
- if options[:json]
117
- xmldoc = XMLElement.new
118
- xmldoc.initialize_xml(xml_str, 'SHOWBACK_RECORDS')
105
+ xmldoc = XMLElement.new
106
+ xmldoc.initialize_xml(xml_str, 'SHOWBACK_RECORDS')
119
107
 
108
+ if options[:json]
120
109
  puts JSON.pretty_generate(xmldoc.to_hash)
110
+ elsif options[:yaml]
111
+ puts xmldoc.to_hash.to_yaml(:indent => 4)
121
112
  elsif options[:xml]
122
113
  puts xml_str
123
114
  end
124
115
  else
116
+ # rubocop:disable Naming/VariableNumber
125
117
  order_by = {}
126
118
  if !options[:csv]
127
119
  order_by[:order_by_1] = 'YEAR'
128
120
  order_by[:order_by_2] = 'MONTH'
129
121
  end
122
+ # rubocop:enable Naming/VariableNumber
130
123
 
131
124
  data_hash = pool.showback(filter_flag,
132
125
  common_opts.merge(order_by))
@@ -186,8 +179,9 @@ CommandParser::CmdParser.new(ARGV) do
186
179
  end_year)
187
180
 
188
181
  if OpenNebula.is_error?(rc)
189
- if rc.message.include? "ReadTimeout"
190
- warn "Showback calculation takes too long, continuing in background"
182
+ if rc.message.include? 'ReadTimeout'
183
+ warn 'Showback calculation takes too long, '\
184
+ 'continuing in background'
191
185
  exit_code 0
192
186
  else
193
187
  warn rc.message
data/bin/onetemplate CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # -------------------------------------------------------------------------- #
4
- # Copyright 2002-2023, 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 #
@@ -26,25 +26,14 @@ else
26
26
  GEMS_LOCATION = ONE_LOCATION + '/share/gems'
27
27
  end
28
28
 
29
- # %%RUBYGEMS_SETUP_BEGIN%%
30
29
  if File.directory?(GEMS_LOCATION)
31
30
  real_gems_path = File.realpath(GEMS_LOCATION)
32
31
  if !defined?(Gem) || Gem.path != [real_gems_path]
33
32
  $LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
34
-
35
- # Suppress warnings from Rubygems
36
- # https://github.com/OpenNebula/one/issues/5379
37
- begin
38
- verb = $VERBOSE
39
- $VERBOSE = nil
40
- require 'rubygems'
41
- Gem.use_paths(real_gems_path)
42
- ensure
43
- $VERBOSE = verb
44
- end
33
+ require 'rubygems'
34
+ Gem.use_paths(real_gems_path)
45
35
  end
46
36
  end
47
- # %%RUBYGEMS_SETUP_END%%
48
37
 
49
38
  $LOAD_PATH << RUBY_LIB_LOCATION
50
39
  $LOAD_PATH << RUBY_LIB_LOCATION + '/cli'
@@ -92,8 +81,8 @@ CommandParser::CmdParser.new(ARGV) do
92
81
  ########################################################################
93
82
  set :option, CommandParser::OPTIONS + OpenNebulaHelper::CLIENT_OPTIONS
94
83
 
95
- list_options = CLIHelper::OPTIONS
96
- list_options << OpenNebulaHelper::XML
84
+ list_options = CLIHelper::OPTIONS
85
+ list_options += OpenNebulaHelper::FORMAT
97
86
  list_options << OpenNebulaHelper::NUMERIC
98
87
  list_options << OpenNebulaHelper::DESCRIBE
99
88
 
@@ -277,7 +266,7 @@ CommandParser::CmdParser.new(ARGV) do
277
266
  else
278
267
  optionals = OneTemplateHelper.get_user_inputs(
279
268
  t.to_hash,
280
- options[:user_inputs_keys],
269
+ options[:user_inputs_keys]
281
270
  )
282
271
 
283
272
  user_inputs = user_inputs + "\n" + optionals
@@ -383,7 +372,8 @@ CommandParser::CmdParser.new(ARGV) do
383
372
  EOT
384
373
 
385
374
  command :show, show_desc, :templateid,
386
- :options => [OpenNebulaHelper::XML, OneTemplateHelper::EXTENDED] do
375
+ :options => [OpenNebulaHelper::FORMAT,
376
+ OneTemplateHelper::EXTENDED] do
387
377
  helper.show_resource(args[0], options)
388
378
  end
389
379