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/onehook
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
|
|
@@ -133,8 +136,8 @@ CommandParser::CmdParser.new(ARGV) do
|
|
|
133
136
|
########################################################################
|
|
134
137
|
set :option, CommandParser::OPTIONS + OpenNebulaHelper::CLIENT_OPTIONS
|
|
135
138
|
|
|
136
|
-
list_options
|
|
137
|
-
list_options
|
|
139
|
+
list_options = CLIHelper::OPTIONS
|
|
140
|
+
list_options += OpenNebulaHelper::FORMAT
|
|
138
141
|
list_options << OpenNebulaHelper::NUMERIC
|
|
139
142
|
list_options << OpenNebulaHelper::DESCRIBE
|
|
140
143
|
|
|
@@ -228,7 +231,7 @@ CommandParser::CmdParser.new(ARGV) do
|
|
|
228
231
|
EOT
|
|
229
232
|
|
|
230
233
|
command :show, show_desc, :hookid,
|
|
231
|
-
:options => [OpenNebulaHelper::
|
|
234
|
+
:options => [OpenNebulaHelper::FORMAT, OpenNebulaHelper::EXTENDED,
|
|
232
235
|
EXECUTION] do
|
|
233
236
|
helper.show_resource(args[0], options)
|
|
234
237
|
end
|
data/bin/onehost
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
|
|
@@ -168,8 +171,8 @@ CommandParser::CmdParser.new(ARGV) do
|
|
|
168
171
|
[:file, nil], :options => CREAT_OPTIONS do
|
|
169
172
|
if options[:im].nil? || options[:vm].nil?
|
|
170
173
|
STDERR.puts 'Drivers are mandatory to create a host:'
|
|
171
|
-
STDERR.puts
|
|
172
|
-
STDERR.puts
|
|
174
|
+
STDERR.puts "\t -i information driver"
|
|
175
|
+
STDERR.puts "\t -v hypervisor driver"
|
|
173
176
|
exit(-1)
|
|
174
177
|
end
|
|
175
178
|
|
|
@@ -283,7 +286,7 @@ CommandParser::CmdParser.new(ARGV) do
|
|
|
283
286
|
EOT
|
|
284
287
|
|
|
285
288
|
command :show, show_desc, :hostid,
|
|
286
|
-
:options => [OpenNebulaHelper::
|
|
289
|
+
:options => [OpenNebulaHelper::FORMAT, OpenNebulaHelper::DECRYPT] do
|
|
287
290
|
helper.show_resource(args[0], options)
|
|
288
291
|
end
|
|
289
292
|
|
data/bin/oneimage
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,14 +27,18 @@ 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
|
|
36
39
|
$LOAD_PATH << RUBY_LIB_LOCATION + '/cli'
|
|
37
40
|
|
|
41
|
+
require 'tempfile'
|
|
38
42
|
require 'command_parser'
|
|
39
43
|
require 'one_helper/oneimage_helper'
|
|
40
44
|
require 'one_helper/onedatastore_helper'
|
|
@@ -73,17 +77,25 @@ CommandParser::CmdParser.new(ARGV) do
|
|
|
73
77
|
:description => 'lock all actions'
|
|
74
78
|
}
|
|
75
79
|
|
|
80
|
+
NO_CONTEXT = {
|
|
81
|
+
:name => 'no_context',
|
|
82
|
+
:large => '--no-context',
|
|
83
|
+
:description => 'Do not add context when building from Dockerfile'
|
|
84
|
+
}
|
|
85
|
+
|
|
76
86
|
########################################################################
|
|
77
87
|
# Global Options
|
|
78
88
|
########################################################################
|
|
79
89
|
set :option, CommandParser::OPTIONS + OpenNebulaHelper::CLIENT_OPTIONS
|
|
80
90
|
|
|
81
|
-
list_options
|
|
82
|
-
list_options
|
|
91
|
+
list_options = CLIHelper::OPTIONS
|
|
92
|
+
list_options += OpenNebulaHelper::FORMAT
|
|
83
93
|
list_options << OpenNebulaHelper::NUMERIC
|
|
84
94
|
list_options << OpenNebulaHelper::DESCRIBE
|
|
85
95
|
|
|
86
|
-
CREATE_OPTIONS = [OneDatastoreHelper::DATASTORE,
|
|
96
|
+
CREATE_OPTIONS = [OneDatastoreHelper::DATASTORE,
|
|
97
|
+
OneImageHelper::IMAGE,
|
|
98
|
+
NO_CONTEXT]
|
|
87
99
|
|
|
88
100
|
########################################################################
|
|
89
101
|
# Formatters for arguments
|
|
@@ -152,7 +164,7 @@ CommandParser::CmdParser.new(ARGV) do
|
|
|
152
164
|
:options => CREATE_OPTIONS + OneImageHelper::TEMPLATE_OPTIONS do
|
|
153
165
|
if options[:datastore].nil? && !options[:dry]
|
|
154
166
|
STDERR.puts 'Datastore to save the image is mandatory: '
|
|
155
|
-
STDERR.puts
|
|
167
|
+
STDERR.puts "\t -d datastore_id"
|
|
156
168
|
exit(-1)
|
|
157
169
|
end
|
|
158
170
|
|
|
@@ -168,6 +180,15 @@ CommandParser::CmdParser.new(ARGV) do
|
|
|
168
180
|
next -1
|
|
169
181
|
end
|
|
170
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
|
+
|
|
171
192
|
helper.create_resource(options) do |image|
|
|
172
193
|
begin
|
|
173
194
|
if args[0]
|
|
@@ -390,7 +411,8 @@ CommandParser::CmdParser.new(ARGV) do
|
|
|
390
411
|
Shows information for the given Image
|
|
391
412
|
EOT
|
|
392
413
|
|
|
393
|
-
command :show, show_desc, :imageid,
|
|
414
|
+
command :show, show_desc, :imageid,
|
|
415
|
+
:options => [OpenNebulaHelper::FORMAT, OpenNebulaHelper::DECRYPT] do
|
|
394
416
|
helper.show_resource(args[0], options)
|
|
395
417
|
end
|
|
396
418
|
|
|
@@ -450,4 +472,73 @@ CommandParser::CmdParser.new(ARGV) do
|
|
|
450
472
|
|
|
451
473
|
return 0
|
|
452
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
|
|
453
544
|
end
|
data/bin/onemarket
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
|
|
|
@@ -154,7 +157,7 @@ CommandParser::CmdParser.new(ARGV) do
|
|
|
154
157
|
EOT
|
|
155
158
|
|
|
156
159
|
command :show, show_desc,
|
|
157
|
-
:marketplaceid, :options => OpenNebulaHelper::
|
|
160
|
+
:marketplaceid, :options => OpenNebulaHelper::FORMAT do
|
|
158
161
|
helper.show_resource(args[0], options)
|
|
159
162
|
end
|
|
160
163
|
|
data/bin/onemarketapp
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
|
|
@@ -83,20 +86,56 @@ CommandParser::CmdParser.new(ARGV) do
|
|
|
83
86
|
:description => 'DockerHub image tag (default latest)'
|
|
84
87
|
}
|
|
85
88
|
|
|
89
|
+
YES = {
|
|
90
|
+
:name => 'yes',
|
|
91
|
+
:large => '--yes',
|
|
92
|
+
:description => 'Import associated VM templates/images',
|
|
93
|
+
:proc => lambda do |_, options|
|
|
94
|
+
options[:yes] = 'yes'
|
|
95
|
+
end
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
NO = {
|
|
99
|
+
:name => 'no',
|
|
100
|
+
:large => '--no',
|
|
101
|
+
:description => 'Do not import/export associated VM templates/images',
|
|
102
|
+
:proc => lambda do |_, options|
|
|
103
|
+
options[:no] = 'no'
|
|
104
|
+
end
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
TEMPLATE = {
|
|
108
|
+
:name => 'template',
|
|
109
|
+
:large => '--template template_id ',
|
|
110
|
+
:description => 'Associate with VM template',
|
|
111
|
+
:format => Integer
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
MARKET = {
|
|
115
|
+
:name => 'market',
|
|
116
|
+
:large => '--market market_id',
|
|
117
|
+
:format => Integer,
|
|
118
|
+
:description => 'Market to import all objects'
|
|
119
|
+
}
|
|
120
|
+
|
|
86
121
|
########################################################################
|
|
87
122
|
# Global Options
|
|
88
123
|
########################################################################
|
|
89
124
|
set :option, CommandParser::OPTIONS + OpenNebulaHelper::CLIENT_OPTIONS
|
|
90
125
|
|
|
91
|
-
list_options
|
|
92
|
-
list_options
|
|
126
|
+
list_options = CLIHelper::OPTIONS
|
|
127
|
+
list_options += OpenNebulaHelper::FORMAT
|
|
93
128
|
list_options << OpenNebulaHelper::NUMERIC
|
|
94
129
|
list_options << OpenNebulaHelper::DESCRIBE
|
|
95
130
|
|
|
96
131
|
CREATE_OPTIONS = [OneMarketPlaceHelper::MARKETPLACE]
|
|
97
132
|
EXPORT_OPTIONS = [OneDatastoreHelper::DATASTORE,
|
|
133
|
+
OneDatastoreHelper::FILE_DATASTORE,
|
|
98
134
|
OneMarketPlaceAppHelper::VMNAME,
|
|
99
|
-
TAG
|
|
135
|
+
TAG,
|
|
136
|
+
NO,
|
|
137
|
+
TEMPLATE]
|
|
138
|
+
IMPORT_OPTIONS = [YES, NO, MARKET, OneMarketPlaceAppHelper::VMNAME]
|
|
100
139
|
|
|
101
140
|
########################################################################
|
|
102
141
|
# Formatters for arguments
|
|
@@ -135,7 +174,7 @@ CommandParser::CmdParser.new(ARGV) do
|
|
|
135
174
|
OneMarketPlaceAppHelper::TEMPLATE_OPTIONS do
|
|
136
175
|
if options[:marketplace].nil?
|
|
137
176
|
STDERR.puts 'Marketplace to save the app is mandatory: '
|
|
138
|
-
STDERR.puts
|
|
177
|
+
STDERR.puts "\t -m marketplace_id"
|
|
139
178
|
exit(-1)
|
|
140
179
|
end
|
|
141
180
|
|
|
@@ -175,6 +214,60 @@ CommandParser::CmdParser.new(ARGV) do
|
|
|
175
214
|
end
|
|
176
215
|
end
|
|
177
216
|
|
|
217
|
+
import_desc = <<-EOT.unindent
|
|
218
|
+
Imports a service template into the marketplace
|
|
219
|
+
EOT
|
|
220
|
+
|
|
221
|
+
command [:'service-template', :import],
|
|
222
|
+
import_desc,
|
|
223
|
+
:service_template_id,
|
|
224
|
+
:options => IMPORT_OPTIONS do
|
|
225
|
+
helper.import(args[0], ServiceTemplate) do |id|
|
|
226
|
+
helper.import_service_template(id, options)
|
|
227
|
+
end
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
vm_import_desc = <<-EOT.unindent
|
|
231
|
+
Imports a VM template into the marketplace
|
|
232
|
+
EOT
|
|
233
|
+
|
|
234
|
+
command [:'vm-template', :import],
|
|
235
|
+
vm_import_desc,
|
|
236
|
+
:vm_template_id,
|
|
237
|
+
:options => IMPORT_OPTIONS do
|
|
238
|
+
helper.import(args[0], TemplatePool) do |id|
|
|
239
|
+
helper.import_vm_template(id, options)
|
|
240
|
+
end
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
vm_import_desc = <<-EOT.unindent
|
|
244
|
+
Imports a VM into the marketplace
|
|
245
|
+
EOT
|
|
246
|
+
|
|
247
|
+
command [:vm, :import],
|
|
248
|
+
vm_import_desc,
|
|
249
|
+
:vm_id,
|
|
250
|
+
:options => IMPORT_OPTIONS do
|
|
251
|
+
t_id = helper.save_as_template(
|
|
252
|
+
helper.get_obj_id(args[0], VirtualMachinePool)
|
|
253
|
+
)
|
|
254
|
+
|
|
255
|
+
if OpenNebula.is_error?(t_id)
|
|
256
|
+
STDERR.puts t_id.message
|
|
257
|
+
exit(-1)
|
|
258
|
+
else
|
|
259
|
+
helper.import(t_id, TemplatePool) do |id|
|
|
260
|
+
helper.import_vm_template(id, options)
|
|
261
|
+
end
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
puts
|
|
265
|
+
puts 'To delete saved template use: ' \
|
|
266
|
+
"`onetemplate delete #{t_id} --recursive`"
|
|
267
|
+
|
|
268
|
+
0
|
|
269
|
+
end
|
|
270
|
+
|
|
178
271
|
export_desc = <<-EOT.unindent
|
|
179
272
|
Exports the marketplace app to the OpenNebula cloud
|
|
180
273
|
EOT
|
|
@@ -183,20 +276,30 @@ CommandParser::CmdParser.new(ARGV) do
|
|
|
183
276
|
helper.perform_action(args[0], options, 'exported') do |obj|
|
|
184
277
|
tag ="tag=#{options[:tag]}" if options[:tag]
|
|
185
278
|
|
|
279
|
+
obj.extend(MarketPlaceAppExt)
|
|
280
|
+
|
|
186
281
|
rc = obj.export(
|
|
187
282
|
:dsid => options[:datastore],
|
|
188
283
|
:name => args[1],
|
|
189
284
|
:vmtemplate_name => options[:vmname],
|
|
190
|
-
:url_args => tag
|
|
285
|
+
:url_args => tag,
|
|
286
|
+
:notemplate => options[:no] == 'no',
|
|
287
|
+
:template => options[:template]
|
|
191
288
|
)
|
|
192
289
|
|
|
193
|
-
|
|
290
|
+
if OpenNebula.is_error?(rc)
|
|
291
|
+
STDERR.puts rc.message
|
|
292
|
+
exit(-1)
|
|
293
|
+
end
|
|
194
294
|
|
|
195
295
|
rc.each do |key, value|
|
|
296
|
+
next if value.nil? || value.empty? || key == :image_type
|
|
297
|
+
|
|
196
298
|
puts key.to_s.upcase
|
|
197
299
|
value.each do |id|
|
|
198
300
|
if OpenNebula.is_error?(id)
|
|
199
301
|
puts id.to_str
|
|
302
|
+
exit(-1)
|
|
200
303
|
else
|
|
201
304
|
puts " ID: #{id}"
|
|
202
305
|
end
|
|
@@ -300,7 +403,7 @@ CommandParser::CmdParser.new(ARGV) do
|
|
|
300
403
|
Shows information for the given marketplace app
|
|
301
404
|
EOT
|
|
302
405
|
|
|
303
|
-
command :show, show_desc, :appid, :options => OpenNebulaHelper::
|
|
406
|
+
command :show, show_desc, :appid, :options => OpenNebulaHelper::FORMAT do
|
|
304
407
|
helper.show_resource(args[0], options)
|
|
305
408
|
end
|
|
306
409
|
|