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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: e1339016807784d2563695e736896cff9b34c6ac0ada98d0468d6a106a3736d1
4
- data.tar.gz: d11bf3c46118f01421788be84eb08a37b95ec6b746c4ed23c416545ed0e647d7
2
+ SHA1:
3
+ metadata.gz: 133ad6e159617025214647d52dbcb5d41f3093cf
4
+ data.tar.gz: 11cdb1ed429159108f9374034cf3fbe7a7866b8c
5
5
  SHA512:
6
- metadata.gz: 84059bd06effa9fe8a51a6821a68119ee7f5e7359cf9d6a7d10ec7533f99c5cb92ab6e67e2feb509a1494453c6091f63377c415d5948dc1a6511168bf04d4d98
7
- data.tar.gz: 138d2f21a5d82cf6532327bb2f83ab92513fba3b5b7204c918a3841bf697caba6c454f76a97df2860c5b67f517518b9db88fe4b83fc549b5e45ff8f3bd0ec619
6
+ metadata.gz: b6450713483ad56c4eea014eb294043d0c83b6d29175c5c123a50e854bc5b08ffc9ecfe034dd19b7dc04655b6581152d047df29e475fdbd16bb812ee9b3701cf
7
+ data.tar.gz: 2633fb675faf36ec1c5d7bf20c57ecaf22f2af9404a5141a7310049108574f2e41b75f260936aa4e9109051ad600341605f350ccd2beeb9d5c61e2bb4e4a0657
data/bin/oneacct 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'
@@ -123,12 +112,14 @@ CommandParser::CmdParser.new(ARGV) do
123
112
  puts xml_str
124
113
  end
125
114
  else
115
+ # rubocop:disable Naming/VariableNumber
126
116
  order_by = {}
127
117
  order_by[:order_by_1] = 'VM/UID'
128
118
 
129
119
  if options[:split] && !options[:csv]
130
120
  order_by[:order_by_2] = 'VM/ID'
131
121
  end
122
+ # rubocop:enable Naming/VariableNumber
132
123
 
133
124
  acct_hash = pool.accounting(filter_flag,
134
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-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'
@@ -117,7 +106,7 @@ CommandParser::CmdParser.new(ARGV) do
117
106
  EOT
118
107
 
119
108
  command :list, list_desc, :options => [CLIHelper::OPTIONS,
120
- OpenNebulaHelper::XML,
109
+ OpenNebulaHelper::FORMAT,
121
110
  OpenNebulaHelper::DESCRIBE] do
122
111
  helper.list_pool(options)
123
112
  end
data/bin/onecluster 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
 
@@ -133,7 +122,7 @@ CommandParser::CmdParser.new(ARGV) do
133
122
  EOT
134
123
 
135
124
  command :show, show_desc, :clusterid,
136
- :options => [OpenNebulaHelper::XML, OpenNebulaHelper::DECRYPT] do
125
+ :options => [OpenNebulaHelper::FORMAT, OpenNebulaHelper::DECRYPT] do
137
126
  helper.show_resource(args[0], options)
138
127
  end
139
128
 
data/bin/onedatastore 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'
@@ -68,8 +57,8 @@ CommandParser::CmdParser.new(ARGV) do
68
57
  ########################################################################
69
58
  set :option, CommandParser::OPTIONS + OpenNebulaHelper::CLIENT_OPTIONS
70
59
 
71
- list_options = CLIHelper::OPTIONS
72
- list_options << OpenNebulaHelper::XML
60
+ list_options = CLIHelper::OPTIONS
61
+ list_options += OpenNebulaHelper::FORMAT
73
62
  list_options << OpenNebulaHelper::NUMERIC
74
63
  list_options << OpenNebulaHelper::DESCRIBE
75
64
 
@@ -175,7 +164,7 @@ CommandParser::CmdParser.new(ARGV) do
175
164
  EOT
176
165
 
177
166
  command :show, show_desc, :datastoreid,
178
- :options => [OpenNebulaHelper::XML, OpenNebulaHelper::DECRYPT] do
167
+ :options => [OpenNebulaHelper::FORMAT, OpenNebulaHelper::DECRYPT] do
179
168
  helper.show_resource(args[0], options)
180
169
  end
181
170
 
data/bin/oneflow 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,30 +26,20 @@ 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
 
52
41
  require 'json'
42
+ require 'tempfile'
53
43
 
54
44
  require 'command_parser'
55
45
  require 'opennebula/oneflow_client'
@@ -68,12 +58,6 @@ CommandParser::CmdParser.new(ARGV) do
68
58
  set :option, CommandParser::VERSION
69
59
  set :option, CommandParser::HELP
70
60
 
71
- DONE = {
72
- :name => 'done',
73
- :large => '--done',
74
- :description => 'Show services in DONE state'
75
- }
76
-
77
61
  ARGS = {
78
62
  :name => 'args',
79
63
  :large => '--args arg1,arg2',
@@ -127,7 +111,7 @@ CommandParser::CmdParser.new(ARGV) do
127
111
  List the available services
128
112
  EOT
129
113
 
130
- command :list, list_desc, :options => [Service::JSON_FORMAT, DONE] do
114
+ command :list, list_desc, :options => OpenNebulaHelper::FORMAT do
131
115
  helper.list_service_pool(helper.client(options), options)
132
116
  end
133
117
 
@@ -137,7 +121,7 @@ CommandParser::CmdParser.new(ARGV) do
137
121
  Top the available services
138
122
  EOT
139
123
 
140
- command :top, top_desc, :options => [CLIHelper::DELAY, DONE] do
124
+ command :top, top_desc, :options => [CLIHelper::DELAY] do
141
125
  Signal.trap('INT') { exit(-1) }
142
126
 
143
127
  helper.top_service_pool(helper.client(options), options)
@@ -151,7 +135,10 @@ CommandParser::CmdParser.new(ARGV) do
151
135
  Show detailed information of a given service
152
136
  EOT
153
137
 
154
- 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
155
142
  helper.format_resource(helper.client(options), args[0], options)
156
143
  end
157
144
 
@@ -359,4 +346,75 @@ CommandParser::CmdParser.new(ARGV) do
359
346
  client.post("#{RESOURCE_PATH}/#{service_id}/action", json)
360
347
  end
361
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
362
420
  end
data/bin/oneflow-template 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
  GEMS_LOCATION = ONE_LOCATION + '/share/gems'
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 << ONEFLOW_LOCATION
@@ -90,6 +79,20 @@ CommandParser::CmdParser.new(ARGV) do
90
79
  :description => 'Clone the template recursively (just templates)'
91
80
  }
92
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
+
93
96
  usage '`oneflow-template` <command> [<args>] [<options>]'
94
97
  version OpenNebulaHelper::ONE_VERSION
95
98
 
@@ -127,7 +130,7 @@ CommandParser::CmdParser.new(ARGV) do
127
130
  List the available Service Templates
128
131
  EOT
129
132
 
130
- command :list, list_desc, :options => Service::JSON_FORMAT do
133
+ command :list, list_desc, :options => OpenNebulaHelper::FORMAT do
131
134
  helper.list_service_template_pool(helper.client(options), options)
132
135
  end
133
136
 
@@ -155,7 +158,10 @@ CommandParser::CmdParser.new(ARGV) do
155
158
  Show detailed information of a given Service Template
156
159
  EOT
157
160
 
158
- command :show, show_desc, :templateid, :options => Service::JSON_FORMAT do
161
+ command :show,
162
+ show_desc,
163
+ :templateid,
164
+ :options => OpenNebulaHelper::FORMAT do
159
165
  helper.format_resource(helper.client(options), args[0], options)
160
166
  end
161
167
 
@@ -188,11 +194,28 @@ CommandParser::CmdParser.new(ARGV) do
188
194
  Delete a given Service Template
189
195
  EOT
190
196
 
191
- 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
192
201
  client = helper.client(options)
193
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
+
194
217
  Service.perform_actions(args[0]) do |template_id|
195
- client.delete("#{RESOURCE_PATH}/#{template_id}")
218
+ client.delete("#{RESOURCE_PATH}/#{template_id}", body.to_json)
196
219
  end
197
220
  end
198
221
 
@@ -202,26 +225,26 @@ CommandParser::CmdParser.new(ARGV) do
202
225
  Instantiate a Service Template
203
226
  EOT
204
227
 
205
- command :instantiate, instantiate_desc, :templateid, [:file, nil],
228
+ command :instantiate,
229
+ instantiate_desc,
230
+ :templateid,
231
+ [:file, nil],
206
232
  :options => [MULTIPLE, Service::JSON_FORMAT, Service::TOP] do
207
233
  number = options[:multiple] || 1
208
234
  params = {}
209
235
  rc = 0
210
- client = helper.client(options)
211
236
 
212
237
  number.times do
213
238
  params['merge_template'] = nil
214
239
  params['merge_template'] = JSON.parse(File.read(args[1])) if args[1]
215
240
 
216
241
  unless params['merge_template']
217
- response = client.get("#{RESOURCE_PATH}/#{args[0]}")
218
-
219
- if CloudClient.is_error?(response)
220
- rc = [response.code.to_i, response.to_s]
221
- break
222
- end
242
+ service_template = OpenNebula::ServiceTemplate
243
+ .new_with_id(args[0],
244
+ OpenNebula::Client.new)
245
+ service_template.info
223
246
 
224
- body = JSON.parse(response.body)['DOCUMENT']['TEMPLATE']['BODY']
247
+ body = JSON.parse(service_template['/DOCUMENT/TEMPLATE/BODY'])
225
248
 
226
249
  params['merge_template'] = helper.custom_attrs(
227
250
  body['custom_attrs']
@@ -234,6 +257,7 @@ CommandParser::CmdParser.new(ARGV) do
234
257
  end
235
258
 
236
259
  json = Service.build_json_action('instantiate', params)
260
+ client = helper.client(options)
237
261
  response = client.post("#{RESOURCE_PATH}/#{args[0]}/action", json)
238
262
 
239
263
  if CloudClient.is_error?(response)
data/bin/onegroup 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
 
@@ -180,7 +169,7 @@ CommandParser::CmdParser.new(ARGV) do
180
169
  EOT
181
170
 
182
171
  command :show, show_desc, [:groupid, nil],
183
- :options => OpenNebulaHelper::XML do
172
+ :options => OpenNebulaHelper::FORMAT do
184
173
  group = args[0] || OpenNebula::Group::SELF
185
174
  helper.show_resource(group, options)
186
175
  end
data/bin/onehook 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'
@@ -147,8 +136,8 @@ CommandParser::CmdParser.new(ARGV) do
147
136
  ########################################################################
148
137
  set :option, CommandParser::OPTIONS + OpenNebulaHelper::CLIENT_OPTIONS
149
138
 
150
- list_options = CLIHelper::OPTIONS
151
- list_options << OpenNebulaHelper::XML
139
+ list_options = CLIHelper::OPTIONS
140
+ list_options += OpenNebulaHelper::FORMAT
152
141
  list_options << OpenNebulaHelper::NUMERIC
153
142
  list_options << OpenNebulaHelper::DESCRIBE
154
143
 
@@ -242,7 +231,7 @@ CommandParser::CmdParser.new(ARGV) do
242
231
  EOT
243
232
 
244
233
  command :show, show_desc, :hookid,
245
- :options => [OpenNebulaHelper::XML, OpenNebulaHelper::EXTENDED,
234
+ :options => [OpenNebulaHelper::FORMAT, OpenNebulaHelper::EXTENDED,
246
235
  EXECUTION] do
247
236
  helper.show_resource(args[0], options)
248
237
  end