opennebula-cli 5.12.9 → 6.0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) 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 +10 -7
  11. data/bin/oneimage +100 -9
  12. data/bin/onemarket +10 -7
  13. data/bin/onemarketapp +114 -11
  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 +8 -11
  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 +11 -8
  26. data/lib/cli_helper.rb +17 -8
  27. data/lib/command_parser.rb +17 -14
  28. data/lib/one_helper.rb +401 -39
  29. data/lib/one_helper/oneacct_helper.rb +6 -17
  30. data/lib/one_helper/oneacl_helper.rb +1 -1
  31. data/lib/one_helper/onecluster_helper.rb +1 -1
  32. data/lib/one_helper/onedatastore_helper.rb +11 -1
  33. data/lib/one_helper/oneflow_helper.rb +20 -5
  34. data/lib/one_helper/oneflowtemplate_helper.rb +28 -2
  35. data/lib/one_helper/onegroup_helper.rb +1 -1
  36. data/lib/one_helper/onehook_helper.rb +1 -1
  37. data/lib/one_helper/onehost_helper.rb +1 -5
  38. data/lib/one_helper/oneimage_helper.rb +13 -7
  39. data/lib/one_helper/onemarket_helper.rb +1 -1
  40. data/lib/one_helper/onemarketapp_helper.rb +500 -96
  41. data/lib/one_helper/onequota_helper.rb +1 -1
  42. data/lib/one_helper/onesecgroup_helper.rb +1 -1
  43. data/lib/one_helper/onetemplate_helper.rb +12 -1
  44. data/lib/one_helper/oneuser_helper.rb +11 -3
  45. data/lib/one_helper/onevcenter_helper.rb +176 -146
  46. data/lib/one_helper/onevdc_helper.rb +1 -1
  47. data/lib/one_helper/onevm_helper.rb +4 -3
  48. data/lib/one_helper/onevmgroup_helper.rb +1 -1
  49. data/lib/one_helper/onevnet_helper.rb +1 -1
  50. data/lib/one_helper/onevntemplate_helper.rb +1 -1
  51. data/lib/one_helper/onevrouter_helper.rb +1 -20
  52. data/lib/one_helper/onezone_helper.rb +24 -17
  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 +50 -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/monitoring_data.xsd +41 -0
  79. data/share/schemas/xsd/opennebula_configuration.xsd +412 -0
  80. data/share/schemas/xsd/raftstatus.xsd +18 -0
  81. data/share/schemas/xsd/security_group.xsd +74 -0
  82. data/share/schemas/xsd/security_group_pool.xsd +12 -0
  83. data/share/schemas/xsd/showback.xsd +29 -0
  84. data/share/schemas/xsd/user.xsd +186 -0
  85. data/share/schemas/xsd/user_pool.xsd +201 -0
  86. data/share/schemas/xsd/vdc.xsd +76 -0
  87. data/share/schemas/xsd/vdc_pool.xsd +12 -0
  88. data/share/schemas/xsd/vm.xsd +251 -0
  89. data/share/schemas/xsd/vm_group.xsd +59 -0
  90. data/share/schemas/xsd/vm_group_pool.xsd +12 -0
  91. data/share/schemas/xsd/vm_pool.xsd +114 -0
  92. data/share/schemas/xsd/vmtemplate.xsd +52 -0
  93. data/share/schemas/xsd/vmtemplate_pool.xsd +12 -0
  94. data/share/schemas/xsd/vnet.xsd +137 -0
  95. data/share/schemas/xsd/vnet_pool.xsd +85 -0
  96. data/share/schemas/xsd/vntemplate.xsd +50 -0
  97. data/share/schemas/xsd/vntemplate_pool.xsd +12 -0
  98. data/share/schemas/xsd/vrouter.xsd +49 -0
  99. data/share/schemas/xsd/vrouter_pool.xsd +12 -0
  100. data/share/schemas/xsd/zone.xsd +40 -0
  101. data/share/schemas/xsd/zone_pool.xsd +36 -0
  102. metadata +67 -5
  103. data/lib/one_helper/oneprovision_helper.rb +0 -362
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6ffe5519361d8bfe5ec8049e21fcc525f31df1af
4
- data.tar.gz: c6c8c856980868f1940e2006f9e606e7e2541a20
3
+ metadata.gz: 744bd1ffb1ad108ad3ebfac08a3e7a0f2e12eea0
4
+ data.tar.gz: d6d8d5f7a701b7252ae828bbcc00c35705e29275
5
5
  SHA512:
6
- metadata.gz: 547bae16979befeb2d672f25718e6b46e34a7fb3dd86f18dbce903dc86a44d6289b7fbed81e5e944b0e3605e6e617f4c12d8e91e0a69b320d91e367420353b2f
7
- data.tar.gz: 714d0229222f5f7b6fbe512b6b830f9393ddb4409622013d0a0a6bf6e3ac21a1d45be6596d97f30918457dc454a72435f6426562b8cb8b05371b5270a440d9a6
6
+ metadata.gz: f468a81b851acbd4b453b4c2248092544c99bcc41af5ee9b42ae67bf87251fc74ec5acf4f26ca48cc31d63075522b97053e56158bf411d15312dcef89fa840e8
7
+ data.tar.gz: 53662ad598df3da566a839f114e7451e9fdd1392ae14487ee733ba858cc812a050df98579ea6fcec70774c63ad17f12dcfdeef399a40e3471687b3b19d2fe937
data/bin/oneacct 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
@@ -109,12 +112,14 @@ CommandParser::CmdParser.new(ARGV) do
109
112
  puts xml_str
110
113
  end
111
114
  else
115
+ # rubocop:disable Naming/VariableNumber
112
116
  order_by = {}
113
117
  order_by[:order_by_1] = 'VM/UID'
114
118
 
115
119
  if options[:split] && !options[:csv]
116
120
  order_by[:order_by_2] = 'VM/ID'
117
121
  end
122
+ # rubocop:enable Naming/VariableNumber
118
123
 
119
124
  acct_hash = pool.accounting(filter_flag,
120
125
  common_opts.merge(order_by))
data/bin/oneacl 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
@@ -103,7 +106,7 @@ CommandParser::CmdParser.new(ARGV) do
103
106
  EOT
104
107
 
105
108
  command :list, list_desc, :options => [CLIHelper::OPTIONS,
106
- OpenNebulaHelper::XML,
109
+ OpenNebulaHelper::FORMAT,
107
110
  OpenNebulaHelper::DESCRIBE] do
108
111
  helper.list_pool(options)
109
112
  end
data/bin/onecluster 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
 
@@ -119,7 +122,7 @@ CommandParser::CmdParser.new(ARGV) do
119
122
  EOT
120
123
 
121
124
  command :show, show_desc, :clusterid,
122
- :options => [OpenNebulaHelper::XML, OpenNebulaHelper::DECRYPT] do
125
+ :options => [OpenNebulaHelper::FORMAT, OpenNebulaHelper::DECRYPT] do
123
126
  helper.show_resource(args[0], options)
124
127
  end
125
128
 
data/bin/onedatastore 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
@@ -54,8 +57,8 @@ CommandParser::CmdParser.new(ARGV) do
54
57
  ########################################################################
55
58
  set :option, CommandParser::OPTIONS + OpenNebulaHelper::CLIENT_OPTIONS
56
59
 
57
- list_options = CLIHelper::OPTIONS
58
- list_options << OpenNebulaHelper::XML
60
+ list_options = CLIHelper::OPTIONS
61
+ list_options += OpenNebulaHelper::FORMAT
59
62
  list_options << OpenNebulaHelper::NUMERIC
60
63
  list_options << OpenNebulaHelper::DESCRIBE
61
64
 
@@ -161,7 +164,7 @@ CommandParser::CmdParser.new(ARGV) do
161
164
  EOT
162
165
 
163
166
  command :show, show_desc, :datastoreid,
164
- :options => [OpenNebulaHelper::XML, OpenNebulaHelper::DECRYPT] do
167
+ :options => [OpenNebulaHelper::FORMAT, OpenNebulaHelper::DECRYPT] do
165
168
  helper.show_resource(args[0], options)
166
169
  end
167
170
 
data/bin/oneflow 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,15 +27,19 @@ 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
36
39
  $LOAD_PATH << RUBY_LIB_LOCATION + '/cli'
37
40
 
38
41
  require 'json'
42
+ require 'tempfile'
39
43
 
40
44
  require 'command_parser'
41
45
  require 'opennebula/oneflow_client'
@@ -54,12 +58,6 @@ CommandParser::CmdParser.new(ARGV) do
54
58
  set :option, CommandParser::VERSION
55
59
  set :option, CommandParser::HELP
56
60
 
57
- DONE = {
58
- :name => 'done',
59
- :large => '--done',
60
- :description => 'Show services in DONE state'
61
- }
62
-
63
61
  ARGS = {
64
62
  :name => 'args',
65
63
  :large => '--args arg1,arg2',
@@ -113,7 +111,7 @@ CommandParser::CmdParser.new(ARGV) do
113
111
  List the available services
114
112
  EOT
115
113
 
116
- command :list, list_desc, :options => [Service::JSON_FORMAT, DONE] do
114
+ command :list, list_desc, :options => OpenNebulaHelper::FORMAT do
117
115
  helper.list_service_pool(helper.client(options), options)
118
116
  end
119
117
 
@@ -123,7 +121,7 @@ CommandParser::CmdParser.new(ARGV) do
123
121
  Top the available services
124
122
  EOT
125
123
 
126
- command :top, top_desc, :options => [CLIHelper::DELAY, DONE] do
124
+ command :top, top_desc, :options => [CLIHelper::DELAY] do
127
125
  Signal.trap('INT') { exit(-1) }
128
126
 
129
127
  helper.top_service_pool(helper.client(options), options)
@@ -137,7 +135,10 @@ CommandParser::CmdParser.new(ARGV) do
137
135
  Show detailed information of a given service
138
136
  EOT
139
137
 
140
- command :show, show_desc, :service_id, :options => Service::JSON_FORMAT do
138
+ command :show,
139
+ show_desc,
140
+ :service_id,
141
+ :options => OpenNebulaHelper::FORMAT do
141
142
  helper.format_resource(helper.client(options), args[0], options)
142
143
  end
143
144
 
@@ -345,4 +346,75 @@ CommandParser::CmdParser.new(ARGV) do
345
346
  client.post("#{RESOURCE_PATH}/#{service_id}/action", json)
346
347
  end
347
348
  end
349
+
350
+ ###
351
+
352
+ update_desc = <<-EOT.unindent
353
+ Update the template contents. If a path is not provided the editor will
354
+ be launched to modify the current content.
355
+ EOT
356
+
357
+ command :update, update_desc, :service_id, [:file, nil] do
358
+ service_id = args[0]
359
+ client = helper.client(options)
360
+
361
+ if args[1]
362
+ path = args[1]
363
+ else
364
+ response = client.get("#{RESOURCE_PATH}/#{service_id}")
365
+
366
+ if CloudClient.is_error?(response)
367
+ exit_with_code response.code.to_i, response.to_s
368
+ else
369
+ document = JSON.parse(response.body)['DOCUMENT']
370
+ template = document['TEMPLATE']['BODY']
371
+
372
+ tmp = Tempfile.new(service_id.to_s)
373
+ path = tmp.path
374
+
375
+ tmp.write(JSON.pretty_generate(template))
376
+ tmp.flush
377
+
378
+ if ENV['EDITOR']
379
+ editor_path = ENV['EDITOR']
380
+ else
381
+ editor_path = OpenNebulaHelper::EDITOR_PATH
382
+ end
383
+
384
+ system("#{editor_path} #{path}")
385
+
386
+ unless $CHILD_STATUS.exitstatus.zero?
387
+ STDERR.puts 'Editor not defined'
388
+ exit(-1)
389
+ end
390
+
391
+ tmp.close
392
+ end
393
+ end
394
+
395
+ response = client.put("#{RESOURCE_PATH}/#{service_id}", File.read(path))
396
+
397
+ if CloudClient.is_error?(response)
398
+ [response.code.to_i, response.to_s]
399
+ else
400
+ 0
401
+ end
402
+ end
403
+
404
+ ###
405
+
406
+ purge_done_desc = <<-EOT.unindent
407
+ Purge and delete services in DONE state
408
+ EOT
409
+
410
+ command :'purge-done', purge_done_desc do
411
+ client = helper.client(options)
412
+ response = client.post('/service_pool/purge_done', '')
413
+
414
+ if CloudClient.is_error?(response)
415
+ exit_with_code response.code.to_i, response.to_s
416
+ else
417
+ 0
418
+ end
419
+ end
348
420
  end
data/bin/oneflow-template 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
@@ -76,6 +79,20 @@ CommandParser::CmdParser.new(ARGV) do
76
79
  :description => 'Clone the template recursively (just templates)'
77
80
  }
78
81
 
82
+ DELETE_TEMPLATES = {
83
+ :name => 'delete_templates',
84
+ :large => '--delete-vm-templates',
85
+ :description => 'Delete associated VM templates when deleting ' \
86
+ 'service template'
87
+ }
88
+
89
+ DELETE_IMAGES = {
90
+ :name => 'delete_images',
91
+ :large => '--delete-images',
92
+ :description => 'Delete associated VM templates and images when ' \
93
+ 'deleting service template'
94
+ }
95
+
79
96
  usage '`oneflow-template` <command> [<args>] [<options>]'
80
97
  version OpenNebulaHelper::ONE_VERSION
81
98
 
@@ -113,7 +130,7 @@ CommandParser::CmdParser.new(ARGV) do
113
130
  List the available Service Templates
114
131
  EOT
115
132
 
116
- command :list, list_desc, :options => Service::JSON_FORMAT do
133
+ command :list, list_desc, :options => OpenNebulaHelper::FORMAT do
117
134
  helper.list_service_template_pool(helper.client(options), options)
118
135
  end
119
136
 
@@ -141,7 +158,10 @@ CommandParser::CmdParser.new(ARGV) do
141
158
  Show detailed information of a given Service Template
142
159
  EOT
143
160
 
144
- command :show, show_desc, :templateid, :options => Service::JSON_FORMAT do
161
+ command :show,
162
+ show_desc,
163
+ :templateid,
164
+ :options => OpenNebulaHelper::FORMAT do
145
165
  helper.format_resource(helper.client(options), args[0], options)
146
166
  end
147
167
 
@@ -174,11 +194,28 @@ CommandParser::CmdParser.new(ARGV) do
174
194
  Delete a given Service Template
175
195
  EOT
176
196
 
177
- command :delete, delete_desc, [:range, :templateid_list] do
197
+ command :delete,
198
+ delete_desc,
199
+ [:range, :templateid_list],
200
+ :options => [DELETE_TEMPLATES, DELETE_IMAGES] do
178
201
  client = helper.client(options)
179
202
 
203
+ # :templates => delete just VM templates
204
+ # :all => delete VM templates and images
205
+ # :none => do not delete anything
206
+ if options.key?(:delete_templates)
207
+ delete = 'templates'
208
+ elsif options.key?(:delete_images)
209
+ delete = 'all'
210
+ else
211
+ delete = 'none'
212
+ end
213
+
214
+ body = {}
215
+ body['delete_type'] = delete
216
+
180
217
  Service.perform_actions(args[0]) do |template_id|
181
- client.delete("#{RESOURCE_PATH}/#{template_id}")
218
+ client.delete("#{RESOURCE_PATH}/#{template_id}", body.to_json)
182
219
  end
183
220
  end
184
221
 
data/bin/onegroup 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
 
@@ -166,7 +169,7 @@ CommandParser::CmdParser.new(ARGV) do
166
169
  EOT
167
170
 
168
171
  command :show, show_desc, [:groupid, nil],
169
- :options => OpenNebulaHelper::XML do
172
+ :options => OpenNebulaHelper::FORMAT do
170
173
  group = args[0] || OpenNebula::Group::SELF
171
174
  helper.show_resource(group, options)
172
175
  end