opennebula-cli 7.2.0 → 7.3.80.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/oneflow +52 -1
- data/bin/onegroup +33 -0
- data/bin/oneimage +7 -2
- data/bin/onesecgroup +2 -1
- data/bin/onevm +27 -8
- data/bin/onevnet +6 -21
- data/bin/onevntemplate +3 -3
- data/lib/command_parser.rb +134 -125
- data/lib/load_opennebula_paths.rb +5 -0
- data/lib/ods_helper.rb +724 -0
- data/lib/one_helper/oneacct_helper.rb +116 -108
- data/lib/one_helper/onedatastore_helper.rb +86 -79
- data/lib/one_helper/onegroup_helper.rb +20 -0
- data/lib/one_helper/onehost_helper.rb +10 -1
- data/lib/one_helper/oneimage_helper.rb +9 -2
- data/lib/one_helper/onemarket_helper.rb +58 -57
- data/lib/one_helper/onequota_helper.rb +239 -189
- data/lib/one_helper/onesecgroup_helper.rb +86 -84
- data/lib/one_helper/onetemplate_helper.rb +63 -63
- data/lib/one_helper/onevdc_helper.rb +44 -44
- data/lib/one_helper/onevm_helper.rb +5 -12
- data/lib/one_helper/onevmgroup_helper.rb +65 -64
- data/lib/one_helper/onevnet_helper.rb +6 -2
- data/lib/one_helper/onevntemplate_helper.rb +42 -39
- data/lib/one_helper/onevrouter_helper.rb +85 -86
- data/lib/one_helper/onezone_helper.rb +97 -100
- data/lib/one_helper.rb +102 -70
- data/share/schemas/xsd/acct.xsd +3 -104
- data/share/schemas/xsd/backupjob.xsd +1 -0
- data/share/schemas/xsd/cluster.xsd +4 -21
- data/share/schemas/xsd/datastore.xsd +4 -29
- data/share/schemas/xsd/document.xsd +3 -25
- data/share/schemas/xsd/group.xsd +17 -13
- data/share/schemas/xsd/group_pool.xsd +18 -14
- data/share/schemas/xsd/hook.xsd +2 -0
- data/share/schemas/xsd/host.xsd +5 -7
- data/share/schemas/xsd/image.xsd +2 -25
- data/share/schemas/xsd/marketplace.xsd +3 -22
- data/share/schemas/xsd/marketplaceapp.xsd +3 -25
- data/share/schemas/xsd/opennebula_configuration.xsd +2 -0
- data/share/schemas/xsd/requirements.xsd +3 -21
- data/share/schemas/xsd/security_group.xsd +6 -43
- data/share/schemas/xsd/shared.xsd +3 -3
- data/share/schemas/xsd/vdc.xsd +2 -7
- data/share/schemas/xsd/vm.xsd +2 -0
- data/share/schemas/xsd/vm_group.xsd +3 -25
- data/share/schemas/xsd/vm_pool.xsd +2 -0
- data/share/schemas/xsd/vmtemplate.xsd +3 -25
- data/share/schemas/xsd/vnet.xsd +13 -67
- data/share/schemas/xsd/vnet_pool.xsd +13 -58
- data/share/schemas/xsd/vntemplate.xsd +3 -25
- data/share/schemas/xsd/vrouter.xsd +4 -32
- metadata +8 -6
data/lib/one_helper.rb
CHANGED
|
@@ -20,18 +20,20 @@ require 'io/console'
|
|
|
20
20
|
require 'time'
|
|
21
21
|
require 'io/wait'
|
|
22
22
|
require 'logger'
|
|
23
|
+
require 'English'
|
|
23
24
|
|
|
24
25
|
begin
|
|
25
26
|
require 'opennebula/version'
|
|
26
27
|
require 'opennebula/lib/client'
|
|
27
28
|
require 'opennebula/pool'
|
|
28
|
-
rescue
|
|
29
|
-
puts 'Error: '+e.message.to_s
|
|
29
|
+
rescue StandardError => e
|
|
30
|
+
puts 'Error: ' + e.message.to_s
|
|
30
31
|
exit(-1)
|
|
31
32
|
end
|
|
32
33
|
|
|
33
34
|
include OpenNebula
|
|
34
35
|
|
|
36
|
+
# OpenNebulaHelper module provides common methods for CLI helpers
|
|
35
37
|
module OpenNebulaHelper
|
|
36
38
|
|
|
37
39
|
ONE_VERSION=<<~EOT
|
|
@@ -175,7 +177,7 @@ Bash symbols must be escaped on STDIN passing'
|
|
|
175
177
|
{
|
|
176
178
|
:name => 'grpc',
|
|
177
179
|
:large => '--grpc',
|
|
178
|
-
:description => 'Use gRPC protocol to connect to OpenNebula'
|
|
180
|
+
:description => 'Use gRPC protocol to connect to OpenNebula'
|
|
179
181
|
}
|
|
180
182
|
]
|
|
181
183
|
|
|
@@ -219,7 +221,7 @@ Bash symbols must be escaped on STDIN passing'
|
|
|
219
221
|
:description =>
|
|
220
222
|
'Which resources can be created by group users '<<
|
|
221
223
|
'(VM+NET+IMAGE+TEMPLATE by default)',
|
|
222
|
-
:format =>
|
|
224
|
+
:format => Object
|
|
223
225
|
}
|
|
224
226
|
]
|
|
225
227
|
|
|
@@ -431,7 +433,7 @@ Bash symbols must be escaped on STDIN passing'
|
|
|
431
433
|
options[:user_inputs_keys] = keys
|
|
432
434
|
|
|
433
435
|
options[:user_inputs] = keys.zip(values).map do |k, v|
|
|
434
|
-
%
|
|
436
|
+
%(#{k}="#{v}")
|
|
435
437
|
end.join("\n")
|
|
436
438
|
end
|
|
437
439
|
},
|
|
@@ -591,6 +593,8 @@ Bash symbols must be escaped on STDIN passing'
|
|
|
591
593
|
|
|
592
594
|
BACKUP_MODES = ['FULL', 'INCREMENT']
|
|
593
595
|
|
|
596
|
+
# rubocop:disable Style/ClassVars
|
|
597
|
+
# Base class for all OpenNebula CLI helper classes
|
|
594
598
|
class OneHelper
|
|
595
599
|
|
|
596
600
|
attr_accessor :client
|
|
@@ -642,6 +646,7 @@ Bash symbols must be escaped on STDIN passing'
|
|
|
642
646
|
end
|
|
643
647
|
end
|
|
644
648
|
|
|
649
|
+
# rubocop:disable Naming/AccessorMethodName
|
|
645
650
|
def self.set_user(user)
|
|
646
651
|
@@user=user
|
|
647
652
|
end
|
|
@@ -680,6 +685,8 @@ Bash symbols must be escaped on STDIN passing'
|
|
|
680
685
|
end
|
|
681
686
|
end
|
|
682
687
|
end
|
|
688
|
+
# rubocop:enable Naming/AccessorMethodName
|
|
689
|
+
# rubocop:enable Style/ClassVars
|
|
683
690
|
|
|
684
691
|
def self.list_layout_help
|
|
685
692
|
"The default columns and their layout can be configured in #{conf_file}"
|
|
@@ -805,12 +812,11 @@ Bash symbols must be escaped on STDIN passing'
|
|
|
805
812
|
# output
|
|
806
813
|
#-----------------------------------------------------------------------
|
|
807
814
|
def list_pool_table(table, pool, options, _filter_flag)
|
|
808
|
-
if $stdout.isatty
|
|
815
|
+
if $stdout.isatty && (!options.key? :no_pager)
|
|
809
816
|
size = $stdout.winsize[0] - 1
|
|
810
817
|
|
|
811
818
|
# ----------- First page, check if pager is needed -------------
|
|
812
819
|
rc = pool.get_page(size, 0, false, options[:state])
|
|
813
|
-
ps = ''
|
|
814
820
|
|
|
815
821
|
return -1, rc.message if OpenNebula.is_error?(rc)
|
|
816
822
|
|
|
@@ -868,8 +874,8 @@ Bash symbols must be escaped on STDIN passing'
|
|
|
868
874
|
|
|
869
875
|
if options[:ids] && elements
|
|
870
876
|
hash = [hash[pool.pool_name][pool.element_name]].flatten
|
|
871
|
-
hash.
|
|
872
|
-
|
|
877
|
+
hash.select! do |element|
|
|
878
|
+
options[:ids].include?(element['ID'].to_i)
|
|
873
879
|
end
|
|
874
880
|
end
|
|
875
881
|
|
|
@@ -885,12 +891,11 @@ Bash symbols must be escaped on STDIN passing'
|
|
|
885
891
|
def list_pool_xml(pool, options, _filter_flag)
|
|
886
892
|
extended = options.include?(:extended) && options[:extended]
|
|
887
893
|
|
|
888
|
-
if $stdout.isatty
|
|
894
|
+
if $stdout.isatty && (!options.key? :no_pager)
|
|
889
895
|
size = $stdout.winsize[0] - 1
|
|
890
896
|
|
|
891
897
|
# ----------- First page, check if pager is needed -------------
|
|
892
898
|
rc = pool.get_page(size, 0, extended, options[:state])
|
|
893
|
-
ps = ''
|
|
894
899
|
|
|
895
900
|
return -1, rc.message if OpenNebula.is_error?(rc)
|
|
896
901
|
|
|
@@ -966,12 +971,11 @@ Bash symbols must be escaped on STDIN passing'
|
|
|
966
971
|
def list_pool_format(pool, options, _filter_flag)
|
|
967
972
|
extended = options.include?(:extended) && options[:extended]
|
|
968
973
|
|
|
969
|
-
if $stdout.isatty
|
|
974
|
+
if $stdout.isatty && (!options.key? :no_pager)
|
|
970
975
|
size = $stdout.winsize[0] - 1
|
|
971
976
|
|
|
972
977
|
# ----------- First page, check if pager is needed -------------
|
|
973
978
|
rc = pool.get_page(size, 0, extended, options[:state])
|
|
974
|
-
ps = ''
|
|
975
979
|
|
|
976
980
|
return -1, rc.message if OpenNebula.is_error?(rc)
|
|
977
981
|
|
|
@@ -1067,27 +1071,24 @@ Bash symbols must be escaped on STDIN passing'
|
|
|
1067
1071
|
|
|
1068
1072
|
pool = factory_pool(filter_flag)
|
|
1069
1073
|
pname = pool.pool_name
|
|
1070
|
-
ename = pool.element_name
|
|
1071
1074
|
|
|
1072
1075
|
if top
|
|
1073
1076
|
return list_pool_top(table, pool, options)
|
|
1074
1077
|
elsif options[:xml]
|
|
1075
1078
|
return list_pool_xml(pool, options, filter_flag)
|
|
1076
1079
|
elsif options[:json]
|
|
1077
|
-
return list_pool_format(pool, options, filter_flag) do |
|
|
1078
|
-
hash = check_resource_xsd(
|
|
1080
|
+
return list_pool_format(pool, options, filter_flag) do |p|
|
|
1081
|
+
hash = check_resource_xsd(p, pname)
|
|
1079
1082
|
puts ::JSON.pretty_generate(hash)
|
|
1080
1083
|
end
|
|
1081
1084
|
elsif options[:yaml]
|
|
1082
|
-
return list_pool_format(pool, options, filter_flag) do |
|
|
1083
|
-
hash = check_resource_xsd(
|
|
1085
|
+
return list_pool_format(pool, options, filter_flag) do |p|
|
|
1086
|
+
hash = check_resource_xsd(p, pname)
|
|
1084
1087
|
puts hash.to_yaml(:indent => 4)
|
|
1085
1088
|
end
|
|
1086
1089
|
else
|
|
1087
1090
|
return list_pool_table(table, pool, options, filter_flag)
|
|
1088
1091
|
end
|
|
1089
|
-
|
|
1090
|
-
0
|
|
1091
1092
|
rescue SystemExit, Interrupt
|
|
1092
1093
|
# Rescue ctrl + c when paginated
|
|
1093
1094
|
0
|
|
@@ -1241,14 +1242,14 @@ Bash symbols must be escaped on STDIN passing'
|
|
|
1241
1242
|
end
|
|
1242
1243
|
|
|
1243
1244
|
def self.name_to_id(name, pool, ename)
|
|
1244
|
-
if ename=='CLUSTER'
|
|
1245
|
+
if ename == 'CLUSTER' && name.upcase == 'ALL'
|
|
1245
1246
|
return 0, 'ALL'
|
|
1246
1247
|
end
|
|
1247
1248
|
|
|
1248
|
-
objects=pool.select {|object| object.name==name }
|
|
1249
|
+
objects = pool.select {|object| object.name == name }
|
|
1249
1250
|
|
|
1250
|
-
return -1, "#{ename} named #{name} not found."
|
|
1251
|
-
return -1, "There are multiple #{ename}s with name #{name}." if objects.length>1
|
|
1251
|
+
return -1, "#{ename} named #{name} not found." if objects.empty?
|
|
1252
|
+
return -1, "There are multiple #{ename}s with name #{name}." if objects.length > 1
|
|
1252
1253
|
|
|
1253
1254
|
result = objects.first.id
|
|
1254
1255
|
|
|
@@ -1277,7 +1278,7 @@ Bash symbols must be escaped on STDIN passing'
|
|
|
1277
1278
|
end
|
|
1278
1279
|
|
|
1279
1280
|
def self.filterflag_to_i_desc
|
|
1280
|
-
|
|
1281
|
+
<<~EOT
|
|
1281
1282
|
a, all all the known #{rname}s
|
|
1282
1283
|
m, mine the #{rname} belonging to the user in ONE_AUTH
|
|
1283
1284
|
g, group 'mine' plus the #{rname} belonging to the groups
|
|
@@ -1289,7 +1290,7 @@ Bash symbols must be escaped on STDIN passing'
|
|
|
1289
1290
|
end
|
|
1290
1291
|
|
|
1291
1292
|
def self.table_conf(conf_file = self.conf_file)
|
|
1292
|
-
path = "#{
|
|
1293
|
+
path = "#{Dir.home}/.one/cli/#{conf_file}"
|
|
1293
1294
|
|
|
1294
1295
|
if File.exist?(path)
|
|
1295
1296
|
path
|
|
@@ -1314,11 +1315,11 @@ Bash symbols must be escaped on STDIN passing'
|
|
|
1314
1315
|
rname = self.class.rname
|
|
1315
1316
|
|
|
1316
1317
|
if phash["#{rname}_POOL"] &&
|
|
1317
|
-
phash["#{rname}_POOL"][
|
|
1318
|
-
if phash["#{rname}_POOL"][
|
|
1319
|
-
phash = phash["#{rname}_POOL"][
|
|
1318
|
+
phash["#{rname}_POOL"][rname]
|
|
1319
|
+
if phash["#{rname}_POOL"][rname].instance_of?(Array)
|
|
1320
|
+
phash = phash["#{rname}_POOL"][rname]
|
|
1320
1321
|
else
|
|
1321
|
-
phash = [phash["#{rname}_POOL"][
|
|
1322
|
+
phash = [phash["#{rname}_POOL"][rname]]
|
|
1322
1323
|
end
|
|
1323
1324
|
else
|
|
1324
1325
|
phash = []
|
|
@@ -1327,7 +1328,9 @@ Bash symbols must be escaped on STDIN passing'
|
|
|
1327
1328
|
phash
|
|
1328
1329
|
end
|
|
1329
1330
|
|
|
1331
|
+
# rubocop:disable Naming/AccessorMethodName
|
|
1330
1332
|
def get_pool
|
|
1333
|
+
# rubocop:enable Naming/AccessorMethodName
|
|
1331
1334
|
user_flag = OpenNebula::Pool::INFO_ALL
|
|
1332
1335
|
pool = factory_pool(user_flag)
|
|
1333
1336
|
|
|
@@ -1377,7 +1380,9 @@ Bash symbols must be escaped on STDIN passing'
|
|
|
1377
1380
|
xsd = xsd['element']
|
|
1378
1381
|
end
|
|
1379
1382
|
|
|
1383
|
+
# rubocop:disable Style/ArrayCoercion
|
|
1380
1384
|
xsd = [xsd] unless xsd.is_a? Array
|
|
1385
|
+
# rubocop:enable Style/ArrayCoercion
|
|
1381
1386
|
|
|
1382
1387
|
check_xsd(hash[ename], xsd)
|
|
1383
1388
|
|
|
@@ -1483,7 +1488,7 @@ Bash symbols must be escaped on STDIN passing'
|
|
|
1483
1488
|
# @param xsd [Hash] XSD of the resource, transformed into hash
|
|
1484
1489
|
#
|
|
1485
1490
|
def check_xsd(hash, xsd)
|
|
1486
|
-
return unless hash
|
|
1491
|
+
return unless hash || hash.empty?
|
|
1487
1492
|
|
|
1488
1493
|
hash.each do |k, v|
|
|
1489
1494
|
# find the elem definition in xsd array
|
|
@@ -1559,6 +1564,9 @@ Bash symbols must be escaped on STDIN passing'
|
|
|
1559
1564
|
when 'VM'
|
|
1560
1565
|
require 'opennebula/virtual_machine_pool'
|
|
1561
1566
|
OpenNebula::VirtualMachinePool.new(client)
|
|
1567
|
+
when 'VMGROUP'
|
|
1568
|
+
require 'opennebula/vm_group_pool'
|
|
1569
|
+
OpenNebula::VMGroupPool.new(client)
|
|
1562
1570
|
when 'ZONE'
|
|
1563
1571
|
require 'opennebula/zone_pool'
|
|
1564
1572
|
OpenNebula::ZonePool.new(client)
|
|
@@ -1602,7 +1610,7 @@ Bash symbols must be escaped on STDIN passing'
|
|
|
1602
1610
|
end
|
|
1603
1611
|
|
|
1604
1612
|
def self.rname_to_id_desc(poolname)
|
|
1605
|
-
"OpenNebula #{poolname}
|
|
1613
|
+
"OpenNebula #{poolname} id"
|
|
1606
1614
|
end
|
|
1607
1615
|
|
|
1608
1616
|
def self.boolean_to_str(str)
|
|
@@ -1615,7 +1623,6 @@ Bash symbols must be escaped on STDIN passing'
|
|
|
1615
1623
|
|
|
1616
1624
|
def self.time_to_str(time, print_seconds = true,
|
|
1617
1625
|
print_hours = true, print_years = false)
|
|
1618
|
-
|
|
1619
1626
|
value = time.to_i
|
|
1620
1627
|
|
|
1621
1628
|
if value==0
|
|
@@ -1654,9 +1661,11 @@ Bash symbols must be escaped on STDIN passing'
|
|
|
1654
1661
|
days, hours=hours.divmod(24)
|
|
1655
1662
|
|
|
1656
1663
|
if print_seconds
|
|
1657
|
-
format('
|
|
1664
|
+
format('%<days>3dd %<hours>02dh%<minutes>02dm%<seconds>02ds',
|
|
1665
|
+
:days => days, :hours => hours, :minutes => minutes, :seconds => seconds)
|
|
1658
1666
|
else
|
|
1659
|
-
format('
|
|
1667
|
+
format('%<days>3dd %<hours>02dh%<minutes>02dm',
|
|
1668
|
+
:days => days, :hours => hours, :minutes => minutes)
|
|
1660
1669
|
end
|
|
1661
1670
|
end
|
|
1662
1671
|
|
|
@@ -1666,35 +1675,36 @@ Bash symbols must be escaped on STDIN passing'
|
|
|
1666
1675
|
hours, minutes=minutes.divmod(60)
|
|
1667
1676
|
|
|
1668
1677
|
if print_seconds
|
|
1669
|
-
format('
|
|
1678
|
+
format('%<hours>3dh%<minutes>02dm%<seconds>02ds',
|
|
1679
|
+
:hours => hours, :minutes => minutes, :seconds => seconds)
|
|
1670
1680
|
else
|
|
1671
|
-
format('
|
|
1681
|
+
format('%<hours>3dh%<minutes>02dm', :hours => hours, :minutes => minutes)
|
|
1672
1682
|
end
|
|
1673
1683
|
end
|
|
1674
1684
|
|
|
1675
|
-
|
|
1685
|
+
BINARY_SUFFIX = ['K', 'M', 'G', 'T']
|
|
1676
1686
|
|
|
1677
1687
|
def self.unit_to_str(value, options, unit = 'K')
|
|
1678
1688
|
if options[:kilobytes]
|
|
1679
1689
|
value
|
|
1680
1690
|
else
|
|
1681
|
-
i=
|
|
1691
|
+
i = BINARY_SUFFIX.index(unit).to_i
|
|
1682
1692
|
|
|
1683
1693
|
while value > 1024 && i < 3
|
|
1684
1694
|
value /= 1024.0
|
|
1685
|
-
i+=1
|
|
1695
|
+
i += 1
|
|
1686
1696
|
end
|
|
1687
1697
|
|
|
1688
1698
|
value = (value * 10).round / 10.0
|
|
1689
1699
|
|
|
1690
1700
|
value = value.to_i if value - value.round == 0
|
|
1691
|
-
|
|
1701
|
+
value.to_s + BINARY_SUFFIX[i]
|
|
1692
1702
|
end
|
|
1693
1703
|
end
|
|
1694
1704
|
|
|
1695
1705
|
def self.bytes_to_unit(value, unit = 'K')
|
|
1696
1706
|
j = 0
|
|
1697
|
-
i =
|
|
1707
|
+
i = BINARY_SUFFIX.index(unit).to_i
|
|
1698
1708
|
|
|
1699
1709
|
while j < i
|
|
1700
1710
|
value /= 1024.0
|
|
@@ -1732,10 +1742,12 @@ Bash symbols must be escaped on STDIN passing'
|
|
|
1732
1742
|
update_template_helper(true, id, resource, path, xpath)
|
|
1733
1743
|
end
|
|
1734
1744
|
|
|
1745
|
+
# rubocop:disable Metrics/ParameterLists
|
|
1735
1746
|
def self.update_template_helper(append, _id, resource, path, xpath, update = true)
|
|
1747
|
+
# rubocop:enable Metrics/ParameterLists
|
|
1736
1748
|
if path
|
|
1737
1749
|
File.read(path)
|
|
1738
|
-
elsif !(stdin =
|
|
1750
|
+
elsif !(stdin = read_stdin).empty?
|
|
1739
1751
|
stdin
|
|
1740
1752
|
elsif append
|
|
1741
1753
|
editor_input
|
|
@@ -1803,7 +1815,7 @@ Bash symbols must be escaped on STDIN passing'
|
|
|
1803
1815
|
editor_path = ENV['EDITOR'] ? ENV['EDITOR'] : EDITOR_PATH
|
|
1804
1816
|
system("#{editor_path} #{tmp.path}")
|
|
1805
1817
|
|
|
1806
|
-
unless
|
|
1818
|
+
unless $CHILD_STATUS.exitstatus == 0
|
|
1807
1819
|
puts 'Editor not defined'
|
|
1808
1820
|
exit(-1)
|
|
1809
1821
|
end
|
|
@@ -1863,7 +1875,11 @@ Bash symbols must be escaped on STDIN passing'
|
|
|
1863
1875
|
user, object=*res
|
|
1864
1876
|
|
|
1865
1877
|
template<<"#{section.upcase}=[\n"
|
|
1866
|
-
if
|
|
1878
|
+
if section.upcase == 'NIC' && ['auto', 'dummy'].include?(object.downcase)
|
|
1879
|
+
extra_attributes.each do |extra_attribute|
|
|
1880
|
+
key, value = extra_attribute.split('=')
|
|
1881
|
+
template<<" #{key.upcase}=\"#{value}\",\n"
|
|
1882
|
+
end
|
|
1867
1883
|
template<<" NETWORK_MODE=\"#{object}\"\n"
|
|
1868
1884
|
else
|
|
1869
1885
|
template<<" #{name.upcase}_UNAME=\"#{user}\",\n" if user
|
|
@@ -1889,11 +1905,11 @@ Bash symbols must be escaped on STDIN passing'
|
|
|
1889
1905
|
if !(options.keys & context_options).empty?
|
|
1890
1906
|
if options[:ssh]
|
|
1891
1907
|
if options[:ssh]==true
|
|
1892
|
-
context_hash['SSH_PUBLIC_KEY'] =
|
|
1908
|
+
context_hash['SSH_PUBLIC_KEY'] = '$USER[SSH_PUBLIC_KEY]'
|
|
1893
1909
|
else
|
|
1894
1910
|
begin
|
|
1895
1911
|
key=File.read(options[:ssh]).strip
|
|
1896
|
-
rescue
|
|
1912
|
+
rescue StandardError => e
|
|
1897
1913
|
STDERR.puts e.message
|
|
1898
1914
|
exit(-1)
|
|
1899
1915
|
end
|
|
@@ -1902,24 +1918,24 @@ Bash symbols must be escaped on STDIN passing'
|
|
|
1902
1918
|
end
|
|
1903
1919
|
|
|
1904
1920
|
if options[:net_context]
|
|
1905
|
-
context_hash['NETWORK'] =
|
|
1921
|
+
context_hash['NETWORK'] = 'YES'
|
|
1906
1922
|
end
|
|
1907
1923
|
|
|
1908
1924
|
if options[:files_ds]
|
|
1909
|
-
files = options[:files_ds].map {
|
|
1925
|
+
files = options[:files_ds].map {|file| %($FILE[IMAGE=\\"#{file}\\"]) }.join(' ')
|
|
1910
1926
|
|
|
1911
1927
|
context_hash['FILES_DS'] = files
|
|
1912
1928
|
end
|
|
1913
1929
|
|
|
1914
1930
|
if options[:init]
|
|
1915
|
-
context_hash['INIT_SCRIPTS'] = options[:init].join(
|
|
1931
|
+
context_hash['INIT_SCRIPTS'] = options[:init].join(' ')
|
|
1916
1932
|
end
|
|
1917
1933
|
|
|
1918
1934
|
if options[:startscript]
|
|
1919
1935
|
script = nil
|
|
1920
1936
|
begin
|
|
1921
1937
|
script = File.read(options[:startscript]).strip
|
|
1922
|
-
rescue
|
|
1938
|
+
rescue StandardError => e
|
|
1923
1939
|
STDERR.puts e.message
|
|
1924
1940
|
exit(-1)
|
|
1925
1941
|
end
|
|
@@ -1929,15 +1945,17 @@ Bash symbols must be escaped on STDIN passing'
|
|
|
1929
1945
|
end
|
|
1930
1946
|
|
|
1931
1947
|
if options[:report_ready]
|
|
1932
|
-
context_hash['REPORT_READY'] =
|
|
1948
|
+
context_hash['REPORT_READY'] = 'YES'
|
|
1933
1949
|
end
|
|
1934
1950
|
|
|
1935
1951
|
if context_hash.any? || options[:context]
|
|
1936
1952
|
formatted_context = "CONTEXT=[\n"
|
|
1937
|
-
formatted_context << options[:context].map {|l|
|
|
1953
|
+
formatted_context << options[:context].map {|l|
|
|
1954
|
+
' ' << l
|
|
1955
|
+
}.join(",\n") if options[:context]
|
|
1938
1956
|
if context_hash.any?
|
|
1939
1957
|
formatted_context << ",\n" if options[:context]
|
|
1940
|
-
formatted_context << context_hash.map {
|
|
1958
|
+
formatted_context << context_hash.map {|k, v| " #{k}=\"#{v}\"" }.join(",\n")
|
|
1941
1959
|
end
|
|
1942
1960
|
formatted_context << "\n]\n"
|
|
1943
1961
|
formatted_context
|
|
@@ -2023,7 +2041,7 @@ Bash symbols must be escaped on STDIN passing'
|
|
|
2023
2041
|
|
|
2024
2042
|
context_hash = {}
|
|
2025
2043
|
if !template_obj.nil? && template_obj.has_elements?('TEMPLATE/CONTEXT')
|
|
2026
|
-
context_hash = template_obj.to_hash[
|
|
2044
|
+
context_hash = template_obj.to_hash['VMTEMPLATE']['TEMPLATE']['CONTEXT']
|
|
2027
2045
|
end
|
|
2028
2046
|
context_str=create_context_str(options, context_hash)
|
|
2029
2047
|
template<<context_str if context_str
|
|
@@ -2124,15 +2142,16 @@ Bash symbols must be escaped on STDIN passing'
|
|
|
2124
2142
|
|
|
2125
2143
|
def self.level_lock_to_str(str)
|
|
2126
2144
|
level = str.to_i
|
|
2127
|
-
|
|
2145
|
+
case level
|
|
2146
|
+
when 0
|
|
2128
2147
|
'None'
|
|
2129
|
-
|
|
2148
|
+
when 1
|
|
2130
2149
|
'Use'
|
|
2131
|
-
|
|
2150
|
+
when 2
|
|
2132
2151
|
'Manage'
|
|
2133
|
-
|
|
2152
|
+
when 3
|
|
2134
2153
|
'Admin'
|
|
2135
|
-
|
|
2154
|
+
when 4
|
|
2136
2155
|
'All'
|
|
2137
2156
|
else
|
|
2138
2157
|
'-'
|
|
@@ -2232,13 +2251,17 @@ Bash symbols must be escaped on STDIN passing'
|
|
|
2232
2251
|
exp = OneTemplateHelper::FLOAT_EXP
|
|
2233
2252
|
end
|
|
2234
2253
|
|
|
2235
|
-
|
|
2254
|
+
noanswer = false
|
|
2255
|
+
|
|
2256
|
+
loop do
|
|
2236
2257
|
print header
|
|
2237
2258
|
answer = STDIN.readline.chop
|
|
2238
2259
|
|
|
2239
2260
|
answer = initial if answer == ''
|
|
2240
2261
|
noanswer = (answer == '') && optional
|
|
2241
|
-
|
|
2262
|
+
|
|
2263
|
+
break if noanswer || !(answer =~ exp).nil?
|
|
2264
|
+
end
|
|
2242
2265
|
|
|
2243
2266
|
if noanswer
|
|
2244
2267
|
next
|
|
@@ -2268,15 +2291,19 @@ Bash symbols must be escaped on STDIN passing'
|
|
|
2268
2291
|
header += "Float in the range [#{min}..#{max}]: "
|
|
2269
2292
|
end
|
|
2270
2293
|
|
|
2271
|
-
|
|
2294
|
+
noanswer = false
|
|
2295
|
+
|
|
2296
|
+
loop do
|
|
2272
2297
|
print header
|
|
2273
2298
|
answer = STDIN.readline.chop
|
|
2274
2299
|
|
|
2275
2300
|
answer = initial if answer == ''
|
|
2276
2301
|
|
|
2277
2302
|
noanswer = (answer == '') && optional
|
|
2278
|
-
|
|
2279
|
-
|
|
2303
|
+
|
|
2304
|
+
break if noanswer || (!(answer =~ exp).nil? &&
|
|
2305
|
+
answer.to_f >= min && answer.to_f <= max)
|
|
2306
|
+
end
|
|
2280
2307
|
|
|
2281
2308
|
if noanswer
|
|
2282
2309
|
next
|
|
@@ -2293,7 +2320,9 @@ Bash symbols must be escaped on STDIN passing'
|
|
|
2293
2320
|
|
|
2294
2321
|
header += 'Please type the selection number: '
|
|
2295
2322
|
|
|
2296
|
-
|
|
2323
|
+
noanswer = false
|
|
2324
|
+
|
|
2325
|
+
loop do
|
|
2297
2326
|
print header
|
|
2298
2327
|
answer = STDIN.readline.chop
|
|
2299
2328
|
|
|
@@ -2304,7 +2333,9 @@ Bash symbols must be escaped on STDIN passing'
|
|
|
2304
2333
|
end
|
|
2305
2334
|
|
|
2306
2335
|
noanswer = (answer == '') && optional
|
|
2307
|
-
|
|
2336
|
+
|
|
2337
|
+
break if noanswer || options.include?(answer)
|
|
2338
|
+
end
|
|
2308
2339
|
|
|
2309
2340
|
if noanswer
|
|
2310
2341
|
next
|
|
@@ -2338,7 +2369,7 @@ Bash symbols must be escaped on STDIN passing'
|
|
|
2338
2369
|
# Require gnuplot gem only here
|
|
2339
2370
|
begin
|
|
2340
2371
|
require 'gnuplot'
|
|
2341
|
-
rescue LoadError
|
|
2372
|
+
rescue LoadError
|
|
2342
2373
|
STDERR.puts(
|
|
2343
2374
|
'Gnuplot gem is not installed, run `gem install gnuplot` '\
|
|
2344
2375
|
'to install it'
|
|
@@ -2581,9 +2612,10 @@ Bash symbols must be escaped on STDIN passing'
|
|
|
2581
2612
|
|
|
2582
2613
|
def self.read_stdin
|
|
2583
2614
|
if STDIN.wait_readable(0)
|
|
2584
|
-
STDIN.read
|
|
2615
|
+
STDIN.read
|
|
2585
2616
|
else
|
|
2586
|
-
|
|
2617
|
+
''
|
|
2587
2618
|
end
|
|
2588
2619
|
end
|
|
2620
|
+
|
|
2589
2621
|
end
|
data/share/schemas/xsd/acct.xsd
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
2
|
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
|
|
3
3
|
targetNamespace="http://opennebula.org/XMLSchema" xmlns="http://opennebula.org/XMLSchema">
|
|
4
|
+
<xs:include schemaLocation="shared.xsd"/>
|
|
5
|
+
<xs:include schemaLocation="vm.xsd"/>
|
|
4
6
|
|
|
5
7
|
<xs:element name="HISTORY_RECORDS">
|
|
6
8
|
<xs:complexType>
|
|
@@ -84,110 +86,7 @@
|
|
|
84
86
|
<xs:element name="UID" type="xs:integer"/>
|
|
85
87
|
<xs:element name="GID" type="xs:integer"/>
|
|
86
88
|
<xs:element name="REQUEST_ID" type="xs:string"/>
|
|
87
|
-
<xs:element
|
|
88
|
-
<xs:complexType>
|
|
89
|
-
<xs:sequence>
|
|
90
|
-
<xs:element name="ID" type="xs:integer"/>
|
|
91
|
-
<xs:element name="UID" type="xs:integer"/>
|
|
92
|
-
<xs:element name="GID" type="xs:integer"/>
|
|
93
|
-
<xs:element name="UNAME" type="xs:string"/>
|
|
94
|
-
<xs:element name="GNAME" type="xs:string"/>
|
|
95
|
-
<xs:element name="NAME" type="xs:string"/>
|
|
96
|
-
<xs:element name="PERMISSIONS" minOccurs="0" maxOccurs="1">
|
|
97
|
-
<xs:complexType>
|
|
98
|
-
<xs:sequence>
|
|
99
|
-
<xs:element name="OWNER_U" type="xs:integer"/>
|
|
100
|
-
<xs:element name="OWNER_M" type="xs:integer"/>
|
|
101
|
-
<xs:element name="OWNER_A" type="xs:integer"/>
|
|
102
|
-
<xs:element name="GROUP_U" type="xs:integer"/>
|
|
103
|
-
<xs:element name="GROUP_M" type="xs:integer"/>
|
|
104
|
-
<xs:element name="GROUP_A" type="xs:integer"/>
|
|
105
|
-
<xs:element name="OTHER_U" type="xs:integer"/>
|
|
106
|
-
<xs:element name="OTHER_M" type="xs:integer"/>
|
|
107
|
-
<xs:element name="OTHER_A" type="xs:integer"/>
|
|
108
|
-
</xs:sequence>
|
|
109
|
-
</xs:complexType>
|
|
110
|
-
</xs:element>
|
|
111
|
-
<xs:element name="LAST_POLL" type="xs:integer"/>
|
|
112
|
-
|
|
113
|
-
<!-- STATE values,
|
|
114
|
-
see http://docs.opennebula.org/stable/user/references/vm_states.html
|
|
115
|
-
-->
|
|
116
|
-
<xs:element name="STATE" type="xs:integer"/>
|
|
117
|
-
|
|
118
|
-
<!-- LCM_STATE values, this sub-state is relevant only when STATE is
|
|
119
|
-
ACTIVE (4)
|
|
120
|
-
see http://docs.opennebula.org/stable/user/references/vm_states.html
|
|
121
|
-
-->
|
|
122
|
-
<xs:element name="LCM_STATE" type="xs:integer"/>
|
|
123
|
-
<xs:element name="PREV_STATE" type="xs:integer"/>
|
|
124
|
-
<xs:element name="PREV_LCM_STATE" type="xs:integer"/>
|
|
125
|
-
<xs:element name="RESCHED" type="xs:integer"/>
|
|
126
|
-
<xs:element name="STIME" type="xs:integer"/>
|
|
127
|
-
<xs:element name="ETIME" type="xs:integer"/>
|
|
128
|
-
<xs:element name="DEPLOY_ID" type="xs:string"/>
|
|
129
|
-
<xs:element name="MONITORING"/>
|
|
130
|
-
<xs:element name="SCHED_ACTIONS" type="xs:anyType"/>
|
|
131
|
-
<xs:element name="TEMPLATE" type="xs:anyType"/>
|
|
132
|
-
<xs:element name="USER_TEMPLATE" type="xs:anyType"/>
|
|
133
|
-
<xs:element name="HISTORY_RECORDS">
|
|
134
|
-
</xs:element>
|
|
135
|
-
<xs:element name="SNAPSHOTS" minOccurs="0" maxOccurs="unbounded">
|
|
136
|
-
<xs:complexType>
|
|
137
|
-
<xs:sequence>
|
|
138
|
-
<xs:element name="ALLOW_ORPHANS" type="xs:string"/>
|
|
139
|
-
<xs:element name="CURRENT_BASE" type="xs:integer"/>
|
|
140
|
-
<xs:element name="DISK_ID" type="xs:integer"/>
|
|
141
|
-
<xs:element name="NEXT_SNAPSHOT" type="xs:integer"/>
|
|
142
|
-
<xs:element name="SNAPSHOT" minOccurs="0" maxOccurs="unbounded">
|
|
143
|
-
<xs:complexType>
|
|
144
|
-
<xs:sequence>
|
|
145
|
-
<xs:element name="ACTIVE" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
|
146
|
-
<xs:element name="CHILDREN" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
|
147
|
-
<xs:element name="DATE" type="xs:integer"/>
|
|
148
|
-
<xs:element name="ID" type="xs:integer"/>
|
|
149
|
-
<xs:element name="NAME" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
|
150
|
-
<xs:element name="PARENT" type="xs:integer"/>
|
|
151
|
-
<xs:element name="SIZE" type="xs:integer"/>
|
|
152
|
-
</xs:sequence>
|
|
153
|
-
</xs:complexType>
|
|
154
|
-
</xs:element>
|
|
155
|
-
</xs:sequence>
|
|
156
|
-
</xs:complexType>
|
|
157
|
-
</xs:element>
|
|
158
|
-
<xs:element name="BACKUPS">
|
|
159
|
-
<xs:complexType>
|
|
160
|
-
<xs:sequence>
|
|
161
|
-
<xs:element name="BACKUP_CONFIG" minOccurs="1" maxOccurs="1">
|
|
162
|
-
<xs:complexType>
|
|
163
|
-
<xs:sequence>
|
|
164
|
-
<xs:element name="BACKUP_VOLATILE" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
|
165
|
-
<xs:element name="FS_FREEZE" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
|
166
|
-
<xs:element name="INCREMENTAL_BACKUP_ID" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
|
167
|
-
<xs:element name="INCREMENT_MODE" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
|
168
|
-
<xs:element name="KEEP_LAST" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
|
169
|
-
<xs:element name="LAST_BACKUP_ID" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
|
170
|
-
<xs:element name="LAST_BACKUP_SIZE" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
|
171
|
-
<xs:element name="LAST_BRIDGE" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
|
172
|
-
<xs:element name="LAST_DATASTORE_ID" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
|
173
|
-
<xs:element name="LAST_INCREMENT_ID" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
|
174
|
-
<xs:element name="MODE" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
|
175
|
-
</xs:sequence>
|
|
176
|
-
</xs:complexType>
|
|
177
|
-
</xs:element>
|
|
178
|
-
<xs:element name="BACKUP_IDS" minOccurs="1" maxOccurs="1">
|
|
179
|
-
<xs:complexType>
|
|
180
|
-
<xs:sequence>
|
|
181
|
-
<xs:element name="ID" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
|
|
182
|
-
</xs:sequence>
|
|
183
|
-
</xs:complexType>
|
|
184
|
-
</xs:element>
|
|
185
|
-
</xs:sequence>
|
|
186
|
-
</xs:complexType>
|
|
187
|
-
</xs:element>
|
|
188
|
-
</xs:sequence>
|
|
189
|
-
</xs:complexType>
|
|
190
|
-
</xs:element>
|
|
89
|
+
<xs:element ref="VM"/>
|
|
191
90
|
</xs:sequence>
|
|
192
91
|
</xs:complexType>
|
|
193
92
|
</xs:element>
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
<xs:element name="BACKUP_VMS" type="xs:string"/>
|
|
28
28
|
<xs:element name="BACKUP_VOLATILE" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
|
29
29
|
<xs:element name="DATASTORE_ID" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
|
30
|
+
<xs:element name="DISK_IDS" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
|
30
31
|
<xs:element name="ERROR" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
|
31
32
|
<xs:element name="EXECUTION" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
|
32
33
|
<xs:element name="FS_FREEZE" type="xs:string" minOccurs="0" maxOccurs="1"/>
|