opennebula-cli 6.10.2 → 6.99.85.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.
- checksums.yaml +4 -4
- data/bin/oneacct +5 -18
- data/bin/oneacl +2 -18
- data/bin/onebackupjob +2 -18
- data/bin/onecluster +36 -18
- data/bin/onedatastore +2 -18
- data/bin/oneflow +2 -18
- data/bin/oneflow-template +8 -24
- data/bin/onegroup +2 -18
- data/bin/onehook +2 -18
- data/bin/onehost +4 -48
- data/bin/oneimage +2 -18
- data/bin/oneirb +2 -61
- data/bin/onelog +3 -22
- data/bin/onemarket +2 -18
- data/bin/onemarketapp +2 -30
- data/bin/onesecgroup +2 -18
- data/bin/oneshowback +2 -18
- data/bin/onetemplate +2 -19
- data/bin/oneuser +2 -18
- data/bin/onevdc +2 -18
- data/bin/onevm +21 -19
- data/bin/onevmgroup +2 -18
- data/bin/onevnet +2 -18
- data/bin/onevntemplate +2 -18
- data/bin/onevrouter +13 -20
- data/bin/onezone +2 -18
- data/lib/cli_helper.rb +1 -1
- data/lib/command_parser.rb +1 -1
- data/lib/one_helper/oneacct_helper.rb +10 -2
- data/lib/one_helper/oneacl_helper.rb +1 -1
- data/lib/one_helper/onebackupjob_helper.rb +1 -1
- data/lib/one_helper/onecluster_helper.rb +49 -1
- data/lib/one_helper/onedatastore_helper.rb +1 -1
- data/lib/one_helper/oneflow_helper.rb +1 -1
- data/lib/one_helper/oneflowtemplate_helper.rb +17 -17
- data/lib/one_helper/onegroup_helper.rb +4 -55
- data/lib/one_helper/onehook_helper.rb +1 -1
- data/lib/one_helper/onehost_helper.rb +29 -87
- data/lib/one_helper/oneimage_helper.rb +2 -19
- data/lib/one_helper/onemarket_helper.rb +1 -1
- data/lib/one_helper/onemarketapp_helper.rb +13 -3
- data/lib/one_helper/onequota_helper.rb +35 -8
- data/lib/one_helper/onesecgroup_helper.rb +1 -1
- data/lib/one_helper/onetemplate_helper.rb +1 -8
- data/lib/one_helper/oneuser_helper.rb +41 -75
- data/lib/one_helper/onevdc_helper.rb +1 -1
- data/lib/one_helper/onevm_helper.rb +119 -102
- 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 -1
- data/lib/one_helper/onezone_helper.rb +10 -23
- data/lib/one_helper.rb +34 -156
- data/share/schemas/xsd/acct.xsd +2 -0
- data/share/schemas/xsd/cluster.xsd +21 -0
- data/share/schemas/xsd/datastore.xsd +1 -13
- data/share/schemas/xsd/group.xsd +11 -122
- data/share/schemas/xsd/group_pool.xsd +8 -120
- data/share/schemas/xsd/host.xsd +19 -21
- data/share/schemas/xsd/image.xsd +0 -1
- data/share/schemas/xsd/monitoring_data.xsd +0 -8
- data/share/schemas/xsd/opennebula_configuration.xsd +23 -1
- data/share/schemas/xsd/plan.xsd +29 -0
- data/share/schemas/xsd/requirements.xsd +45 -0
- data/share/schemas/xsd/scheduler_driver_action.xsd +24 -0
- data/share/schemas/xsd/shared.xsd +67 -0
- data/share/schemas/xsd/user.xsd +10 -122
- data/share/schemas/xsd/user_pool.xsd +8 -120
- data/share/schemas/xsd/vm.xsd +37 -28
- data/share/schemas/xsd/vm_pool.xsd +0 -12
- data/share/schemas/xsd/vm_pool_extended.xsd +12 -0
- data/share/schemas/xsd/vmtemplate.xsd +0 -3
- data/share/schemas/xsd/vnet.xsd +0 -5
- data/share/schemas/xsd/vnet_pool_extended.xsd +12 -0
- metadata +11 -9
- data/bin/onevcenter +0 -471
- data/lib/one_helper/onevcenter_helper.rb +0 -523
data/bin/onevcenter
DELETED
@@ -1,471 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# -------------------------------------------------------------------------- #
|
4
|
-
# Copyright 2002-2024, OpenNebula Project, OpenNebula Systems #
|
5
|
-
# #
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
7
|
-
# not use this file except in compliance with the License. You may obtain #
|
8
|
-
# a copy of the License at #
|
9
|
-
# #
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0 #
|
11
|
-
# #
|
12
|
-
# Unless required by applicable law or agreed to in writing, software #
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS, #
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
15
|
-
# See the License for the specific language governing permissions and #
|
16
|
-
# limitations under the License. #
|
17
|
-
#--------------------------------------------------------------------------- #
|
18
|
-
|
19
|
-
ONE_LOCATION = ENV['ONE_LOCATION']
|
20
|
-
|
21
|
-
if !ONE_LOCATION
|
22
|
-
RUBY_LIB_LOCATION = '/usr/lib/one/ruby'
|
23
|
-
GEMS_LOCATION = '/usr/share/one/gems'
|
24
|
-
REMOTES_LOCATION = '/var/lib/one/remotes/'
|
25
|
-
else
|
26
|
-
RUBY_LIB_LOCATION = ONE_LOCATION + '/lib/ruby'
|
27
|
-
GEMS_LOCATION = ONE_LOCATION + '/share/gems'
|
28
|
-
REMOTES_LOCATION = ONE_LOCATION + '/var/remotes/'
|
29
|
-
end
|
30
|
-
|
31
|
-
# %%RUBYGEMS_SETUP_BEGIN%%
|
32
|
-
if File.directory?(GEMS_LOCATION)
|
33
|
-
real_gems_path = File.realpath(GEMS_LOCATION)
|
34
|
-
if !defined?(Gem) || Gem.path != [real_gems_path]
|
35
|
-
$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
|
47
|
-
end
|
48
|
-
end
|
49
|
-
# %%RUBYGEMS_SETUP_END%%
|
50
|
-
|
51
|
-
$LOAD_PATH << RUBY_LIB_LOCATION
|
52
|
-
$LOAD_PATH << RUBY_LIB_LOCATION + '/cli'
|
53
|
-
$LOAD_PATH << REMOTES_LOCATION + 'vmm/vcenter/'
|
54
|
-
|
55
|
-
require 'command_parser'
|
56
|
-
require 'one_helper/onevcenter_helper'
|
57
|
-
require 'vcenter_driver'
|
58
|
-
|
59
|
-
CommandParser::CmdParser.new(ARGV) do
|
60
|
-
usage '`onevcenter` <command> [<args>] [<options>]'
|
61
|
-
version OpenNebulaHelper::ONE_VERSION
|
62
|
-
|
63
|
-
helper = OneVcenterHelper.new
|
64
|
-
|
65
|
-
before_proc do
|
66
|
-
helper.set_client(options)
|
67
|
-
end
|
68
|
-
|
69
|
-
############################################################################
|
70
|
-
# Authentication Options
|
71
|
-
############################################################################
|
72
|
-
|
73
|
-
VCENTER = {
|
74
|
-
:name => 'vcenter',
|
75
|
-
:large => '--vcenter vCenter',
|
76
|
-
:description => 'The vCenter hostname',
|
77
|
-
:format => String
|
78
|
-
}
|
79
|
-
|
80
|
-
USER = {
|
81
|
-
:name => 'vuser',
|
82
|
-
:large => '--vuser username',
|
83
|
-
:description => 'The username to interact with vCenter',
|
84
|
-
:format => String
|
85
|
-
}
|
86
|
-
|
87
|
-
PASS = {
|
88
|
-
:name => 'vpass',
|
89
|
-
:large => '--vpass password',
|
90
|
-
:description => 'The password for the user',
|
91
|
-
:format => String
|
92
|
-
}
|
93
|
-
|
94
|
-
PORT = {
|
95
|
-
:name => 'port',
|
96
|
-
:short => '-p port',
|
97
|
-
:large => '--port port',
|
98
|
-
:format => String,
|
99
|
-
:description => 'vCenter API port, defaults to 443 (SSL) or 80'
|
100
|
-
}
|
101
|
-
|
102
|
-
AUTH_OPTS = [VCENTER, USER, PASS, PORT]
|
103
|
-
|
104
|
-
############################################################################
|
105
|
-
# List & Import
|
106
|
-
############################################################################
|
107
|
-
|
108
|
-
OBJECT = {
|
109
|
-
:name => 'object',
|
110
|
-
:short => '-o object',
|
111
|
-
:large => '--object object ',
|
112
|
-
:format => String,
|
113
|
-
:description => 'vCenter object: [datastores, templates,'\
|
114
|
-
'networks, datastores, images, hosts]'
|
115
|
-
}
|
116
|
-
|
117
|
-
HOST = {
|
118
|
-
:name => 'host',
|
119
|
-
:short => '-h host_id',
|
120
|
-
:large => '--host host_id',
|
121
|
-
:format => String,
|
122
|
-
:description => 'OpenNebula host used to authenticate the operation'
|
123
|
-
}
|
124
|
-
|
125
|
-
DATASTORE = {
|
126
|
-
:name => 'datastore',
|
127
|
-
:short => '-d datastore_id',
|
128
|
-
:large => '--datastore datastore_id',
|
129
|
-
:format => String,
|
130
|
-
:description => 'OpenNebula datastore used'
|
131
|
-
}
|
132
|
-
|
133
|
-
CONFIG = {
|
134
|
-
:name => 'configuration',
|
135
|
-
:large => '--config file',
|
136
|
-
:format => String,
|
137
|
-
:description => 'Configuration file for custom options'
|
138
|
-
}
|
139
|
-
|
140
|
-
LINKED_CLONE = {
|
141
|
-
:name => 'linked_clone',
|
142
|
-
:large => '--linked_clone linked_clone',
|
143
|
-
:format => String,
|
144
|
-
:description => 'Import template as linked clone, 0/1'
|
145
|
-
}
|
146
|
-
|
147
|
-
COPY = {
|
148
|
-
:name => 'copy',
|
149
|
-
:large => '--copy copy',
|
150
|
-
:format => String,
|
151
|
-
:description => 'Import template as copy, 0/1'
|
152
|
-
}
|
153
|
-
|
154
|
-
NAME = {
|
155
|
-
:name => 'name',
|
156
|
-
:large => '--name name',
|
157
|
-
:format => String,
|
158
|
-
:description => 'Import template copy with name'
|
159
|
-
}
|
160
|
-
|
161
|
-
FOLDER = {
|
162
|
-
:name => 'folder',
|
163
|
-
:large => '--folder folder',
|
164
|
-
:format => String,
|
165
|
-
:description => 'Import template in folder'
|
166
|
-
}
|
167
|
-
|
168
|
-
USE_DEFAULTS = {
|
169
|
-
:name => 'defaults',
|
170
|
-
:large => '--use-defaults',
|
171
|
-
:description => 'Use defaults for answers to questions',
|
172
|
-
:format => String
|
173
|
-
}
|
174
|
-
|
175
|
-
ALL = {
|
176
|
-
:name => 'all',
|
177
|
-
:large => '--all',
|
178
|
-
:description => 'Import all list',
|
179
|
-
:format => String
|
180
|
-
}
|
181
|
-
|
182
|
-
CLUSTER_REF = {
|
183
|
-
:name => 'cluster_ref',
|
184
|
-
:large => '--cluster-ref cluster_ref',
|
185
|
-
:format => String,
|
186
|
-
:description => 'Cluster ref to import'
|
187
|
-
}
|
188
|
-
|
189
|
-
LIST_OPTS = [OBJECT, HOST, DATASTORE, CLIHelper::CSV_OPT] + AUTH_OPTS
|
190
|
-
|
191
|
-
############################################################################
|
192
|
-
# Global Options
|
193
|
-
############################################################################
|
194
|
-
cmd_options = CommandParser::OPTIONS - [CommandParser::VERBOSE]
|
195
|
-
set :option, cmd_options + OpenNebulaHelper::CLIENT_OPTIONS
|
196
|
-
|
197
|
-
############################################################################
|
198
|
-
# list resources
|
199
|
-
############################################################################
|
200
|
-
list_desc = <<-EOT.unindent
|
201
|
-
Show a list with unimported vCenter objects
|
202
|
-
|
203
|
-
Examples:
|
204
|
-
- listing available templates:
|
205
|
-
|
206
|
-
onevcenter list -o templates -h <host_id>
|
207
|
-
|
208
|
-
- listing available images:
|
209
|
-
|
210
|
-
onevcenter list -o datastores -h <host_id> -d <ds-img_id>
|
211
|
-
|
212
|
-
- listing available clusters:
|
213
|
-
|
214
|
-
onevcenter list -o hosts --vcenter <IP> --vuser <U> --vpass <P>
|
215
|
-
EOT
|
216
|
-
|
217
|
-
command :list, list_desc, :options => LIST_OPTS do
|
218
|
-
begin
|
219
|
-
args = helper.parse_opts(options)
|
220
|
-
|
221
|
-
args[:filter] = true
|
222
|
-
args[:short] = true
|
223
|
-
|
224
|
-
helper.list(options, args)
|
225
|
-
rescue StandardError => e
|
226
|
-
STDERR.puts e.message
|
227
|
-
exit 1
|
228
|
-
end
|
229
|
-
|
230
|
-
0
|
231
|
-
end
|
232
|
-
|
233
|
-
list_desc = <<-EOT.unindent
|
234
|
-
Show a list with unimported vCenter objects excluding all filters
|
235
|
-
|
236
|
-
Examples:
|
237
|
-
- listing networks including uplinks:
|
238
|
-
|
239
|
-
onevcenter list_all -o networks -h <host_id>
|
240
|
-
EOT
|
241
|
-
|
242
|
-
command :list_all, list_desc, :options => LIST_OPTS do
|
243
|
-
begin
|
244
|
-
args = helper.parse_opts(options)
|
245
|
-
|
246
|
-
args[:filter] = false
|
247
|
-
args[:short] = true
|
248
|
-
|
249
|
-
helper.list(options, args)
|
250
|
-
rescue StandardError => e
|
251
|
-
STDERR.puts e.message
|
252
|
-
exit 1
|
253
|
-
end
|
254
|
-
|
255
|
-
0
|
256
|
-
end
|
257
|
-
|
258
|
-
import_desc = <<-EOT.unindent
|
259
|
-
Import the the desired vCenter object
|
260
|
-
|
261
|
-
Examples:
|
262
|
-
- importing first datastore
|
263
|
-
|
264
|
-
onevcenter import -o templates -h <host_id>
|
265
|
-
|
266
|
-
- importing 2 concrete templates:
|
267
|
-
|
268
|
-
onevcenter import "vm-1252, vm-553, vm-1248" -o templates -h <host_id>
|
269
|
-
|
270
|
-
- importing a image range:
|
271
|
-
|
272
|
-
onevcenter import 0..10 -o images -h <host_id> -d <ds-img_id>
|
273
|
-
EOT
|
274
|
-
|
275
|
-
command :import,
|
276
|
-
import_desc,
|
277
|
-
[:oid, nil],
|
278
|
-
:options => [OBJECT, HOST, DATASTORE] do
|
279
|
-
begin
|
280
|
-
vi_client = VCenterDriver::VIClient.new_from_host(options[:host])
|
281
|
-
importer = VCenterDriver::VcImporter.new_child(helper.client,
|
282
|
-
vi_client,
|
283
|
-
options[:object])
|
284
|
-
|
285
|
-
importer.retrieve_resources(helper.parse_opts(options))
|
286
|
-
indexes = importer.get_indexes(args.first)
|
287
|
-
|
288
|
-
if indexes.nil?
|
289
|
-
raise "Could not get any unimported #{options[:object]}"\
|
290
|
-
" resources info in host: #{options[:host]} with"\
|
291
|
-
" this input: #{args.first}"
|
292
|
-
end
|
293
|
-
|
294
|
-
importer.process_import(indexes, options) do |object_info|
|
295
|
-
helper.cli_dialogue(object_info)
|
296
|
-
end
|
297
|
-
|
298
|
-
importer.stdout
|
299
|
-
rescue StandardError => e
|
300
|
-
STDERR.puts e.message
|
301
|
-
exit 1
|
302
|
-
end
|
303
|
-
|
304
|
-
0
|
305
|
-
end
|
306
|
-
|
307
|
-
command :import_defaults,
|
308
|
-
import_desc,
|
309
|
-
[:oid, nil],
|
310
|
-
:options => [OBJECT,
|
311
|
-
HOST,
|
312
|
-
DATASTORE,
|
313
|
-
CONFIG,
|
314
|
-
FOLDER,
|
315
|
-
LINKED_CLONE,
|
316
|
-
COPY,
|
317
|
-
NAME] do
|
318
|
-
begin
|
319
|
-
vi_client = VCenterDriver::VIClient.new_from_host(options[:host])
|
320
|
-
importer = VCenterDriver::VcImporter.new_child(helper.client,
|
321
|
-
vi_client,
|
322
|
-
options[:object])
|
323
|
-
|
324
|
-
if options[:object] == 'networks' && !args.first.nil?
|
325
|
-
indexes = args.first
|
326
|
-
else
|
327
|
-
importer.retrieve_resources(helper.parse_opts(options))
|
328
|
-
indexes = importer.get_indexes(args.first)
|
329
|
-
end
|
330
|
-
|
331
|
-
if options[:object] == 'templates' &&
|
332
|
-
indexes &&
|
333
|
-
indexes.split(',').length == 1
|
334
|
-
opts = {
|
335
|
-
:type => 'default',
|
336
|
-
:linked_clone => '0',
|
337
|
-
:copy => '0',
|
338
|
-
:name => '',
|
339
|
-
:folder => ''
|
340
|
-
}
|
341
|
-
|
342
|
-
if options[:linked_clone]
|
343
|
-
opts[:linked_clone] = options[:linked_clone]
|
344
|
-
end
|
345
|
-
|
346
|
-
opts[:copy] = options[:copy] if options[:copy]
|
347
|
-
opts[:name] = options[:name] if options[:name]
|
348
|
-
opts[:folder] = options[:folder] if options[:folder]
|
349
|
-
|
350
|
-
options[indexes] = opts
|
351
|
-
end
|
352
|
-
|
353
|
-
importer.process_import(indexes, options)
|
354
|
-
importer.stdout
|
355
|
-
rescue StandardError => e
|
356
|
-
STDERR.puts e.message
|
357
|
-
exit 1
|
358
|
-
end
|
359
|
-
|
360
|
-
0
|
361
|
-
end
|
362
|
-
|
363
|
-
############################################################################
|
364
|
-
# Import clusters
|
365
|
-
############################################################################
|
366
|
-
host_desc = <<-EOT.unindent
|
367
|
-
Import vCenter clusters as OpenNebula hosts
|
368
|
-
|
369
|
-
Example:
|
370
|
-
- Get available clusters:
|
371
|
-
|
372
|
-
onevcenter hosts --vcenter <vcenter> --vuser <user> --vpass <pass>
|
373
|
-
EOT
|
374
|
-
|
375
|
-
command :hosts,
|
376
|
-
host_desc,
|
377
|
-
:options => [CLUSTER_REF, USE_DEFAULTS] + AUTH_OPTS do
|
378
|
-
con_ops = helper.connection_options('Hosts', options)
|
379
|
-
|
380
|
-
begin
|
381
|
-
VCenterDriver::VcImporter.import_clusters(con_ops, options)
|
382
|
-
rescue StandardError
|
383
|
-
exit 1
|
384
|
-
end
|
385
|
-
|
386
|
-
0
|
387
|
-
end
|
388
|
-
|
389
|
-
############################################################################
|
390
|
-
# Clear VM tags
|
391
|
-
############################################################################
|
392
|
-
cleartags_desc = <<-EOT.unindent
|
393
|
-
Clear extraconfig tags from a vCenter VM, useful when a VM has been
|
394
|
-
launched by OpenNebula and needs to be reimported
|
395
|
-
|
396
|
-
Example:
|
397
|
-
- Clean VM 15:
|
398
|
-
|
399
|
-
onevcenter cleargs 15
|
400
|
-
EOT
|
401
|
-
|
402
|
-
command :cleartags, cleartags_desc, :vmid do
|
403
|
-
vmid = args[0]
|
404
|
-
remove_str = "\n onevm recover --delete-db #{vmid}" \
|
405
|
-
"\n\nAfter a monitoring cycle, the VM will appear "\
|
406
|
-
'as a Wild VM for reimport.'
|
407
|
-
|
408
|
-
print 'Extracting information from VM ' + vmid
|
409
|
-
|
410
|
-
begin
|
411
|
-
print '.'
|
412
|
-
|
413
|
-
client = Client.new
|
414
|
-
|
415
|
-
vm_pool = VirtualMachinePool.new(client, -1)
|
416
|
-
host_pool = HostPool.new(client)
|
417
|
-
deploy_id = -1
|
418
|
-
host_id = -1
|
419
|
-
hostname = ''
|
420
|
-
|
421
|
-
rc = vm_pool.info
|
422
|
-
raise rc.message if OpenNebula.is_error?(rc)
|
423
|
-
|
424
|
-
rc = host_pool.info
|
425
|
-
raise rc.message if OpenNebula.is_error?(rc)
|
426
|
-
|
427
|
-
vm_pool.each do |vm|
|
428
|
-
next if vm.id.to_s != vmid
|
429
|
-
|
430
|
-
deploy_id = vm.deploy_id
|
431
|
-
vm_history = vm.to_hash['VM']['HISTORY_RECORDS']['HISTORY']
|
432
|
-
hostname = vm_history['HOSTNAME']
|
433
|
-
break
|
434
|
-
end
|
435
|
-
|
436
|
-
host_pool.each do |host|
|
437
|
-
if host.name == hostname
|
438
|
-
host_id = host.id
|
439
|
-
end
|
440
|
-
end
|
441
|
-
|
442
|
-
vi_client = VCenterDriver::VIClient.new_from_host(host_id)
|
443
|
-
vm = VCenterDriver::VirtualMachine
|
444
|
-
.new(vi_client, deploy_id, vmid)
|
445
|
-
|
446
|
-
keys = vm.extra_config_keys
|
447
|
-
|
448
|
-
print '.'
|
449
|
-
|
450
|
-
if keys.empty?
|
451
|
-
puts "\n\nNo OpenNebula keys present, is safe to remove the VM."
|
452
|
-
puts remove_str
|
453
|
-
exit 0
|
454
|
-
end
|
455
|
-
|
456
|
-
puts '.'
|
457
|
-
puts 'The following keys will be removed:'
|
458
|
-
keys.each {|key| puts "\t- #{key}" }
|
459
|
-
|
460
|
-
vm.clear_tags
|
461
|
-
rescue StandardError => e
|
462
|
-
STDERR.puts "Couldn't clear VM tags. Reason: #{e.message}"
|
463
|
-
exit 1
|
464
|
-
end
|
465
|
-
|
466
|
-
puts "\nKeys removed from VM. Is safe to remove it"
|
467
|
-
puts remove_str
|
468
|
-
|
469
|
-
0
|
470
|
-
end
|
471
|
-
end
|