opennebula-cli 6.6.1 → 6.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/oneacl +1 -1
- data/bin/onecluster +1 -1
- data/bin/onedatastore +1 -1
- data/bin/oneflow-template +10 -5
- data/bin/onegroup +1 -1
- data/bin/onehook +1 -1
- data/bin/onehost +1 -1
- data/bin/oneimage +1 -1
- data/bin/onemarket +1 -1
- data/bin/onemarketapp +1 -1
- data/bin/onesecgroup +1 -1
- data/bin/onetemplate +1 -1
- data/bin/oneuser +1 -1
- data/bin/onevdc +1 -1
- data/bin/onevm +24 -8
- data/bin/onevmgroup +1 -1
- data/bin/onevnet +1 -1
- data/bin/onevntemplate +1 -1
- data/bin/onevrouter +1 -1
- data/bin/onezone +1 -1
- data/lib/one_helper/oneflowtemplate_helper.rb +29 -0
- data/lib/one_helper/onetemplate_helper.rb +1 -0
- data/lib/one_helper/onevm_helper.rb +50 -57
- data/lib/one_helper.rb +321 -325
- data/share/schemas/xsd/vm_pool.xsd +1 -0
- metadata +4 -4
@@ -267,8 +267,8 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
267
267
|
end
|
268
268
|
|
269
269
|
vm_nics.each do |nic|
|
270
|
-
|
271
|
-
|
270
|
+
['IP', 'EXTERNAL_IP', 'IP6_GLOBAL', 'IP6_ULA', 'IP6', 'VROUTER_IP',
|
271
|
+
'VROUTER_IP6_GLOBAL', 'VROUTER_IP6_ULA'].each do |attr|
|
272
272
|
if nic.key?(attr)
|
273
273
|
ips.push(nic[attr])
|
274
274
|
end
|
@@ -333,7 +333,7 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
333
333
|
end
|
334
334
|
end
|
335
335
|
|
336
|
-
|
336
|
+
CLIHelper::ShowTable.new(config_file, self) do
|
337
337
|
column :ID, 'ONE identifier for Virtual Machine', :size => 6 do |d|
|
338
338
|
d['ID']
|
339
339
|
end
|
@@ -377,7 +377,7 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
377
377
|
:left, :size => 10 do |d|
|
378
378
|
if d['HISTORY_RECORDS'] && d['HISTORY_RECORDS']['HISTORY']
|
379
379
|
state_str = VirtualMachine::VM_STATE[d['STATE'].to_i]
|
380
|
-
if
|
380
|
+
if ['ACTIVE', 'SUSPENDED', 'POWEROFF'].include? state_str
|
381
381
|
d['HISTORY_RECORDS']['HISTORY']['HOSTNAME']
|
382
382
|
end
|
383
383
|
end
|
@@ -414,8 +414,6 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
414
414
|
default :ID, :USER, :GROUP, :NAME, :STAT, :CPU, :MEM, :HOST,
|
415
415
|
:TIME
|
416
416
|
end
|
417
|
-
|
418
|
-
table
|
419
417
|
end
|
420
418
|
|
421
419
|
def schedule_actions(ids, options, action, warning = nil)
|
@@ -428,8 +426,7 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
428
426
|
"#{action} scheduled after #{options[:schedule]}s from start"
|
429
427
|
end
|
430
428
|
|
431
|
-
perform_actions(
|
432
|
-
|
429
|
+
perform_actions(ids, options, message) do |vm|
|
433
430
|
str_periodic = ''
|
434
431
|
|
435
432
|
if options.key?(:weekly)
|
@@ -457,7 +454,7 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
457
454
|
str_periodic << ', END_TYPE = 0'
|
458
455
|
end
|
459
456
|
|
460
|
-
tmp_str =
|
457
|
+
tmp_str = 'SCHED_ACTION = ['
|
461
458
|
tmp_str << "ACTION = #{action}, "
|
462
459
|
tmp_str << "WARNING = #{warning}," if warning
|
463
460
|
tmp_str << "ARGS = \"#{options[:args]}\"," if options[:args]
|
@@ -467,7 +464,8 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
467
464
|
rc = vm.sched_action_add(tmp_str)
|
468
465
|
|
469
466
|
if OpenNebula.is_error?(rc)
|
470
|
-
|
467
|
+
STDERR.puts rc.message
|
468
|
+
return -1
|
471
469
|
end
|
472
470
|
end
|
473
471
|
end
|
@@ -600,7 +598,7 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
600
598
|
EOF
|
601
599
|
|
602
600
|
ans = ''
|
603
|
-
until
|
601
|
+
until ['n', 'a', 'r', 'q'].include?(ans)
|
604
602
|
printf '> '
|
605
603
|
ans = STDIN.gets.strip.downcase
|
606
604
|
|
@@ -618,7 +616,7 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
618
616
|
|
619
617
|
if result == 'SUCCESS'
|
620
618
|
success = true
|
621
|
-
puts result
|
619
|
+
puts result
|
622
620
|
else
|
623
621
|
puts
|
624
622
|
puts "#{result}. Repeat command.".red
|
@@ -660,7 +658,7 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
660
658
|
# - action
|
661
659
|
# - time
|
662
660
|
# - warning
|
663
|
-
def
|
661
|
+
def charters
|
664
662
|
YAML.load_file(self.class.table_conf)[:charters]
|
665
663
|
end
|
666
664
|
|
@@ -725,9 +723,9 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
725
723
|
options[:ssh_opts].nil? ? opts = '' : opts = options[:ssh_opts]
|
726
724
|
|
727
725
|
if opts.empty?
|
728
|
-
exec(
|
726
|
+
exec('ssh', "#{login}@#{ip}", '-p', port.to_s, cmd.to_s)
|
729
727
|
else
|
730
|
-
exec('ssh', *opts.split,
|
728
|
+
exec('ssh', *opts.split, "#{login}@#{ip}", '-p', port.to_s, cmd.to_s)
|
731
729
|
end
|
732
730
|
end
|
733
731
|
|
@@ -759,7 +757,7 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
759
757
|
|
760
758
|
vm_hash = vm.to_hash
|
761
759
|
|
762
|
-
if
|
760
|
+
if ['ACTIVE', 'SUSPENDED', 'POWEROFF'].include? vm.state_str
|
763
761
|
cluster_id = vm['/VM/HISTORY_RECORDS/HISTORY[last()]/CID']
|
764
762
|
else
|
765
763
|
cluster_id = nil
|
@@ -794,7 +792,7 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
794
792
|
OpenNebulaHelper.level_lock_to_str(vm['LOCK/LOCKED']))
|
795
793
|
puts format(str, 'RESCHED',
|
796
794
|
OpenNebulaHelper.boolean_to_str(vm['RESCHED']))
|
797
|
-
if
|
795
|
+
if ['ACTIVE', 'SUSPENDED', 'POWEROFF'].include? vm.state_str
|
798
796
|
puts format(str, 'HOST',
|
799
797
|
vm['/VM/HISTORY_RECORDS/HISTORY[last()]/HOSTNAME'])
|
800
798
|
end
|
@@ -823,7 +821,7 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
823
821
|
end
|
824
822
|
end
|
825
823
|
|
826
|
-
order_attrs =
|
824
|
+
order_attrs = ['CPU', 'MEMORY', 'NETTX', 'NETRX']
|
827
825
|
|
828
826
|
vm_monitoring_sort = []
|
829
827
|
order_attrs.each do |key|
|
@@ -834,7 +832,7 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
834
832
|
|
835
833
|
vm_monitoring_sort.sort_by {|a| a[0] }
|
836
834
|
|
837
|
-
filter_attrs =
|
835
|
+
filter_attrs = ['STATE', 'DISK_SIZE', 'SNAPSHOT_SIZE']
|
838
836
|
vm_monitoring.each do |key, val|
|
839
837
|
if !filter_attrs.include?(key)
|
840
838
|
vm_monitoring_sort << [key, val]
|
@@ -856,7 +854,7 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
856
854
|
|
857
855
|
CLIHelper.print_header(str_h1 % 'PERMISSIONS', false)
|
858
856
|
|
859
|
-
|
857
|
+
['OWNER', 'GROUP', 'OTHER'].each do |e|
|
860
858
|
mask = '---'
|
861
859
|
mask[0] = 'u' if vm["PERMISSIONS/#{e}_U"] == '1'
|
862
860
|
mask[1] = 'm' if vm["PERMISSIONS/#{e}_M"] == '1'
|
@@ -969,9 +967,7 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
969
967
|
end.show(vm_disks, {})
|
970
968
|
|
971
969
|
if !options[:all]
|
972
|
-
while vm.has_elements?('/VM/TEMPLATE/DISK')
|
973
|
-
vm.delete_element('/VM/TEMPLATE/DISK')
|
974
|
-
end
|
970
|
+
vm.delete_element('/VM/TEMPLATE/DISK') while vm.has_elements?('/VM/TEMPLATE/DISK')
|
975
971
|
end
|
976
972
|
end
|
977
973
|
|
@@ -1006,17 +1002,17 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
1006
1002
|
# array. Duplicate IPs are not shown.
|
1007
1003
|
extra_ips = []
|
1008
1004
|
|
1009
|
-
if (val = vm['/VM/MONITORING/GUEST_IP'])
|
1010
|
-
extra_ips << val
|
1005
|
+
if (val = vm['/VM/MONITORING/GUEST_IP']) && (val && !val.empty?)
|
1006
|
+
extra_ips << val
|
1011
1007
|
end
|
1012
1008
|
|
1013
|
-
if (val = vm['/VM/MONITORING/GUEST_IP_ADDRESSES'])
|
1014
|
-
extra_ips += val.split(',')
|
1009
|
+
if (val = vm['/VM/MONITORING/GUEST_IP_ADDRESSES']) && (val && !val.empty?)
|
1010
|
+
extra_ips += val.split(',')
|
1015
1011
|
end
|
1016
1012
|
|
1017
1013
|
extra_ips.uniq!
|
1018
1014
|
|
1019
|
-
|
1015
|
+
['NIC', 'NIC_ALIAS'].each do |type|
|
1020
1016
|
next unless vm.has_elements?("/VM/TEMPLATE/#{type}") ||
|
1021
1017
|
vm.has_elements?('/VM/TEMPLATE/PCI[NIC_ID>-1]') ||
|
1022
1018
|
!extra_ips.empty?
|
@@ -1052,7 +1048,7 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
1052
1048
|
vm_nics.each do |nic|
|
1053
1049
|
next if nic.key?('CLI_DONE')
|
1054
1050
|
|
1055
|
-
|
1051
|
+
['EXTERNAL_IP', 'IP6_LINK', 'IP6_ULA', 'IP6_GLOBAL', 'IP6'].each do |attr|
|
1056
1052
|
next unless nic.key?(attr)
|
1057
1053
|
|
1058
1054
|
shown_ips << nic[attr]
|
@@ -1065,8 +1061,8 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
1065
1061
|
array_id += 1
|
1066
1062
|
end
|
1067
1063
|
|
1068
|
-
|
1069
|
-
|
1064
|
+
['VROUTER_IP', 'VROUTER_IP6_LINK', 'VROUTER_IP6_ULA',
|
1065
|
+
'VROUTER_IP6_GLOBAL'].each do |attr|
|
1070
1066
|
next unless nic.key?(attr)
|
1071
1067
|
|
1072
1068
|
shown_ips << nic[attr]
|
@@ -1148,15 +1144,13 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
1148
1144
|
|
1149
1145
|
next if options[:all]
|
1150
1146
|
|
1151
|
-
while vm.has_elements?("/VM/TEMPLATE/#{type}")
|
1152
|
-
vm.delete_element("/VM/TEMPLATE/#{type}")
|
1153
|
-
end
|
1147
|
+
vm.delete_element("/VM/TEMPLATE/#{type}") while vm.has_elements?("/VM/TEMPLATE/#{type}")
|
1154
1148
|
end
|
1155
1149
|
|
1156
1150
|
if vm_hash['VM']['TEMPLATE']['NIC']
|
1157
1151
|
nic = [vm_hash['VM']['TEMPLATE']['NIC']]
|
1158
1152
|
nic = nic.flatten
|
1159
|
-
nic = nic.
|
1153
|
+
nic = nic.reject {|v| v['EXTERNAL_PORT_RANGE'].nil? }[0]
|
1160
1154
|
|
1161
1155
|
if nic
|
1162
1156
|
ip = vm_hash['VM']['HISTORY_RECORDS']['HISTORY']
|
@@ -1174,9 +1168,7 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
1174
1168
|
end
|
1175
1169
|
|
1176
1170
|
if !options[:all]
|
1177
|
-
while vm.has_elements?('/VM/TEMPLATE/NIC')
|
1178
|
-
vm.delete_element('/VM/TEMPLATE/NIC')
|
1179
|
-
end
|
1171
|
+
vm.delete_element('/VM/TEMPLATE/NIC') while vm.has_elements?('/VM/TEMPLATE/NIC')
|
1180
1172
|
end
|
1181
1173
|
|
1182
1174
|
if vm.has_elements?('/VM/TEMPLATE/SECURITY_GROUP_RULE') && !is_hybrid
|
@@ -1322,15 +1314,17 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
1322
1314
|
column :REPEAT, '', :adjust => true do |d|
|
1323
1315
|
str_rep = ''
|
1324
1316
|
if !d.nil? && d.key?('REPEAT')
|
1325
|
-
|
1317
|
+
case d['REPEAT']
|
1318
|
+
when '0'
|
1326
1319
|
str_rep << 'Weekly '
|
1327
|
-
|
1320
|
+
when '1'
|
1328
1321
|
str_rep << 'Monthly '
|
1329
|
-
|
1322
|
+
when '2'
|
1330
1323
|
str_rep << 'Yearly '
|
1331
|
-
|
1324
|
+
when '3'
|
1332
1325
|
str_rep << 'Each ' << d['DAYS'] << ' hours'
|
1333
1326
|
end
|
1327
|
+
|
1334
1328
|
if d['REPEAT'] != '3'
|
1335
1329
|
str_rep << d['DAYS']
|
1336
1330
|
end
|
@@ -1341,20 +1335,19 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
1341
1335
|
column :END, '', :adjust => true do |d|
|
1342
1336
|
str_end = ''
|
1343
1337
|
if !d.nil? && d.key?('END_TYPE')
|
1344
|
-
|
1338
|
+
case d['END_TYPE']
|
1339
|
+
when '0'
|
1345
1340
|
str_end << 'None'
|
1346
|
-
|
1341
|
+
when '1'
|
1347
1342
|
str_end << 'After ' << d['END_VALUE'] << ' times'
|
1348
|
-
|
1343
|
+
when '2'
|
1349
1344
|
str_end << 'On ' << \
|
1350
|
-
OpenNebulaHelper.time_to_str(d['END_VALUE'],
|
1351
|
-
false, false,
|
1352
|
-
true)
|
1345
|
+
OpenNebulaHelper.time_to_str(d['END_VALUE'], false, false, true)
|
1353
1346
|
end
|
1354
1347
|
end
|
1355
1348
|
str_end unless d.nil?
|
1356
1349
|
end
|
1357
|
-
column :STATUS, '', :left, :size => 50
|
1350
|
+
column :STATUS, '', :left, :size => 50 do |d|
|
1358
1351
|
if d['DONE'] && !d['REPEAT']
|
1359
1352
|
"Done on #{OpenNebulaHelper.time_to_str(d['DONE'], false)}"
|
1360
1353
|
elsif d['MESSAGE']
|
@@ -1377,7 +1370,7 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
1377
1370
|
elsif minutes > 0
|
1378
1371
|
"Next in #{minutes} minutes"
|
1379
1372
|
else
|
1380
|
-
|
1373
|
+
'Overdue!'
|
1381
1374
|
end
|
1382
1375
|
end
|
1383
1376
|
end
|
@@ -1427,18 +1420,18 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
|
1427
1420
|
def print_backups(vm, vm_hash)
|
1428
1421
|
if vm.has_elements?('/VM/BACKUPS/BACKUP_CONFIG')
|
1429
1422
|
puts
|
1430
|
-
CLIHelper.print_header('%-80s'
|
1423
|
+
CLIHelper.print_header(format('%-80s', 'BACKUP CONFIGURATION'), false)
|
1431
1424
|
puts vm.template_like_str('BACKUPS/BACKUP_CONFIG')
|
1432
1425
|
end
|
1433
1426
|
|
1434
|
-
|
1435
|
-
puts
|
1436
|
-
CLIHelper.print_header('%-80s' % 'VM BACKUPS', false)
|
1427
|
+
return unless vm.has_elements?('/VM/BACKUPS/BACKUP_IDS')
|
1437
1428
|
|
1438
|
-
|
1429
|
+
puts
|
1430
|
+
CLIHelper.print_header(format('%-80s', 'VM BACKUPS'), false)
|
1439
1431
|
|
1440
|
-
|
1441
|
-
|
1432
|
+
ids = [vm_hash['VM']['BACKUPS']['BACKUP_IDS']['ID']].flatten
|
1433
|
+
|
1434
|
+
puts format('IMAGE IDS: %s', ids.join(','))
|
1442
1435
|
end
|
1443
1436
|
|
1444
1437
|
def print_numa_nodes(numa_nodes)
|