opennebula-cli 6.0.0.1 → 6.0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/oneacct +13 -2
- data/bin/oneacl +13 -2
- data/bin/onecluster +13 -2
- data/bin/onedatastore +13 -2
- data/bin/oneflow +13 -2
- data/bin/oneflow-template +13 -2
- data/bin/onegroup +13 -2
- data/bin/onehook +17 -6
- data/bin/onehost +13 -2
- data/bin/oneimage +17 -6
- data/bin/onemarket +13 -2
- data/bin/onemarketapp +21 -10
- data/bin/onesecgroup +13 -2
- data/bin/oneshowback +13 -2
- data/bin/onetemplate +28 -8
- data/bin/oneuser +13 -2
- data/bin/onevcenter +14 -3
- data/bin/onevdc +13 -2
- data/bin/onevm +180 -18
- data/bin/onevmgroup +17 -6
- data/bin/onevnet +17 -6
- data/bin/onevntemplate +17 -6
- data/bin/onevrouter +17 -6
- data/bin/onezone +14 -3
- data/lib/one_helper.rb +2 -2
- data/lib/one_helper/onecluster_helper.rb +75 -42
- data/lib/one_helper/onevm_helper.rb +20 -0
- data/lib/one_helper/onevnet_helper.rb +173 -151
- data/lib/one_helper/onezone_helper.rb +12 -4
- data/share/schemas/xsd/opennebula_configuration.xsd +1 -0
- data/share/schemas/xsd/vnet.xsd +2 -0
- metadata +6 -6
data/bin/onevmgroup
CHANGED
@@ -26,14 +26,25 @@ else
|
|
26
26
|
GEMS_LOCATION = ONE_LOCATION + '/share/gems'
|
27
27
|
end
|
28
28
|
|
29
|
+
# %%RUBYGEMS_SETUP_BEGIN%%
|
29
30
|
if File.directory?(GEMS_LOCATION)
|
30
31
|
real_gems_path = File.realpath(GEMS_LOCATION)
|
31
32
|
if !defined?(Gem) || Gem.path != [real_gems_path]
|
32
33
|
$LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
|
33
|
-
|
34
|
-
|
34
|
+
|
35
|
+
# Suppress warnings from Rubygems
|
36
|
+
# https://github.com/OpenNebula/one/issues/5379
|
37
|
+
begin
|
38
|
+
verb = $VERBOSE
|
39
|
+
$VERBOSE = nil
|
40
|
+
require 'rubygems'
|
41
|
+
Gem.use_paths(real_gems_path)
|
42
|
+
ensure
|
43
|
+
$VERBOSE = verb
|
44
|
+
end
|
35
45
|
end
|
36
46
|
end
|
47
|
+
# %%RUBYGEMS_SETUP_END%%
|
37
48
|
|
38
49
|
$LOAD_PATH << RUBY_LIB_LOCATION
|
39
50
|
$LOAD_PATH << RUBY_LIB_LOCATION + '/cli'
|
@@ -231,9 +242,9 @@ CommandParser::CmdParser.new(ARGV) do
|
|
231
242
|
[Admin]: locks only Admin actions.
|
232
243
|
EOT
|
233
244
|
|
234
|
-
command :lock, lock_desc, :
|
245
|
+
command :lock, lock_desc, [:range, :vmgroupid_list],
|
235
246
|
:options => [USE, MANAGE, ADMIN, ALL] do
|
236
|
-
helper.
|
247
|
+
helper.perform_actions(args[0], options, 'VMGroup locked') do |vmg|
|
237
248
|
if !options[:use].nil?
|
238
249
|
level = 1
|
239
250
|
elsif !options[:manage].nil?
|
@@ -254,8 +265,8 @@ CommandParser::CmdParser.new(ARGV) do
|
|
254
265
|
Valid states are: All.
|
255
266
|
EOT
|
256
267
|
|
257
|
-
command :unlock, unlock_desc, :
|
258
|
-
helper.
|
268
|
+
command :unlock, unlock_desc, [:range, :vmgroupid_list] do
|
269
|
+
helper.perform_actions(args[0], options, 'VMGroup unlocked') do |vmg|
|
259
270
|
vmg.unlock
|
260
271
|
end
|
261
272
|
end
|
data/bin/onevnet
CHANGED
@@ -26,14 +26,25 @@ else
|
|
26
26
|
GEMS_LOCATION = ONE_LOCATION + '/share/gems'
|
27
27
|
end
|
28
28
|
|
29
|
+
# %%RUBYGEMS_SETUP_BEGIN%%
|
29
30
|
if File.directory?(GEMS_LOCATION)
|
30
31
|
real_gems_path = File.realpath(GEMS_LOCATION)
|
31
32
|
if !defined?(Gem) || Gem.path != [real_gems_path]
|
32
33
|
$LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
|
33
|
-
|
34
|
-
|
34
|
+
|
35
|
+
# Suppress warnings from Rubygems
|
36
|
+
# https://github.com/OpenNebula/one/issues/5379
|
37
|
+
begin
|
38
|
+
verb = $VERBOSE
|
39
|
+
$VERBOSE = nil
|
40
|
+
require 'rubygems'
|
41
|
+
Gem.use_paths(real_gems_path)
|
42
|
+
ensure
|
43
|
+
$VERBOSE = verb
|
44
|
+
end
|
35
45
|
end
|
36
46
|
end
|
47
|
+
# %%RUBYGEMS_SETUP_END%%
|
37
48
|
|
38
49
|
$LOAD_PATH << RUBY_LIB_LOCATION
|
39
50
|
$LOAD_PATH << RUBY_LIB_LOCATION + '/cli'
|
@@ -379,9 +390,9 @@ CommandParser::CmdParser.new(ARGV) do
|
|
379
390
|
[Admin]: locks only Admin actions.
|
380
391
|
EOT
|
381
392
|
|
382
|
-
command :lock, lock_desc, :
|
393
|
+
command :lock, lock_desc, [:range, :vnetid_list],
|
383
394
|
:options => [USE, MANAGE, ADMIN, ALL] do
|
384
|
-
helper.
|
395
|
+
helper.perform_actions(args[0], options, 'VNet locked') do |vnet|
|
385
396
|
if !options[:use].nil?
|
386
397
|
level = 1
|
387
398
|
elsif !options[:manage].nil?
|
@@ -402,8 +413,8 @@ CommandParser::CmdParser.new(ARGV) do
|
|
402
413
|
Valid states are: All.
|
403
414
|
EOT
|
404
415
|
|
405
|
-
command :unlock, unlock_desc, :
|
406
|
-
helper.
|
416
|
+
command :unlock, unlock_desc, [:range, :vnetid_list] do
|
417
|
+
helper.perform_actions(args[0], options, 'VNet unlocked') do |vnet|
|
407
418
|
vnet.unlock
|
408
419
|
end
|
409
420
|
end
|
data/bin/onevntemplate
CHANGED
@@ -26,14 +26,25 @@ else
|
|
26
26
|
GEMS_LOCATION = ONE_LOCATION + '/share/gems'
|
27
27
|
end
|
28
28
|
|
29
|
+
# %%RUBYGEMS_SETUP_BEGIN%%
|
29
30
|
if File.directory?(GEMS_LOCATION)
|
30
31
|
real_gems_path = File.realpath(GEMS_LOCATION)
|
31
32
|
if !defined?(Gem) || Gem.path != [real_gems_path]
|
32
33
|
$LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
|
33
|
-
|
34
|
-
|
34
|
+
|
35
|
+
# Suppress warnings from Rubygems
|
36
|
+
# https://github.com/OpenNebula/one/issues/5379
|
37
|
+
begin
|
38
|
+
verb = $VERBOSE
|
39
|
+
$VERBOSE = nil
|
40
|
+
require 'rubygems'
|
41
|
+
Gem.use_paths(real_gems_path)
|
42
|
+
ensure
|
43
|
+
$VERBOSE = verb
|
44
|
+
end
|
35
45
|
end
|
36
46
|
end
|
47
|
+
# %%RUBYGEMS_SETUP_END%%
|
37
48
|
|
38
49
|
$LOAD_PATH << RUBY_LIB_LOCATION
|
39
50
|
$LOAD_PATH << RUBY_LIB_LOCATION + '/cli'
|
@@ -339,9 +350,9 @@ CommandParser::CmdParser.new(ARGV) do
|
|
339
350
|
[Admin]: locks only Admin actions.
|
340
351
|
EOT
|
341
352
|
|
342
|
-
command :lock, lock_desc, :
|
353
|
+
command :lock, lock_desc, [:range, :templateid_list],
|
343
354
|
:options => [USE, MANAGE, ADMIN, ALL] do
|
344
|
-
helper.
|
355
|
+
helper.perform_actions(args[0], options, 'VN Template locked') do |t|
|
345
356
|
if !options[:use].nil?
|
346
357
|
level = 1
|
347
358
|
elsif !options[:manage].nil?
|
@@ -362,8 +373,8 @@ CommandParser::CmdParser.new(ARGV) do
|
|
362
373
|
Valid states are: All.
|
363
374
|
EOT
|
364
375
|
|
365
|
-
command :unlock, unlock_desc, :
|
366
|
-
helper.
|
376
|
+
command :unlock, unlock_desc, [:range, :templateid_list] do
|
377
|
+
helper.perform_actions(args[0], options, 'VN Template unlocked') do |t|
|
367
378
|
t.unlock
|
368
379
|
end
|
369
380
|
end
|
data/bin/onevrouter
CHANGED
@@ -26,14 +26,25 @@ else
|
|
26
26
|
GEMS_LOCATION = ONE_LOCATION + '/share/gems'
|
27
27
|
end
|
28
28
|
|
29
|
+
# %%RUBYGEMS_SETUP_BEGIN%%
|
29
30
|
if File.directory?(GEMS_LOCATION)
|
30
31
|
real_gems_path = File.realpath(GEMS_LOCATION)
|
31
32
|
if !defined?(Gem) || Gem.path != [real_gems_path]
|
32
33
|
$LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
|
33
|
-
|
34
|
-
|
34
|
+
|
35
|
+
# Suppress warnings from Rubygems
|
36
|
+
# https://github.com/OpenNebula/one/issues/5379
|
37
|
+
begin
|
38
|
+
verb = $VERBOSE
|
39
|
+
$VERBOSE = nil
|
40
|
+
require 'rubygems'
|
41
|
+
Gem.use_paths(real_gems_path)
|
42
|
+
ensure
|
43
|
+
$VERBOSE = verb
|
44
|
+
end
|
35
45
|
end
|
36
46
|
end
|
47
|
+
# %%RUBYGEMS_SETUP_END%%
|
37
48
|
|
38
49
|
$LOAD_PATH << RUBY_LIB_LOCATION
|
39
50
|
$LOAD_PATH << RUBY_LIB_LOCATION + '/cli'
|
@@ -364,9 +375,9 @@ CommandParser::CmdParser.new(ARGV) do
|
|
364
375
|
[Admin]: locks only Admin actions.
|
365
376
|
EOT
|
366
377
|
|
367
|
-
command :lock, lock_desc, :
|
378
|
+
command :lock, lock_desc, [:range, :vrouterid_list],
|
368
379
|
:options => [USE, MANAGE, ADMIN, ALL] do
|
369
|
-
helper.
|
380
|
+
helper.perform_actions(args[0], options, 'VRouter locked') do |vr|
|
370
381
|
if !options[:use].nil?
|
371
382
|
level = 1
|
372
383
|
elsif !options[:manage].nil?
|
@@ -387,8 +398,8 @@ CommandParser::CmdParser.new(ARGV) do
|
|
387
398
|
valid states are: All.
|
388
399
|
EOT
|
389
400
|
|
390
|
-
command :unlock, unlock_desc, :
|
391
|
-
helper.
|
401
|
+
command :unlock, unlock_desc, [:range, :vrouterid_list] do
|
402
|
+
helper.perform_actions(args[0], options, 'VRouter unlocked') do |vr|
|
392
403
|
vr.unlock
|
393
404
|
end
|
394
405
|
end
|
data/bin/onezone
CHANGED
@@ -26,14 +26,25 @@ else
|
|
26
26
|
GEMS_LOCATION = ONE_LOCATION + '/share/gems'
|
27
27
|
end
|
28
28
|
|
29
|
+
# %%RUBYGEMS_SETUP_BEGIN%%
|
29
30
|
if File.directory?(GEMS_LOCATION)
|
30
31
|
real_gems_path = File.realpath(GEMS_LOCATION)
|
31
32
|
if !defined?(Gem) || Gem.path != [real_gems_path]
|
32
33
|
$LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
|
33
|
-
|
34
|
-
|
34
|
+
|
35
|
+
# Suppress warnings from Rubygems
|
36
|
+
# https://github.com/OpenNebula/one/issues/5379
|
37
|
+
begin
|
38
|
+
verb = $VERBOSE
|
39
|
+
$VERBOSE = nil
|
40
|
+
require 'rubygems'
|
41
|
+
Gem.use_paths(real_gems_path)
|
42
|
+
ensure
|
43
|
+
$VERBOSE = verb
|
44
|
+
end
|
35
45
|
end
|
36
46
|
end
|
47
|
+
# %%RUBYGEMS_SETUP_END%%
|
37
48
|
|
38
49
|
$LOAD_PATH << RUBY_LIB_LOCATION
|
39
50
|
$LOAD_PATH << RUBY_LIB_LOCATION + '/cli'
|
@@ -254,7 +265,7 @@ CommandParser::CmdParser.new(ARGV) do
|
|
254
265
|
end
|
255
266
|
|
256
267
|
server = Replicator.new('/var/lib/one/.ssh/id_rsa', args[0])
|
257
|
-
server.process_files(options
|
268
|
+
server.process_files(options[:db])
|
258
269
|
|
259
270
|
0
|
260
271
|
end
|
data/lib/one_helper.rb
CHANGED
@@ -710,8 +710,8 @@ EOT
|
|
710
710
|
elements, hash = print_page(pool, options)
|
711
711
|
|
712
712
|
if options[:ids] && elements
|
713
|
-
|
714
|
-
|
713
|
+
hash = [hash[pool.pool_name][pool.element_name]].flatten
|
714
|
+
hash.reject! do |element|
|
715
715
|
!options[:ids].include?(element['ID'].to_i)
|
716
716
|
end
|
717
717
|
end
|
@@ -16,73 +16,71 @@
|
|
16
16
|
|
17
17
|
require 'one_helper'
|
18
18
|
|
19
|
+
# OneCluster CLI command helper
|
19
20
|
class OneClusterHelper < OpenNebulaHelper::OneHelper
|
20
21
|
|
21
22
|
CLUSTER = {
|
22
|
-
:name =>
|
23
|
-
:short =>
|
24
|
-
:large =>
|
25
|
-
:description =>
|
23
|
+
:name => 'cluster',
|
24
|
+
:short => '-c id|name',
|
25
|
+
:large => '--cluster id|name',
|
26
|
+
:description => 'Selects the cluster',
|
26
27
|
:format => String,
|
27
|
-
:proc => lambda {
|
28
|
-
OpenNebulaHelper.rname_to_id(o,
|
28
|
+
:proc => lambda {|o, _options|
|
29
|
+
OpenNebulaHelper.rname_to_id(o, 'CLUSTER')
|
29
30
|
}
|
30
31
|
}
|
31
32
|
|
32
33
|
def self.rname
|
33
|
-
|
34
|
+
'CLUSTER'
|
34
35
|
end
|
35
36
|
|
36
37
|
def self.conf_file
|
37
|
-
|
38
|
+
'onecluster.yaml'
|
38
39
|
end
|
39
40
|
|
40
41
|
def element_size(ehash, ename)
|
41
|
-
ids = ehash[ename][
|
42
|
+
ids = ehash[ename]['ID']
|
42
43
|
|
43
44
|
if ids.nil?
|
44
|
-
|
45
|
+
0
|
45
46
|
elsif ids.class == String
|
46
|
-
|
47
|
+
1
|
47
48
|
else
|
48
|
-
|
49
|
+
ids.size
|
49
50
|
end
|
50
51
|
end
|
51
52
|
|
52
|
-
|
53
|
-
def format_pool(options)
|
53
|
+
def format_pool(_options)
|
54
54
|
config_file = self.class.table_conf
|
55
55
|
|
56
|
-
|
57
|
-
column :ID,
|
58
|
-
d[
|
56
|
+
CLIHelper::ShowTable.new(config_file, self) do
|
57
|
+
column :ID, 'ONE identifier for the Cluster', :size=>5 do |d|
|
58
|
+
d['ID']
|
59
59
|
end
|
60
60
|
|
61
|
-
column :NAME,
|
62
|
-
d[
|
61
|
+
column :NAME, 'Name of the Cluster', :left, :size=>25 do |d|
|
62
|
+
d['NAME']
|
63
63
|
end
|
64
64
|
|
65
|
-
column :HOSTS,
|
66
|
-
@ext.element_size(d,
|
65
|
+
column :HOSTS, 'Number of Hosts', :size=>5 do |d|
|
66
|
+
@ext.element_size(d, 'HOSTS') rescue 0
|
67
67
|
end
|
68
68
|
|
69
|
-
column :VNETS,
|
70
|
-
@ext.element_size(d,
|
69
|
+
column :VNETS, 'Number of Networks', :size=>5 do |d|
|
70
|
+
@ext.element_size(d, 'VNETS') rescue 0
|
71
71
|
end
|
72
72
|
|
73
|
-
column :DATASTORES,
|
74
|
-
@ext.element_size(d,
|
73
|
+
column :DATASTORES, 'Number of Datastores', :size=>10 do |d|
|
74
|
+
@ext.element_size(d, 'DATASTORES') rescue 0
|
75
75
|
end
|
76
76
|
|
77
77
|
default :ID, :NAME, :HOSTS, :VNETS, :DATASTORES
|
78
78
|
end
|
79
|
-
|
80
|
-
table
|
81
79
|
end
|
82
80
|
|
83
81
|
private
|
84
82
|
|
85
|
-
def factory(id=nil)
|
83
|
+
def factory(id = nil)
|
86
84
|
if id
|
87
85
|
OpenNebula::Cluster.new_with_id(id, @client)
|
88
86
|
else
|
@@ -91,39 +89,74 @@ class OneClusterHelper < OpenNebulaHelper::OneHelper
|
|
91
89
|
end
|
92
90
|
end
|
93
91
|
|
94
|
-
def factory_pool(
|
92
|
+
def factory_pool(_user_flag = -2)
|
95
93
|
OpenNebula::ClusterPool.new(@client)
|
96
94
|
end
|
97
95
|
|
98
|
-
def format_resource(cluster,
|
99
|
-
str=
|
100
|
-
str_h1=
|
96
|
+
def format_resource(cluster, _options = {})
|
97
|
+
str='%-18s: %-20s'
|
98
|
+
str_h1='%-80s'
|
101
99
|
|
102
100
|
CLIHelper.print_header(str_h1 % "CLUSTER #{cluster['ID']} INFORMATION")
|
103
|
-
puts str
|
104
|
-
puts str
|
101
|
+
puts format(str, 'ID', cluster.id.to_s)
|
102
|
+
puts format(str, 'NAME', cluster.name)
|
103
|
+
|
105
104
|
puts
|
105
|
+
CLIHelper.print_header(str_h1 % 'CLUSTER RESOURCES', false)
|
106
|
+
cluster.info!
|
106
107
|
|
107
|
-
|
108
|
-
|
108
|
+
hosts = cluster.to_hash['CLUSTER']['HOSTS']['ID']
|
109
|
+
|
110
|
+
if hosts
|
111
|
+
total_cpu = 0
|
112
|
+
used_cpu = 0
|
113
|
+
total_ram = 0
|
114
|
+
used_ram = 0
|
115
|
+
|
116
|
+
[hosts].flatten.each do |h|
|
117
|
+
h = OpenNebula::Host.new_with_id(h, @client)
|
118
|
+
|
119
|
+
h.info!
|
120
|
+
|
121
|
+
h = h.to_hash
|
122
|
+
h = h['HOST']['HOST_SHARE']
|
123
|
+
|
124
|
+
total_cpu += h['TOTAL_CPU'].to_i / 100
|
125
|
+
used_cpu += h['CPU_USAGE'].to_i / 100
|
126
|
+
total_ram += h['TOTAL_MEM'].to_i / 1024 / 1024
|
127
|
+
used_ram += h['MEM_USAGE'].to_i / 1024 / 1024
|
128
|
+
end
|
129
|
+
|
130
|
+
puts "TOTAL CPUs: #{total_cpu}"
|
131
|
+
puts "OCCUPIED CPUs: #{used_cpu}"
|
132
|
+
puts "AVAILABLE CPUs: #{total_cpu - used_cpu}"
|
133
|
+
puts
|
134
|
+
puts "TOTAL RAM: #{total_ram}"
|
135
|
+
puts "OCCUPIED RAM: #{used_ram}"
|
136
|
+
puts "AVAILABLE RAM: #{total_ram - used_ram}"
|
137
|
+
end
|
109
138
|
|
110
139
|
puts
|
140
|
+
CLIHelper.print_header(str_h1 % 'CLUSTER TEMPLATE', false)
|
141
|
+
puts cluster.template_str
|
111
142
|
|
112
|
-
|
143
|
+
puts
|
144
|
+
CLIHelper.print_header(format('%-15s', 'HOSTS'))
|
113
145
|
cluster.host_ids.each do |id|
|
114
|
-
puts
|
146
|
+
puts format('%-15s', id)
|
115
147
|
end
|
116
148
|
|
117
149
|
puts
|
118
|
-
CLIHelper.print_header(
|
150
|
+
CLIHelper.print_header(format('%-15s', 'VNETS'))
|
119
151
|
cluster.vnet_ids.each do |id|
|
120
|
-
puts
|
152
|
+
puts format('%-15s', id)
|
121
153
|
end
|
122
154
|
|
123
155
|
puts
|
124
|
-
CLIHelper.print_header(
|
156
|
+
CLIHelper.print_header(format('%-15s', 'DATASTORES'))
|
125
157
|
cluster.datastore_ids.each do |id|
|
126
|
-
puts
|
158
|
+
puts format('%-15s', id)
|
127
159
|
end
|
128
160
|
end
|
161
|
+
|
129
162
|
end
|
@@ -1086,6 +1086,26 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
1086
1086
|
end
|
1087
1087
|
end
|
1088
1088
|
|
1089
|
+
if vm_hash['VM']['TEMPLATE']['NIC']
|
1090
|
+
nic = [vm_hash['VM']['TEMPLATE']['NIC']]
|
1091
|
+
nic = nic.flatten
|
1092
|
+
nic = nic.select {|v| !v['EXTERNAL_PORT_RANGE'].nil? }[0]
|
1093
|
+
|
1094
|
+
if nic
|
1095
|
+
ip = vm_hash['VM']['HISTORY_RECORDS']['HISTORY']
|
1096
|
+
ip = [ip].flatten[-1]['HOSTNAME']
|
1097
|
+
port = Integer(nic['EXTERNAL_PORT_RANGE'].split(':')[0]) + 21
|
1098
|
+
|
1099
|
+
puts
|
1100
|
+
CLIHelper.print_header(str_h1 % 'PORT FORWARD', false)
|
1101
|
+
|
1102
|
+
puts "[#{nic['EXTERNAL_PORT_RANGE']}]:" \
|
1103
|
+
"[#{nic['INTERNAL_PORT_RANGE'].split('/')[0]}]"
|
1104
|
+
|
1105
|
+
puts "SSH on #{ip} at port #{port}"
|
1106
|
+
end
|
1107
|
+
end
|
1108
|
+
|
1089
1109
|
if !options[:all]
|
1090
1110
|
while vm.has_elements?('/VM/TEMPLATE/NIC')
|
1091
1111
|
vm.delete_element('/VM/TEMPLATE/NIC')
|