opennebula-cli 5.13.80.pre → 6.0.0.2
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 +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 +15 -4
- data/bin/oneimage +19 -8
- data/bin/onemarket +13 -2
- data/bin/onemarketapp +23 -16
- data/bin/onesecgroup +13 -2
- data/bin/oneshowback +13 -2
- data/bin/onetemplate +28 -8
- data/bin/oneuser +13 -2
- data/bin/onevcenter +22 -6
- 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 +15 -4
- data/lib/cli_helper.rb +13 -2
- data/lib/command_parser.rb +16 -13
- data/lib/one_helper.rb +4 -3
- data/lib/one_helper/oneacct_helper.rb +1 -3
- data/lib/one_helper/onecluster_helper.rb +75 -42
- data/lib/one_helper/oneimage_helper.rb +6 -0
- data/lib/one_helper/onemarketapp_helper.rb +12 -6
- 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 +25 -21
- data/share/schemas/xsd/index.xsd +1 -0
- data/share/schemas/xsd/monitoring_data.xsd +41 -0
- data/share/schemas/xsd/opennebula_configuration.xsd +1 -0
- data/share/schemas/xsd/vnet.xsd +2 -0
- metadata +9 -8
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'
|
@@ -57,7 +68,7 @@ CommandParser::CmdParser.new(ARGV) do
|
|
57
68
|
}
|
58
69
|
|
59
70
|
DATABASE = {
|
60
|
-
:name => '
|
71
|
+
:name => 'db',
|
61
72
|
:large => '--db',
|
62
73
|
:description => 'Also sync database'
|
63
74
|
}
|
@@ -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/cli_helper.rb
CHANGED
@@ -211,6 +211,17 @@ module CLIHelper
|
|
211
211
|
end
|
212
212
|
end
|
213
213
|
|
214
|
+
# Get text in green colour
|
215
|
+
#
|
216
|
+
# @param text [String] String to print
|
217
|
+
def self.green(text)
|
218
|
+
if $stdout.tty?
|
219
|
+
ANSI_GREEN + text + ANSI_RESET
|
220
|
+
else
|
221
|
+
text
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
214
225
|
# Print header
|
215
226
|
#
|
216
227
|
# @param str [String] String with header content
|
@@ -357,14 +368,14 @@ module CLIHelper
|
|
357
368
|
# @param options [Hash] Object with CLI user options
|
358
369
|
# @param top [Boolean] True to not update columns again
|
359
370
|
def show(data, options = {}, top = false)
|
371
|
+
update_columns(options) unless top
|
372
|
+
|
360
373
|
if options[:list]
|
361
374
|
@cli_columns = options[:list].collect {|o| o.upcase.to_sym }
|
362
375
|
else
|
363
376
|
@cli_columns = @default_columns
|
364
377
|
end
|
365
378
|
|
366
|
-
update_columns(options) unless top
|
367
|
-
|
368
379
|
if data.is_a? Hash
|
369
380
|
@data = data
|
370
381
|
|
data/lib/command_parser.rb
CHANGED
@@ -481,9 +481,12 @@ module CommandParser
|
|
481
481
|
begin
|
482
482
|
rc = comm[:proc].call
|
483
483
|
|
484
|
-
if rc.instance_of?(Array)
|
484
|
+
if rc.instance_of?(Array) && rc[0] != 0
|
485
|
+
STDERR.puts rc[1]
|
486
|
+
exit(rc[0])
|
487
|
+
elsif rc.instance_of?(Array)
|
485
488
|
puts rc[1]
|
486
|
-
exit
|
489
|
+
exit(rc[0])
|
487
490
|
else
|
488
491
|
exit(@exit_code || rc)
|
489
492
|
end
|
@@ -537,7 +540,7 @@ module CommandParser
|
|
537
540
|
begin
|
538
541
|
@cmdparse.parse!(@args)
|
539
542
|
rescue => e
|
540
|
-
puts e.message
|
543
|
+
STDERR.puts e.message
|
541
544
|
exit -1
|
542
545
|
end
|
543
546
|
|
@@ -547,8 +550,8 @@ module CommandParser
|
|
547
550
|
if rc[0] == 0
|
548
551
|
@options[e[:name].to_sym] = rc[1]
|
549
552
|
else
|
550
|
-
puts rc[1]
|
551
|
-
puts "option #{e[:name]}: Parsing error"
|
553
|
+
STDERR.puts rc[1]
|
554
|
+
STDERR.puts "option #{e[:name]}: Parsing error"
|
552
555
|
exit -1
|
553
556
|
end
|
554
557
|
end
|
@@ -557,11 +560,11 @@ module CommandParser
|
|
557
560
|
|
558
561
|
def check_args!(name, arity, args_format)
|
559
562
|
if @args.length < arity
|
560
|
-
print "Command #{name} requires "
|
563
|
+
STDERR.print "Command #{name} requires "
|
561
564
|
if arity>1
|
562
|
-
puts "#{args_format.length} parameters to run."
|
565
|
+
STDERR.puts "#{args_format.length} parameters to run."
|
563
566
|
else
|
564
|
-
puts "one parameter to run"
|
567
|
+
STDERR.puts "one parameter to run"
|
565
568
|
end
|
566
569
|
|
567
570
|
print_command_help(name)
|
@@ -579,11 +582,11 @@ module CommandParser
|
|
579
582
|
end
|
580
583
|
}.join(' ')
|
581
584
|
|
582
|
-
puts "Wrong number of arguments"
|
585
|
+
STDERR.puts "Wrong number of arguments"
|
583
586
|
if args_str.empty?
|
584
|
-
puts "No argument is required"
|
587
|
+
STDERR.puts "No argument is required"
|
585
588
|
else
|
586
|
-
puts "The arguments should be: #{args_str}"
|
589
|
+
STDERR.puts "The arguments should be: #{args_str}"
|
587
590
|
end
|
588
591
|
exit -1
|
589
592
|
end
|
@@ -613,9 +616,9 @@ module CommandParser
|
|
613
616
|
|
614
617
|
unless argument
|
615
618
|
if error_msg
|
616
|
-
puts error_msg
|
619
|
+
STDERR.puts error_msg
|
617
620
|
else
|
618
|
-
puts "command #{name}: argument #{id} must be one of #{format.join(', ')}"
|
621
|
+
STDERR.puts "command #{name}: argument #{id} must be one of #{format.join(', ')}"
|
619
622
|
end
|
620
623
|
exit -1
|
621
624
|
end
|
data/lib/one_helper.rb
CHANGED
@@ -707,9 +707,10 @@ EOT
|
|
707
707
|
|
708
708
|
return -1, rc.message if OpenNebula.is_error?(rc)
|
709
709
|
|
710
|
-
|
710
|
+
elements, hash = print_page(pool, options)
|
711
711
|
|
712
|
-
|
712
|
+
if options[:ids] && elements
|
713
|
+
hash = [hash[pool.pool_name][pool.element_name]].flatten
|
713
714
|
hash.reject! do |element|
|
714
715
|
!options[:ids].include?(element['ID'].to_i)
|
715
716
|
end
|
@@ -1010,7 +1011,7 @@ EOT
|
|
1010
1011
|
rc = perform_action(id,options,verbose,&block)
|
1011
1012
|
|
1012
1013
|
unless rc[0]==0
|
1013
|
-
puts rc[1]
|
1014
|
+
STDERR.puts rc[1]
|
1014
1015
|
exit_code=rc[0]
|
1015
1016
|
end
|
1016
1017
|
end
|
@@ -98,13 +98,11 @@ class AcctHelper < OpenNebulaHelper::OneHelper
|
|
98
98
|
}
|
99
99
|
|
100
100
|
ACCT_OPTIONS = [START_TIME_ACCT, END_TIME_ACCT, USERFILTER, GROUP, HOST, XPATH, SPLIT]
|
101
|
-
SHOWBACK_OPTIONS = [START_TIME_SHOWBACK, END_TIME_SHOWBACK, USERFILTER, GROUP]
|
101
|
+
SHOWBACK_OPTIONS = [START_TIME_SHOWBACK, END_TIME_SHOWBACK, USERFILTER, GROUP, OpenNebulaHelper::FORMAT]
|
102
102
|
|
103
103
|
ACCT_OPTIONS << OpenNebulaHelper::XML
|
104
104
|
ACCT_OPTIONS << OpenNebulaHelper::JSON
|
105
105
|
|
106
|
-
SHOWBACK_OPTIONS += OpenNebulaHelper::FORMAT
|
107
|
-
|
108
106
|
ACCT_TABLE = CLIHelper::ShowTable.new(self.table_conf("oneacct.yaml"), nil) do
|
109
107
|
column :UID, "User ID", :size=>4 do |d|
|
110
108
|
d["UID"]
|
@@ -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
|