opennebula-cli 5.12.7 → 6.0.0
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.
- checksums.yaml +4 -4
- data/bin/oneacct +9 -4
- data/bin/oneacl +8 -5
- data/bin/onecluster +10 -7
- data/bin/onedatastore +10 -7
- data/bin/oneflow +85 -13
- data/bin/oneflow-template +45 -8
- data/bin/onegroup +10 -7
- data/bin/onehook +10 -7
- data/bin/onehost +10 -7
- data/bin/oneimage +100 -9
- data/bin/onemarket +10 -7
- data/bin/onemarketapp +114 -11
- data/bin/onesecgroup +13 -7
- data/bin/oneshowback +18 -10
- data/bin/onetemplate +12 -8
- data/bin/oneuser +30 -7
- data/bin/onevcenter +16 -8
- data/bin/onevdc +10 -7
- data/bin/onevm +147 -12
- data/bin/onevmgroup +13 -7
- data/bin/onevnet +8 -5
- data/bin/onevntemplate +11 -7
- data/bin/onevrouter +10 -7
- data/bin/onezone +11 -8
- data/lib/cli_helper.rb +17 -8
- data/lib/command_parser.rb +1 -1
- data/lib/one_helper.rb +398 -37
- data/lib/one_helper/oneacct_helper.rb +8 -17
- data/lib/one_helper/oneacl_helper.rb +1 -1
- data/lib/one_helper/onecluster_helper.rb +1 -1
- data/lib/one_helper/onedatastore_helper.rb +11 -1
- data/lib/one_helper/oneflow_helper.rb +20 -5
- data/lib/one_helper/oneflowtemplate_helper.rb +28 -2
- data/lib/one_helper/onegroup_helper.rb +1 -1
- data/lib/one_helper/onehook_helper.rb +1 -1
- data/lib/one_helper/onehost_helper.rb +1 -5
- data/lib/one_helper/oneimage_helper.rb +13 -7
- data/lib/one_helper/onemarket_helper.rb +1 -1
- data/lib/one_helper/onemarketapp_helper.rb +500 -96
- data/lib/one_helper/onequota_helper.rb +1 -1
- data/lib/one_helper/onesecgroup_helper.rb +1 -1
- data/lib/one_helper/onetemplate_helper.rb +12 -1
- data/lib/one_helper/oneuser_helper.rb +11 -3
- data/lib/one_helper/onevcenter_helper.rb +176 -146
- data/lib/one_helper/onevdc_helper.rb +1 -1
- data/lib/one_helper/onevm_helper.rb +4 -3
- data/lib/one_helper/onevmgroup_helper.rb +1 -1
- data/lib/one_helper/onevnet_helper.rb +1 -1
- data/lib/one_helper/onevntemplate_helper.rb +1 -1
- data/lib/one_helper/onevrouter_helper.rb +1 -20
- data/lib/one_helper/onezone_helper.rb +24 -17
- data/share/schemas/xsd/acct.xsd +179 -0
- data/share/schemas/xsd/acl_pool.xsd +22 -0
- data/share/schemas/xsd/api_info.xsd +43 -0
- data/share/schemas/xsd/cluster.xsd +34 -0
- data/share/schemas/xsd/cluster_pool.xsd +12 -0
- data/share/schemas/xsd/datastore.xsd +67 -0
- data/share/schemas/xsd/datastore_pool.xsd +12 -0
- data/share/schemas/xsd/document.xsd +42 -0
- data/share/schemas/xsd/document_pool.xsd +12 -0
- data/share/schemas/xsd/group.xsd +179 -0
- data/share/schemas/xsd/group_pool.xsd +194 -0
- data/share/schemas/xsd/hook.xsd +59 -0
- data/share/schemas/xsd/hook_message_api.xsd +14 -0
- data/share/schemas/xsd/hook_message_retry.xsd +12 -0
- data/share/schemas/xsd/hook_message_state.xsd +25 -0
- data/share/schemas/xsd/hook_pool.xsd +12 -0
- data/share/schemas/xsd/host.xsd +164 -0
- data/share/schemas/xsd/host_pool.xsd +12 -0
- data/share/schemas/xsd/image.xsd +123 -0
- data/share/schemas/xsd/image_pool.xsd +12 -0
- data/share/schemas/xsd/index.xsd +50 -0
- data/share/schemas/xsd/marketplace.xsd +44 -0
- data/share/schemas/xsd/marketplace_pool.xsd +12 -0
- data/share/schemas/xsd/marketplaceapp.xsd +56 -0
- data/share/schemas/xsd/marketplaceapp_pool.xsd +12 -0
- data/share/schemas/xsd/monitoring_data.xsd +41 -0
- data/share/schemas/xsd/opennebula_configuration.xsd +412 -0
- data/share/schemas/xsd/raftstatus.xsd +18 -0
- data/share/schemas/xsd/security_group.xsd +74 -0
- data/share/schemas/xsd/security_group_pool.xsd +12 -0
- data/share/schemas/xsd/showback.xsd +29 -0
- data/share/schemas/xsd/user.xsd +186 -0
- data/share/schemas/xsd/user_pool.xsd +201 -0
- data/share/schemas/xsd/vdc.xsd +76 -0
- data/share/schemas/xsd/vdc_pool.xsd +12 -0
- data/share/schemas/xsd/vm.xsd +251 -0
- data/share/schemas/xsd/vm_group.xsd +59 -0
- data/share/schemas/xsd/vm_group_pool.xsd +12 -0
- data/share/schemas/xsd/vm_pool.xsd +114 -0
- data/share/schemas/xsd/vmtemplate.xsd +52 -0
- data/share/schemas/xsd/vmtemplate_pool.xsd +12 -0
- data/share/schemas/xsd/vnet.xsd +137 -0
- data/share/schemas/xsd/vnet_pool.xsd +85 -0
- data/share/schemas/xsd/vntemplate.xsd +50 -0
- data/share/schemas/xsd/vntemplate_pool.xsd +12 -0
- data/share/schemas/xsd/vrouter.xsd +49 -0
- data/share/schemas/xsd/vrouter_pool.xsd +12 -0
- data/share/schemas/xsd/zone.xsd +40 -0
- data/share/schemas/xsd/zone_pool.xsd +36 -0
- metadata +79 -17
- data/lib/one_helper/oneprovision_helper.rb +0 -362
data/bin/onesecgroup
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
3
|
# -------------------------------------------------------------------------- #
|
|
4
|
-
# Copyright 2002-
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
|
57
|
-
list_options
|
|
59
|
+
list_options = CLIHelper::OPTIONS
|
|
60
|
+
list_options += OpenNebulaHelper::FORMAT
|
|
58
61
|
list_options << OpenNebulaHelper::NUMERIC
|
|
59
62
|
list_options << OpenNebulaHelper::DESCRIBE
|
|
60
63
|
|
|
@@ -221,7 +224,10 @@ CommandParser::CmdParser.new(ARGV) do
|
|
|
221
224
|
Shows information for the given Security Group
|
|
222
225
|
EOT
|
|
223
226
|
|
|
224
|
-
command :show,
|
|
227
|
+
command :show,
|
|
228
|
+
show_desc,
|
|
229
|
+
:secgroupid,
|
|
230
|
+
:options => OpenNebulaHelper::FORMAT do
|
|
225
231
|
helper.show_resource(args[0], options)
|
|
226
232
|
end
|
|
227
233
|
end
|
data/bin/oneshowback
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
3
|
# -------------------------------------------------------------------------- #
|
|
4
|
-
# Copyright 2002-
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
|
@@ -92,27 +95,31 @@ CommandParser::CmdParser.new(ARGV) do
|
|
|
92
95
|
|
|
93
96
|
pool = OpenNebula::VirtualMachinePool.new(helper.client)
|
|
94
97
|
|
|
95
|
-
if options[:json] || options[:xml]
|
|
98
|
+
if options[:json] || options[:xml] || options[:yaml]
|
|
96
99
|
xml_str = pool.showback_xml(filter_flag, common_opts)
|
|
97
100
|
if OpenNebula.is_error?(xml_str)
|
|
98
101
|
puts xml_str.message
|
|
99
102
|
exit(-1)
|
|
100
103
|
end
|
|
101
104
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
xmldoc.initialize_xml(xml_str, 'SHOWBACK_RECORDS')
|
|
105
|
+
xmldoc = XMLElement.new
|
|
106
|
+
xmldoc.initialize_xml(xml_str, 'SHOWBACK_RECORDS')
|
|
105
107
|
|
|
108
|
+
if options[:json]
|
|
106
109
|
puts JSON.pretty_generate(xmldoc.to_hash)
|
|
110
|
+
elsif options[:yaml]
|
|
111
|
+
puts xmldoc.to_hash.to_yaml(:indent => 4)
|
|
107
112
|
elsif options[:xml]
|
|
108
113
|
puts xml_str
|
|
109
114
|
end
|
|
110
115
|
else
|
|
116
|
+
# rubocop:disable Naming/VariableNumber
|
|
111
117
|
order_by = {}
|
|
112
118
|
if !options[:csv]
|
|
113
119
|
order_by[:order_by_1] = 'YEAR'
|
|
114
120
|
order_by[:order_by_2] = 'MONTH'
|
|
115
121
|
end
|
|
122
|
+
# rubocop:enable Naming/VariableNumber
|
|
116
123
|
|
|
117
124
|
data_hash = pool.showback(filter_flag,
|
|
118
125
|
common_opts.merge(order_by))
|
|
@@ -172,8 +179,9 @@ CommandParser::CmdParser.new(ARGV) do
|
|
|
172
179
|
end_year)
|
|
173
180
|
|
|
174
181
|
if OpenNebula.is_error?(rc)
|
|
175
|
-
if rc.message.include?
|
|
176
|
-
warn
|
|
182
|
+
if rc.message.include? 'ReadTimeout'
|
|
183
|
+
warn 'Showback calculation takes too long, '\
|
|
184
|
+
'continuing in background'
|
|
177
185
|
exit_code 0
|
|
178
186
|
else
|
|
179
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-
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
|
82
|
-
list_options
|
|
84
|
+
list_options = CLIHelper::OPTIONS
|
|
85
|
+
list_options += OpenNebulaHelper::FORMAT
|
|
83
86
|
list_options << OpenNebulaHelper::NUMERIC
|
|
84
87
|
list_options << OpenNebulaHelper::DESCRIBE
|
|
85
88
|
|
|
@@ -263,7 +266,7 @@ CommandParser::CmdParser.new(ARGV) do
|
|
|
263
266
|
else
|
|
264
267
|
optionals = OneTemplateHelper.get_user_inputs(
|
|
265
268
|
t.to_hash,
|
|
266
|
-
options[:user_inputs_keys]
|
|
269
|
+
options[:user_inputs_keys]
|
|
267
270
|
)
|
|
268
271
|
|
|
269
272
|
user_inputs = user_inputs + "\n" + optionals
|
|
@@ -369,7 +372,8 @@ CommandParser::CmdParser.new(ARGV) do
|
|
|
369
372
|
EOT
|
|
370
373
|
|
|
371
374
|
command :show, show_desc, :templateid,
|
|
372
|
-
:options => [OpenNebulaHelper::
|
|
375
|
+
:options => [OpenNebulaHelper::FORMAT,
|
|
376
|
+
OneTemplateHelper::EXTENDED] do
|
|
373
377
|
helper.show_resource(args[0], options)
|
|
374
378
|
end
|
|
375
379
|
|
data/bin/oneuser
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
3
|
# -------------------------------------------------------------------------- #
|
|
4
|
-
# Copyright 2002-
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
|
72
|
-
list_options
|
|
74
|
+
list_options = CLIHelper::OPTIONS
|
|
75
|
+
list_options += OpenNebulaHelper::FORMAT
|
|
73
76
|
list_options << OpenNebulaHelper::NUMERIC
|
|
74
77
|
list_options << OpenNebulaHelper::DESCRIBE
|
|
75
78
|
|
|
@@ -559,7 +562,7 @@ CommandParser::CmdParser.new(ARGV) do
|
|
|
559
562
|
EOT
|
|
560
563
|
|
|
561
564
|
command :show, show_desc, [:userid, nil],
|
|
562
|
-
:options => OpenNebulaHelper::
|
|
565
|
+
:options => OpenNebulaHelper::FORMAT do
|
|
563
566
|
user = args[0] || OpenNebula::User::SELF
|
|
564
567
|
helper.show_resource(user, options)
|
|
565
568
|
end
|
|
@@ -801,4 +804,24 @@ CommandParser::CmdParser.new(ARGV) do
|
|
|
801
804
|
user.login(username, '', 0)
|
|
802
805
|
end
|
|
803
806
|
end
|
|
807
|
+
|
|
808
|
+
enable_desc = <<-EOT.unindent
|
|
809
|
+
Enables the given User
|
|
810
|
+
EOT
|
|
811
|
+
|
|
812
|
+
command :enable, enable_desc, [:range, :userid_list] do
|
|
813
|
+
helper.perform_actions(args[0], options, 'enabled') do |user|
|
|
814
|
+
user.enable
|
|
815
|
+
end
|
|
816
|
+
end
|
|
817
|
+
|
|
818
|
+
disable_desc = <<-EOT.unindent
|
|
819
|
+
Disables the given User
|
|
820
|
+
EOT
|
|
821
|
+
|
|
822
|
+
command :disable, disable_desc, [:range, :userid_list] do
|
|
823
|
+
helper.perform_actions(args[0], options, 'disabled') do |user|
|
|
824
|
+
user.disable
|
|
825
|
+
end
|
|
826
|
+
end
|
|
804
827
|
end
|
data/bin/onevcenter
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
3
|
# -------------------------------------------------------------------------- #
|
|
4
|
-
# Copyright 2002-
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
|
@@ -236,7 +239,7 @@ CommandParser::CmdParser.new(ARGV) do
|
|
|
236
239
|
" this input: #{args.first}"
|
|
237
240
|
end
|
|
238
241
|
|
|
239
|
-
importer.process_import(indexes) do |object_info|
|
|
242
|
+
importer.process_import(indexes, options) do |object_info|
|
|
240
243
|
helper.cli_dialogue(object_info)
|
|
241
244
|
end
|
|
242
245
|
|
|
@@ -257,10 +260,15 @@ CommandParser::CmdParser.new(ARGV) do
|
|
|
257
260
|
importer = VCenterDriver::VcImporter.new_child(helper.client,
|
|
258
261
|
vi_client,
|
|
259
262
|
options[:object])
|
|
260
|
-
importer.retrieve_resources(helper.parse_opts(options))
|
|
261
|
-
indexes = importer.get_indexes(args.first)
|
|
262
263
|
|
|
263
|
-
|
|
264
|
+
if options[:object] == "networks" && !args.first.nil?
|
|
265
|
+
indexes = args.first
|
|
266
|
+
else
|
|
267
|
+
importer.retrieve_resources(helper.parse_opts(options))
|
|
268
|
+
indexes = importer.get_indexes(args.first)
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
importer.process_import(indexes, options)
|
|
264
272
|
|
|
265
273
|
importer.stdout
|
|
266
274
|
rescue StandardError => e
|
data/bin/onevdc
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
3
|
# -------------------------------------------------------------------------- #
|
|
4
|
-
# Copyright 2002-
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
|
57
|
-
list_options
|
|
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::
|
|
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-
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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::
|
|
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
|
-
|
|
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.
|
|
1225
|
-
|
|
1226
|
-
|
|
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"]
|
|
@@ -1271,7 +1307,7 @@ CommandParser::CmdParser.new(ARGV) do
|
|
|
1271
1307
|
lock_desc = <<-EOT.unindent
|
|
1272
1308
|
Locks a VM with differents levels for lock any actions with this VM, show and
|
|
1273
1309
|
monitoring never will be locked.
|
|
1274
|
-
|
|
1310
|
+
Valid states are: All.
|
|
1275
1311
|
EOT
|
|
1276
1312
|
|
|
1277
1313
|
command :lock, lock_desc, :vmid,
|
|
@@ -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')
|