opennebula-cli 7.2.0 → 7.2.1

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.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/bin/onevm +1 -1
  3. data/lib/command_parser.rb +134 -125
  4. data/lib/load_opennebula_paths.rb +5 -0
  5. data/lib/ods_helper.rb +541 -0
  6. data/lib/one_helper/oneacct_helper.rb +116 -108
  7. data/lib/one_helper/onedatastore_helper.rb +86 -79
  8. data/lib/one_helper/onemarket_helper.rb +58 -57
  9. data/lib/one_helper/onequota_helper.rb +239 -189
  10. data/lib/one_helper/onesecgroup_helper.rb +86 -84
  11. data/lib/one_helper/onetemplate_helper.rb +63 -63
  12. data/lib/one_helper/onevdc_helper.rb +44 -44
  13. data/lib/one_helper/onevm_helper.rb +5 -7
  14. data/lib/one_helper/onevmgroup_helper.rb +64 -62
  15. data/lib/one_helper/onevntemplate_helper.rb +42 -39
  16. data/lib/one_helper/onevrouter_helper.rb +85 -86
  17. data/lib/one_helper/onezone_helper.rb +97 -100
  18. data/lib/one_helper.rb +88 -69
  19. data/share/schemas/xsd/acct.xsd +3 -104
  20. data/share/schemas/xsd/cluster.xsd +4 -21
  21. data/share/schemas/xsd/datastore.xsd +4 -29
  22. data/share/schemas/xsd/document.xsd +3 -25
  23. data/share/schemas/xsd/group.xsd +2 -14
  24. data/share/schemas/xsd/group_pool.xsd +2 -14
  25. data/share/schemas/xsd/hook.xsd +2 -0
  26. data/share/schemas/xsd/host.xsd +5 -7
  27. data/share/schemas/xsd/image.xsd +2 -25
  28. data/share/schemas/xsd/marketplace.xsd +3 -22
  29. data/share/schemas/xsd/marketplaceapp.xsd +3 -25
  30. data/share/schemas/xsd/opennebula_configuration.xsd +1 -0
  31. data/share/schemas/xsd/requirements.xsd +3 -21
  32. data/share/schemas/xsd/security_group.xsd +6 -43
  33. data/share/schemas/xsd/shared.xsd +3 -3
  34. data/share/schemas/xsd/vdc.xsd +2 -7
  35. data/share/schemas/xsd/vm_group.xsd +3 -25
  36. data/share/schemas/xsd/vm_pool.xsd +2 -0
  37. data/share/schemas/xsd/vmtemplate.xsd +3 -25
  38. data/share/schemas/xsd/vnet.xsd +9 -67
  39. data/share/schemas/xsd/vnet_pool.xsd +8 -57
  40. data/share/schemas/xsd/vntemplate.xsd +3 -25
  41. data/share/schemas/xsd/vrouter.xsd +4 -32
  42. metadata +6 -4
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 Exception => e
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 => String
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
- %[#{k}="#{v}"]
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 and (!options.key? :no_pager)
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.reject! do |element|
872
- !options[:ids].include?(element['ID'].to_i)
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 and (!options.key? :no_pager)
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 and (!options.key? :no_pager)
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 |pool|
1078
- hash = check_resource_xsd(pool, pname)
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 |pool|
1083
- hash = check_resource_xsd(pool, pname)
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' and name.upcase=='ALL'
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." unless objects.length>0
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
- desc=<<~EOT
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 = "#{ENV['HOME']}/.one/cli/#{conf_file}"
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"]["#{rname}"]
1318
- if phash["#{rname}_POOL"]["#{rname}"].instance_of?(Array)
1319
- phash = phash["#{rname}_POOL"]["#{rname}"]
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"]["#{rname}"]]
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 or hash.empty?
1491
+ return unless hash || hash.empty?
1487
1492
 
1488
1493
  hash.each do |k, v|
1489
1494
  # find the elem definition in xsd array
@@ -1602,7 +1607,7 @@ Bash symbols must be escaped on STDIN passing'
1602
1607
  end
1603
1608
 
1604
1609
  def self.rname_to_id_desc(poolname)
1605
- "OpenNebula #{poolname} name or id"
1610
+ "OpenNebula #{poolname} id"
1606
1611
  end
1607
1612
 
1608
1613
  def self.boolean_to_str(str)
@@ -1615,7 +1620,6 @@ Bash symbols must be escaped on STDIN passing'
1615
1620
 
1616
1621
  def self.time_to_str(time, print_seconds = true,
1617
1622
  print_hours = true, print_years = false)
1618
-
1619
1623
  value = time.to_i
1620
1624
 
1621
1625
  if value==0
@@ -1654,9 +1658,11 @@ Bash symbols must be escaped on STDIN passing'
1654
1658
  days, hours=hours.divmod(24)
1655
1659
 
1656
1660
  if print_seconds
1657
- format('%3dd %02dh%02dm%02ds', days, hours, minutes, seconds)
1661
+ format('%<days>3dd %<hours>02dh%<minutes>02dm%<seconds>02ds',
1662
+ :days => days, :hours => hours, :minutes => minutes, :seconds => seconds)
1658
1663
  else
1659
- format('%3dd %02dh%02dm', days, hours, minutes)
1664
+ format('%<days>3dd %<hours>02dh%<minutes>02dm',
1665
+ :days => days, :hours => hours, :minutes => minutes)
1660
1666
  end
1661
1667
  end
1662
1668
 
@@ -1666,35 +1672,36 @@ Bash symbols must be escaped on STDIN passing'
1666
1672
  hours, minutes=minutes.divmod(60)
1667
1673
 
1668
1674
  if print_seconds
1669
- format('%3dh%02dm%02ds', hours, minutes, seconds)
1675
+ format('%<hours>3dh%<minutes>02dm%<seconds>02ds',
1676
+ :hours => hours, :minutes => minutes, :seconds => seconds)
1670
1677
  else
1671
- format('%3dh%02dm', hours, minutes)
1678
+ format('%<hours>3dh%<minutes>02dm', :hours => hours, :minutes => minutes)
1672
1679
  end
1673
1680
  end
1674
1681
 
1675
- BinarySufix = ['K', 'M', 'G', 'T']
1682
+ BINARY_SUFFIX = ['K', 'M', 'G', 'T']
1676
1683
 
1677
1684
  def self.unit_to_str(value, options, unit = 'K')
1678
1685
  if options[:kilobytes]
1679
1686
  value
1680
1687
  else
1681
- i=BinarySufix.index(unit).to_i
1688
+ i = BINARY_SUFFIX.index(unit).to_i
1682
1689
 
1683
1690
  while value > 1024 && i < 3
1684
1691
  value /= 1024.0
1685
- i+=1
1692
+ i += 1
1686
1693
  end
1687
1694
 
1688
1695
  value = (value * 10).round / 10.0
1689
1696
 
1690
1697
  value = value.to_i if value - value.round == 0
1691
- st = value.to_s + BinarySufix[i]
1698
+ value.to_s + BINARY_SUFFIX[i]
1692
1699
  end
1693
1700
  end
1694
1701
 
1695
1702
  def self.bytes_to_unit(value, unit = 'K')
1696
1703
  j = 0
1697
- i = BinarySufix.index(unit).to_i
1704
+ i = BINARY_SUFFIX.index(unit).to_i
1698
1705
 
1699
1706
  while j < i
1700
1707
  value /= 1024.0
@@ -1732,10 +1739,12 @@ Bash symbols must be escaped on STDIN passing'
1732
1739
  update_template_helper(true, id, resource, path, xpath)
1733
1740
  end
1734
1741
 
1742
+ # rubocop:disable Metrics/ParameterLists
1735
1743
  def self.update_template_helper(append, _id, resource, path, xpath, update = true)
1744
+ # rubocop:enable Metrics/ParameterLists
1736
1745
  if path
1737
1746
  File.read(path)
1738
- elsif !(stdin = self.read_stdin).empty?
1747
+ elsif !(stdin = read_stdin).empty?
1739
1748
  stdin
1740
1749
  elsif append
1741
1750
  editor_input
@@ -1803,7 +1812,7 @@ Bash symbols must be escaped on STDIN passing'
1803
1812
  editor_path = ENV['EDITOR'] ? ENV['EDITOR'] : EDITOR_PATH
1804
1813
  system("#{editor_path} #{tmp.path}")
1805
1814
 
1806
- unless $?.exitstatus == 0
1815
+ unless $CHILD_STATUS.exitstatus == 0
1807
1816
  puts 'Editor not defined'
1808
1817
  exit(-1)
1809
1818
  end
@@ -1889,11 +1898,11 @@ Bash symbols must be escaped on STDIN passing'
1889
1898
  if !(options.keys & context_options).empty?
1890
1899
  if options[:ssh]
1891
1900
  if options[:ssh]==true
1892
- context_hash['SSH_PUBLIC_KEY'] = "$USER[SSH_PUBLIC_KEY]"
1901
+ context_hash['SSH_PUBLIC_KEY'] = '$USER[SSH_PUBLIC_KEY]'
1893
1902
  else
1894
1903
  begin
1895
1904
  key=File.read(options[:ssh]).strip
1896
- rescue Exception => e
1905
+ rescue StandardError => e
1897
1906
  STDERR.puts e.message
1898
1907
  exit(-1)
1899
1908
  end
@@ -1902,24 +1911,24 @@ Bash symbols must be escaped on STDIN passing'
1902
1911
  end
1903
1912
 
1904
1913
  if options[:net_context]
1905
- context_hash['NETWORK'] = "YES"
1914
+ context_hash['NETWORK'] = 'YES'
1906
1915
  end
1907
1916
 
1908
1917
  if options[:files_ds]
1909
- files = options[:files_ds].map { |file| %($FILE[IMAGE=\\"#{file}\\"]) }.join(" ")
1918
+ files = options[:files_ds].map {|file| %($FILE[IMAGE=\\"#{file}\\"]) }.join(' ')
1910
1919
 
1911
1920
  context_hash['FILES_DS'] = files
1912
1921
  end
1913
1922
 
1914
1923
  if options[:init]
1915
- context_hash['INIT_SCRIPTS'] = options[:init].join(" ")
1924
+ context_hash['INIT_SCRIPTS'] = options[:init].join(' ')
1916
1925
  end
1917
1926
 
1918
1927
  if options[:startscript]
1919
1928
  script = nil
1920
1929
  begin
1921
1930
  script = File.read(options[:startscript]).strip
1922
- rescue Exception => e
1931
+ rescue StandardError => e
1923
1932
  STDERR.puts e.message
1924
1933
  exit(-1)
1925
1934
  end
@@ -1929,15 +1938,17 @@ Bash symbols must be escaped on STDIN passing'
1929
1938
  end
1930
1939
 
1931
1940
  if options[:report_ready]
1932
- context_hash['REPORT_READY'] = "YES"
1941
+ context_hash['REPORT_READY'] = 'YES'
1933
1942
  end
1934
1943
 
1935
1944
  if context_hash.any? || options[:context]
1936
1945
  formatted_context = "CONTEXT=[\n"
1937
- formatted_context << options[:context].map {|l| ' ' << l }.join(",\n") if options[:context]
1946
+ formatted_context << options[:context].map {|l|
1947
+ ' ' << l
1948
+ }.join(",\n") if options[:context]
1938
1949
  if context_hash.any?
1939
1950
  formatted_context << ",\n" if options[:context]
1940
- formatted_context << context_hash.map { |k, v| " #{k}=\"#{v}\"" }.join(",\n")
1951
+ formatted_context << context_hash.map {|k, v| " #{k}=\"#{v}\"" }.join(",\n")
1941
1952
  end
1942
1953
  formatted_context << "\n]\n"
1943
1954
  formatted_context
@@ -2023,7 +2034,7 @@ Bash symbols must be escaped on STDIN passing'
2023
2034
 
2024
2035
  context_hash = {}
2025
2036
  if !template_obj.nil? && template_obj.has_elements?('TEMPLATE/CONTEXT')
2026
- context_hash = template_obj.to_hash["VMTEMPLATE"]["TEMPLATE"]["CONTEXT"]
2037
+ context_hash = template_obj.to_hash['VMTEMPLATE']['TEMPLATE']['CONTEXT']
2027
2038
  end
2028
2039
  context_str=create_context_str(options, context_hash)
2029
2040
  template<<context_str if context_str
@@ -2124,15 +2135,16 @@ Bash symbols must be escaped on STDIN passing'
2124
2135
 
2125
2136
  def self.level_lock_to_str(str)
2126
2137
  level = str.to_i
2127
- if level == 0
2138
+ case level
2139
+ when 0
2128
2140
  'None'
2129
- elsif level == 1
2141
+ when 1
2130
2142
  'Use'
2131
- elsif level == 2
2143
+ when 2
2132
2144
  'Manage'
2133
- elsif level == 3
2145
+ when 3
2134
2146
  'Admin'
2135
- elsif level == 4
2147
+ when 4
2136
2148
  'All'
2137
2149
  else
2138
2150
  '-'
@@ -2232,13 +2244,15 @@ Bash symbols must be escaped on STDIN passing'
2232
2244
  exp = OneTemplateHelper::FLOAT_EXP
2233
2245
  end
2234
2246
 
2235
- begin
2247
+ loop do
2236
2248
  print header
2237
2249
  answer = STDIN.readline.chop
2238
2250
 
2239
2251
  answer = initial if answer == ''
2240
2252
  noanswer = (answer == '') && optional
2241
- end while !noanswer && (answer =~ exp).nil?
2253
+
2254
+ break if noanswer || !(answer =~ exp).nil?
2255
+ end
2242
2256
 
2243
2257
  if noanswer
2244
2258
  next
@@ -2268,15 +2282,17 @@ Bash symbols must be escaped on STDIN passing'
2268
2282
  header += "Float in the range [#{min}..#{max}]: "
2269
2283
  end
2270
2284
 
2271
- begin
2285
+ loop do
2272
2286
  print header
2273
2287
  answer = STDIN.readline.chop
2274
2288
 
2275
2289
  answer = initial if answer == ''
2276
2290
 
2277
2291
  noanswer = (answer == '') && optional
2278
- end while !noanswer && ((answer =~ exp).nil? ||
2279
- answer.to_f < min || answer.to_f > max)
2292
+
2293
+ break if noanswer || (!(answer =~ exp).nil? &&
2294
+ answer.to_f >= min && answer.to_f <= max)
2295
+ end
2280
2296
 
2281
2297
  if noanswer
2282
2298
  next
@@ -2293,7 +2309,7 @@ Bash symbols must be escaped on STDIN passing'
2293
2309
 
2294
2310
  header += 'Please type the selection number: '
2295
2311
 
2296
- begin
2312
+ loop do
2297
2313
  print header
2298
2314
  answer = STDIN.readline.chop
2299
2315
 
@@ -2304,7 +2320,9 @@ Bash symbols must be escaped on STDIN passing'
2304
2320
  end
2305
2321
 
2306
2322
  noanswer = (answer == '') && optional
2307
- end while !noanswer && !options.include?(answer)
2323
+
2324
+ break if noanswer || options.include?(answer)
2325
+ end
2308
2326
 
2309
2327
  if noanswer
2310
2328
  next
@@ -2338,7 +2356,7 @@ Bash symbols must be escaped on STDIN passing'
2338
2356
  # Require gnuplot gem only here
2339
2357
  begin
2340
2358
  require 'gnuplot'
2341
- rescue LoadError, Gem::LoadError
2359
+ rescue LoadError
2342
2360
  STDERR.puts(
2343
2361
  'Gnuplot gem is not installed, run `gem install gnuplot` '\
2344
2362
  'to install it'
@@ -2581,9 +2599,10 @@ Bash symbols must be escaped on STDIN passing'
2581
2599
 
2582
2600
  def self.read_stdin
2583
2601
  if STDIN.wait_readable(0)
2584
- STDIN.read()
2602
+ STDIN.read
2585
2603
  else
2586
- ''
2604
+ ''
2587
2605
  end
2588
2606
  end
2607
+
2589
2608
  end
@@ -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 name="VM">
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>
@@ -1,32 +1,15 @@
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"/>
4
5
  <xs:element name="CLUSTER">
5
6
  <xs:complexType>
6
7
  <xs:sequence>
7
8
  <xs:element name="ID" type="xs:integer"/>
8
9
  <xs:element name="NAME" type="xs:string"/>
9
- <xs:element name="HOSTS">
10
- <xs:complexType>
11
- <xs:sequence>
12
- <xs:element name="ID" type="xs:integer" minOccurs="0" maxOccurs="unbounded"/>
13
- </xs:sequence>
14
- </xs:complexType>
15
- </xs:element>
16
- <xs:element name="DATASTORES">
17
- <xs:complexType>
18
- <xs:sequence>
19
- <xs:element name="ID" type="xs:integer" minOccurs="0" maxOccurs="unbounded"/>
20
- </xs:sequence>
21
- </xs:complexType>
22
- </xs:element>
23
- <xs:element name="VNETS">
24
- <xs:complexType>
25
- <xs:sequence>
26
- <xs:element name="ID" type="xs:integer" minOccurs="0" maxOccurs="unbounded"/>
27
- </xs:sequence>
28
- </xs:complexType>
29
- </xs:element>
10
+ <xs:element name="HOSTS" type="IDS"/>
11
+ <xs:element name="DATASTORES" type="IDS"/>
12
+ <xs:element name="VNETS" type="IDS"/>
30
13
  <xs:element name="TEMPLATE" type="xs:anyType"/>
31
14
  <xs:element name="PLAN" minOccurs="0" maxOccurs="1">
32
15
  <xs:complexType>