opennebula-cli 5.12.10 → 5.13.80.pre
Sign up to get free protection for your applications and to get access to all the features.
- 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 +8 -5
- data/bin/oneimage +99 -8
- data/bin/onemarket +10 -7
- data/bin/onemarketapp +117 -10
- data/bin/onesecgroup +13 -7
- data/bin/oneshowback +18 -10
- data/bin/onetemplate +12 -8
- data/bin/oneuser +30 -7
- data/bin/onevcenter +10 -18
- data/bin/onevdc +10 -7
- data/bin/onevm +146 -11
- data/bin/onevmgroup +13 -7
- data/bin/onevnet +8 -5
- data/bin/onevntemplate +11 -7
- data/bin/onevrouter +10 -7
- data/bin/onezone +10 -7
- data/lib/cli_helper.rb +4 -6
- data/lib/command_parser.rb +1 -1
- 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 +7 -7
- data/lib/one_helper/onemarket_helper.rb +1 -1
- data/lib/one_helper/onemarketapp_helper.rb +494 -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 +12 -1
- data/lib/one_helper.rb +398 -37
- 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 +49 -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/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 +68 -7
- data/lib/one_helper/oneprovision_helper.rb +0 -362
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
|
@@ -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
|
@@ -42,6 +45,9 @@ require 'one_helper/onemarketapp_helper'
|
|
42
45
|
require 'one_helper/onemarket_helper'
|
43
46
|
require 'one_helper/onedatastore_helper'
|
44
47
|
|
48
|
+
require 'vcenter_driver'
|
49
|
+
CONFIG = VCenterConf.new
|
50
|
+
|
45
51
|
CommandParser::CmdParser.new(ARGV) do
|
46
52
|
usage '`onemarket` <command> [<args>] [<options>]'
|
47
53
|
version OpenNebulaHelper::ONE_VERSION
|
@@ -83,20 +89,56 @@ CommandParser::CmdParser.new(ARGV) do
|
|
83
89
|
:description => 'DockerHub image tag (default latest)'
|
84
90
|
}
|
85
91
|
|
92
|
+
YES = {
|
93
|
+
:name => 'yes',
|
94
|
+
:large => '--yes',
|
95
|
+
:description => 'Import associated VM templates/images',
|
96
|
+
:proc => lambda do |_, options|
|
97
|
+
options[:yes] = 'yes'
|
98
|
+
end
|
99
|
+
}
|
100
|
+
|
101
|
+
NO = {
|
102
|
+
:name => 'no',
|
103
|
+
:large => '--no',
|
104
|
+
:description => 'Do not import/export associated VM templates/images',
|
105
|
+
:proc => lambda do |_, options|
|
106
|
+
options[:no] = 'no'
|
107
|
+
end
|
108
|
+
}
|
109
|
+
|
110
|
+
TEMPLATE = {
|
111
|
+
:name => 'template',
|
112
|
+
:large => '--template template_id ',
|
113
|
+
:description => 'Associate with VM template',
|
114
|
+
:format => Integer
|
115
|
+
}
|
116
|
+
|
117
|
+
MARKET = {
|
118
|
+
:name => 'market',
|
119
|
+
:large => '--market market_id',
|
120
|
+
:format => Integer,
|
121
|
+
:description => 'Market to import all objects'
|
122
|
+
}
|
123
|
+
|
86
124
|
########################################################################
|
87
125
|
# Global Options
|
88
126
|
########################################################################
|
89
127
|
set :option, CommandParser::OPTIONS + OpenNebulaHelper::CLIENT_OPTIONS
|
90
128
|
|
91
|
-
list_options
|
92
|
-
list_options
|
129
|
+
list_options = CLIHelper::OPTIONS
|
130
|
+
list_options += OpenNebulaHelper::FORMAT
|
93
131
|
list_options << OpenNebulaHelper::NUMERIC
|
94
132
|
list_options << OpenNebulaHelper::DESCRIBE
|
95
133
|
|
96
134
|
CREATE_OPTIONS = [OneMarketPlaceHelper::MARKETPLACE]
|
97
135
|
EXPORT_OPTIONS = [OneDatastoreHelper::DATASTORE,
|
136
|
+
OneDatastoreHelper::FILE_DATASTORE,
|
98
137
|
OneMarketPlaceAppHelper::VMNAME,
|
99
|
-
TAG
|
138
|
+
TAG,
|
139
|
+
NO,
|
140
|
+
TEMPLATE]
|
141
|
+
IMPORT_OPTIONS = [YES, NO, MARKET, OneMarketPlaceAppHelper::VMNAME]
|
100
142
|
|
101
143
|
########################################################################
|
102
144
|
# Formatters for arguments
|
@@ -175,6 +217,60 @@ CommandParser::CmdParser.new(ARGV) do
|
|
175
217
|
end
|
176
218
|
end
|
177
219
|
|
220
|
+
import_desc = <<-EOT.unindent
|
221
|
+
Imports a service template into the marketplace
|
222
|
+
EOT
|
223
|
+
|
224
|
+
command [:'service-template', :import],
|
225
|
+
import_desc,
|
226
|
+
:service_template_id,
|
227
|
+
:options => IMPORT_OPTIONS do
|
228
|
+
helper.import(args[0], ServiceTemplate) do |id|
|
229
|
+
helper.import_service_template(id, options)
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
vm_import_desc = <<-EOT.unindent
|
234
|
+
Imports a VM template into the marketplace
|
235
|
+
EOT
|
236
|
+
|
237
|
+
command [:'vm-template', :import],
|
238
|
+
vm_import_desc,
|
239
|
+
:vm_template_id,
|
240
|
+
:options => IMPORT_OPTIONS do
|
241
|
+
helper.import(args[0], TemplatePool) do |id|
|
242
|
+
helper.import_vm_template(id, options)
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
vm_import_desc = <<-EOT.unindent
|
247
|
+
Imports a VM into the marketplace
|
248
|
+
EOT
|
249
|
+
|
250
|
+
command [:vm, :import],
|
251
|
+
vm_import_desc,
|
252
|
+
:vm_id,
|
253
|
+
:options => IMPORT_OPTIONS do
|
254
|
+
t_id = helper.save_as_template(
|
255
|
+
helper.get_obj_id(args[0], VirtualMachinePool)
|
256
|
+
)
|
257
|
+
|
258
|
+
if OpenNebula.is_error?(t_id)
|
259
|
+
STDERR.puts t_id.message
|
260
|
+
exit(-1)
|
261
|
+
else
|
262
|
+
helper.import(t_id, TemplatePool) do |id|
|
263
|
+
helper.import_vm_template(id, options)
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
puts
|
268
|
+
puts 'To delete saved template use: ' \
|
269
|
+
"`onetemplate delete #{t_id} --recursive`"
|
270
|
+
|
271
|
+
0
|
272
|
+
end
|
273
|
+
|
178
274
|
export_desc = <<-EOT.unindent
|
179
275
|
Exports the marketplace app to the OpenNebula cloud
|
180
276
|
EOT
|
@@ -183,20 +279,31 @@ CommandParser::CmdParser.new(ARGV) do
|
|
183
279
|
helper.perform_action(args[0], options, 'exported') do |obj|
|
184
280
|
tag ="tag=#{options[:tag]}" if options[:tag]
|
185
281
|
|
282
|
+
obj.extend(MarketPlaceAppExt)
|
283
|
+
|
186
284
|
rc = obj.export(
|
187
285
|
:dsid => options[:datastore],
|
188
286
|
:name => args[1],
|
189
287
|
:vmtemplate_name => options[:vmname],
|
190
|
-
:url_args => tag
|
288
|
+
:url_args => tag,
|
289
|
+
:notemplate => options[:no] == 'no',
|
290
|
+
:template => options[:template],
|
291
|
+
:default_template => CONFIG[:default_template]
|
191
292
|
)
|
192
293
|
|
193
|
-
|
294
|
+
if OpenNebula.is_error?(rc)
|
295
|
+
STDERR.puts rc.message
|
296
|
+
exit(-1)
|
297
|
+
end
|
194
298
|
|
195
299
|
rc.each do |key, value|
|
300
|
+
next if value.nil? || value.empty? || key == :image_type
|
301
|
+
|
196
302
|
puts key.to_s.upcase
|
197
303
|
value.each do |id|
|
198
304
|
if OpenNebula.is_error?(id)
|
199
305
|
puts id.to_str
|
306
|
+
exit(-1)
|
200
307
|
else
|
201
308
|
puts " ID: #{id}"
|
202
309
|
end
|
@@ -300,7 +407,7 @@ CommandParser::CmdParser.new(ARGV) do
|
|
300
407
|
Shows information for the given marketplace app
|
301
408
|
EOT
|
302
409
|
|
303
|
-
command :show, show_desc, :appid, :options => OpenNebulaHelper::
|
410
|
+
command :show, show_desc, :appid, :options => OpenNebulaHelper::FORMAT do
|
304
411
|
helper.show_resource(args[0], options)
|
305
412
|
end
|
306
413
|
|
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
|