opennebula 6.4.5 → 6.5.80.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ActionManager.rb +1 -1
  3. data/lib/CommandManager.rb +10 -7
  4. data/lib/DriverExecHelper.rb +2 -2
  5. data/lib/OpenNebulaDriver.rb +1 -1
  6. data/lib/VirtualMachineDriver.rb +28 -14
  7. data/lib/cloud/CloudClient.rb +3 -3
  8. data/lib/datacenter.rb +25 -21
  9. data/lib/datastore.rb +4 -4
  10. data/lib/distributed_firewall.rb +1 -1
  11. data/lib/file_helper.rb +2 -2
  12. data/lib/host.rb +3 -3
  13. data/lib/logical_port.rb +1 -1
  14. data/lib/logical_switch.rb +1 -1
  15. data/lib/memoize.rb +1 -1
  16. data/lib/models/role.rb +114 -68
  17. data/lib/models/service.rb +58 -58
  18. data/lib/models.rb +1 -1
  19. data/lib/network.rb +1 -1
  20. data/lib/nsx_client.rb +1 -1
  21. data/lib/nsx_component.rb +1 -1
  22. data/lib/nsx_constants.rb +2 -2
  23. data/lib/nsx_driver.rb +1 -1
  24. data/lib/nsx_error.rb +1 -1
  25. data/lib/nsx_rule.rb +1 -1
  26. data/lib/nsxt_client.rb +1 -1
  27. data/lib/nsxt_dfw.rb +1 -1
  28. data/lib/nsxt_logical_port.rb +1 -1
  29. data/lib/nsxt_rule.rb +1 -1
  30. data/lib/nsxt_tz.rb +1 -1
  31. data/lib/nsxv_client.rb +1 -1
  32. data/lib/nsxv_dfw.rb +1 -1
  33. data/lib/nsxv_logical_port.rb +1 -1
  34. data/lib/nsxv_rule.rb +1 -1
  35. data/lib/nsxv_tz.rb +1 -1
  36. data/lib/opaque_network.rb +1 -1
  37. data/lib/opennebula/acl.rb +1 -1
  38. data/lib/opennebula/acl_pool.rb +1 -1
  39. data/lib/opennebula/client.rb +1 -1
  40. data/lib/opennebula/cluster.rb +1 -1
  41. data/lib/opennebula/cluster_pool.rb +1 -1
  42. data/lib/opennebula/datastore.rb +4 -3
  43. data/lib/opennebula/datastore_pool.rb +1 -1
  44. data/lib/opennebula/document.rb +1 -1
  45. data/lib/opennebula/document_json.rb +1 -1
  46. data/lib/opennebula/document_pool.rb +1 -1
  47. data/lib/opennebula/document_pool_json.rb +1 -1
  48. data/lib/opennebula/error.rb +1 -1
  49. data/lib/opennebula/flow/grammar.rb +1 -1
  50. data/lib/opennebula/flow/service_pool.rb +1 -1
  51. data/lib/opennebula/flow/service_template.rb +22 -22
  52. data/lib/opennebula/flow/service_template_ext.rb +1 -1
  53. data/lib/opennebula/flow/service_template_pool.rb +1 -1
  54. data/lib/opennebula/flow/validator.rb +1 -1
  55. data/lib/opennebula/flow.rb +1 -1
  56. data/lib/opennebula/group.rb +1 -1
  57. data/lib/opennebula/group_pool.rb +1 -1
  58. data/lib/opennebula/hook.rb +1 -1
  59. data/lib/opennebula/hook_log.rb +1 -1
  60. data/lib/opennebula/hook_pool.rb +1 -1
  61. data/lib/opennebula/host.rb +1 -1
  62. data/lib/opennebula/host_pool.rb +1 -1
  63. data/lib/opennebula/image.rb +33 -23
  64. data/lib/opennebula/image_pool.rb +1 -1
  65. data/lib/opennebula/ldap_auth.rb +2 -2
  66. data/lib/opennebula/ldap_auth_spec.rb +1 -1
  67. data/lib/opennebula/lockable_ext.rb +1 -1
  68. data/lib/opennebula/marketplace.rb +1 -1
  69. data/lib/opennebula/marketplace_pool.rb +1 -1
  70. data/lib/opennebula/marketplaceapp.rb +1 -1
  71. data/lib/opennebula/marketplaceapp_ext.rb +4 -4
  72. data/lib/opennebula/marketplaceapp_pool.rb +1 -1
  73. data/lib/opennebula/oneflow_client.rb +1 -1
  74. data/lib/opennebula/pool.rb +1 -1
  75. data/lib/opennebula/pool_element.rb +1 -1
  76. data/lib/opennebula/security_group.rb +1 -1
  77. data/lib/opennebula/security_group_pool.rb +1 -1
  78. data/lib/opennebula/server_cipher_auth.rb +1 -1
  79. data/lib/opennebula/server_x509_auth.rb +1 -1
  80. data/lib/opennebula/ssh_auth.rb +80 -103
  81. data/lib/opennebula/system.rb +1 -1
  82. data/lib/opennebula/template.rb +1 -1
  83. data/lib/opennebula/template_ext.rb +3 -3
  84. data/lib/opennebula/template_pool.rb +1 -1
  85. data/lib/opennebula/user.rb +1 -1
  86. data/lib/opennebula/user_pool.rb +1 -1
  87. data/lib/opennebula/utils.rb +1 -1
  88. data/lib/opennebula/vdc.rb +1 -1
  89. data/lib/opennebula/vdc_pool.rb +1 -1
  90. data/lib/opennebula/virtual_machine.rb +31 -3
  91. data/lib/opennebula/virtual_machine_ext.rb +12 -217
  92. data/lib/opennebula/virtual_machine_pool.rb +1 -1
  93. data/lib/opennebula/virtual_network.rb +33 -4
  94. data/lib/opennebula/virtual_network_pool.rb +1 -1
  95. data/lib/opennebula/virtual_router.rb +1 -1
  96. data/lib/opennebula/virtual_router_pool.rb +1 -1
  97. data/lib/opennebula/vm_group.rb +1 -1
  98. data/lib/opennebula/vm_group_pool.rb +1 -1
  99. data/lib/opennebula/vntemplate.rb +1 -1
  100. data/lib/opennebula/vntemplate_pool.rb +1 -1
  101. data/lib/opennebula/wait_ext.rb +1 -1
  102. data/lib/opennebula/x509_auth.rb +1 -1
  103. data/lib/opennebula/xml_element.rb +1 -1
  104. data/lib/opennebula/xml_pool.rb +1 -1
  105. data/lib/opennebula/xml_utils.rb +1 -1
  106. data/lib/opennebula/zone.rb +1 -1
  107. data/lib/opennebula/zone_pool.rb +1 -1
  108. data/lib/opennebula.rb +2 -2
  109. data/lib/rest_client.rb +18 -14
  110. data/lib/scripts_common.rb +1 -1
  111. data/lib/transport_zone.rb +1 -1
  112. data/lib/vcenter_driver.rb +1 -1
  113. data/lib/vcenter_importer.rb +1 -1
  114. data/lib/vi_client.rb +73 -65
  115. data/lib/vi_helper.rb +1 -1
  116. data/lib/virtual_machine.rb +3 -9
  117. data/lib/virtual_wire.rb +2 -2
  118. data/lib/vm_disk.rb +1 -1
  119. data/lib/vm_folder.rb +1 -1
  120. data/lib/vm_helper.rb +1 -1
  121. data/lib/vm_monitor.rb +1 -1
  122. data/lib/vm_nic.rb +1 -1
  123. data/lib/vm_template.rb +1 -1
  124. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 34ad5b5d6ddf88c8d92248d3c321d7e6891609fbc83776ef6d0a71ea6e634977
4
- data.tar.gz: 2efb015748722ee63a336106a59b1306b0382049cdeb44ef86eee11a957f7379
3
+ metadata.gz: 5cb427e39e8e2f581076e069b21c0da24b5e82dac56e29b0e7017c7e419b3a31
4
+ data.tar.gz: 59203c99872a0065565a336a0bc814f5f7f9acd15a79bcdf3e1df9c92f3b5209
5
5
  SHA512:
6
- metadata.gz: f3a43640e13e4a9e73e2b3efc8ae5da0793b50a56b8655a855e4b42820869515d602a7fd3ede1ace8f8996d64cbb78b82461c5f90466256498538d9f048e70c6
7
- data.tar.gz: 54c3b592674fdca5ed5836aac7b32336fd4a1970dc2b816ad0236c622133559f136fc545b4be56a26f3fee847572c4f30970d5cd8ba44fdc92af0d4e53484403
6
+ metadata.gz: c20a43d2ade283e63fda2143c9fb8fc2d88f7191e81f75f17219d0d625c99f587f6aea2517dfde44d1dd65aea08c65fa349518045a58df2f912d3d7bc5afb197
7
+ data.tar.gz: 7e4f2365737cf9746b91834ff0af8cb01ff7dc198b5f143686d483f6c9aa927df6cbac4e4226682ce599c5afea85be716e2cb21dc2144986e288f8f2f33e5bbb
data/lib/ActionManager.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- */
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, OpenNebula Project, OpenNebula Systems #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License"); you may */
4
4
  # not use this file except in compliance with the License. You may obtain */
5
5
  # a copy of the License at */
@@ -1,5 +1,5 @@
1
1
  # --------------------------------------------------------------------------
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems
2
+ # Copyright 2002-2022, OpenNebula Project, OpenNebula Systems
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may
5
5
  # not use this file except in compliance with the License. You may obtain
@@ -212,19 +212,22 @@ end
212
212
  # Executes commands in a remote machine ussing ssh. See documentation
213
213
  # for GenericCommand
214
214
  class SSHCommand < GenericCommand
215
- attr_accessor :host
215
+
216
+ attr_accessor :host, :ssh_opts
216
217
 
217
218
  # Creates a command and runs it
218
- def self.run(command, host, logger=nil, stdin=nil, timeout=nil)
219
- cmd=self.new(command, host, logger, stdin, timeout)
219
+ def self.run(command, host, logger=nil, stdin=nil, timeout=nil, ssh_opts='')
220
+ cmd=self.new(command, host, logger, stdin, timeout, ssh_opts)
220
221
  cmd.run
221
222
  cmd
222
223
  end
223
224
 
224
225
  # This one takes another parameter. +host+ is the machine
225
226
  # where the command is going to be executed
226
- def initialize(command, host, logger=nil, stdin=nil, timeout=nil)
227
+ def initialize(command, host, logger=nil, stdin=nil, timeout=nil, ssh_opts='')
227
228
  @host=host
229
+ @ssh_opts = ssh_opts
230
+
228
231
  super(command, logger, stdin, timeout)
229
232
  end
230
233
 
@@ -232,10 +235,10 @@ private
232
235
 
233
236
  def execute
234
237
  if @stdin
235
- capture3_timeout("ssh #{@host} #{@command}",
238
+ capture3_timeout("ssh #{@ssh_opts} #{@host} #{@command}",
236
239
  :pgroup => true, :stdin_data => @stdin)
237
240
  else
238
- capture3_timeout("ssh -n #{@host} #{@command}",
241
+ capture3_timeout("ssh -n #{@ssh_opts} #{@host} #{@command}",
239
242
  :pgroup => true)
240
243
  end
241
244
  end
@@ -1,6 +1,6 @@
1
1
  # rubocop:disable Naming/FileName
2
2
  # -------------------------------------------------------------------------- #
3
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
3
+ # Copyright 2002-2022, OpenNebula Project, OpenNebula Systems #
4
4
  # #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
6
6
  # not use this file except in compliance with the License. You may obtain #
@@ -189,7 +189,7 @@ module DriverExecHelper
189
189
  cfg=file.read
190
190
  end
191
191
 
192
- cfg.split("\n").each do |line|
192
+ cfg.split(/\n/).each do |line|
193
193
  m=line.match(/^([^=]+)=(.*)$/)
194
194
 
195
195
  next unless m
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -53,7 +53,9 @@ class VirtualMachineDriver < OpenNebulaDriver
53
53
  :resize_disk => "RESIZEDISK",
54
54
  :update_sg => "UPDATESG",
55
55
  :update_conf => "UPDATECONF",
56
- :resize => "RESIZE"
56
+ :resize => "RESIZE",
57
+ :backup => "BACKUP",
58
+ :update_nic => "UPDATENIC"
57
59
  }
58
60
 
59
61
  POLL_ATTRIBUTE = OpenNebula::VirtualMachine::Driver::POLL_ATTRIBUTE
@@ -76,23 +78,23 @@ class VirtualMachineDriver < OpenNebulaDriver
76
78
 
77
79
  super(directory, @options)
78
80
 
79
- @hosts = Array.new
80
-
81
- register_action(ACTION[:deploy].to_sym, method("deploy"))
82
- register_action(ACTION[:shutdown].to_sym, method("shutdown"))
83
- register_action(ACTION[:reboot].to_sym, method("reboot"))
84
- register_action(ACTION[:reset].to_sym, method("reset"))
85
- register_action(ACTION[:cancel].to_sym, method("cancel"))
86
- register_action(ACTION[:save].to_sym, method("save"))
87
- register_action(ACTION[:restore].to_sym, method("restore"))
88
- register_action(ACTION[:migrate].to_sym, method("migrate"))
89
- register_action(ACTION[:poll].to_sym, method("poll"))
81
+ @hosts = Array.new
82
+
83
+ register_action(ACTION[:deploy].to_sym, method("deploy"))
84
+ register_action(ACTION[:shutdown].to_sym, method("shutdown"))
85
+ register_action(ACTION[:reboot].to_sym, method("reboot"))
86
+ register_action(ACTION[:reset].to_sym, method("reset"))
87
+ register_action(ACTION[:cancel].to_sym, method("cancel"))
88
+ register_action(ACTION[:save].to_sym, method("save"))
89
+ register_action(ACTION[:restore].to_sym, method("restore"))
90
+ register_action(ACTION[:migrate].to_sym, method("migrate"))
91
+ register_action(ACTION[:poll].to_sym, method("poll"))
90
92
  register_action(ACTION[:attach_disk].to_sym, method("attach_disk"))
91
93
  register_action(ACTION[:detach_disk].to_sym, method("detach_disk"))
92
94
  register_action(ACTION[:snapshot_create].to_sym, method("snapshot_create"))
93
95
  register_action(ACTION[:snapshot_revert].to_sym, method("snapshot_revert"))
94
96
  register_action(ACTION[:snapshot_delete].to_sym, method("snapshot_delete"))
95
- register_action(ACTION[:cleanup].to_sym, method("cleanup"))
97
+ register_action(ACTION[:cleanup].to_sym, method("cleanup"))
96
98
  register_action(ACTION[:attach_nic].to_sym, method("attach_nic"))
97
99
  register_action(ACTION[:detach_nic].to_sym, method("detach_nic"))
98
100
  register_action(ACTION[:disk_snapshot_create].to_sym, method("disk_snapshot_create"))
@@ -100,6 +102,8 @@ class VirtualMachineDriver < OpenNebulaDriver
100
102
  register_action(ACTION[:update_sg].to_sym, method("update_sg"))
101
103
  register_action(ACTION[:update_conf].to_sym, method("update_conf"))
102
104
  register_action(ACTION[:resize].to_sym, method("resize"))
105
+ register_action(ACTION[:backup].to_sym, method("backup"))
106
+ register_action(ACTION[:update_nic].to_sym, method("update_nic"))
103
107
  end
104
108
 
105
109
  # Decodes the encoded XML driver message received from the core
@@ -234,6 +238,16 @@ class VirtualMachineDriver < OpenNebulaDriver
234
238
  send_message(ACTION[:resize],RESULT[:failure],id,error)
235
239
  end
236
240
 
241
+ def backup(id, drv_message)
242
+ error = "Action not implemented by driver #{self.class}"
243
+ send_message(ACTION[:backup],RESULT[:failure],id,error)
244
+ end
245
+
246
+ def update_nic(id, drv_message)
247
+ error = "Action not implemented by driver #{self.class}"
248
+ send_message(ACTION[:update_nic],RESULT[:failure],id,error)
249
+ end
250
+
237
251
  private
238
252
 
239
253
  # Interface to handle the pending events from the ActionManager Interface
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -51,7 +51,7 @@ end
51
51
  module CloudClient
52
52
 
53
53
  # OpenNebula version
54
- VERSION = '6.4.5'
54
+ VERSION = '6.5.80'
55
55
 
56
56
  # #########################################################################
57
57
  # Default location for the authentication file
@@ -229,7 +229,7 @@ module CloudCLI
229
229
  def version_text
230
230
  version=<<EOT
231
231
  OpenNebula #{CloudClient::VERSION}
232
- Copyright 2002-2023, OpenNebula Project, OpenNebula Systems
232
+ Copyright 2002-2022, OpenNebula Project, OpenNebula Systems
233
233
 
234
234
  Licensed under the Apache License, Version 2.0 (the "License"); you may
235
235
  not use this file except in compliance with the License. You may obtain
data/lib/datacenter.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -929,26 +929,30 @@ module VCenterDriver
929
929
  spec.configSpec.maxMtu = mtu
930
930
 
931
931
  # The DVS must be created in the networkFolder of the datacenter
932
- dvs_creation_task = @item
933
- .networkFolder
934
- .CreateDVS_Task(
935
- :spec => spec
936
- )
937
- dvs_creation_task.wait_for_completion
938
-
939
- # If task finished successfuly we rename the uplink portgroup
940
- dvs = nil
941
- if dvs_creation_task.info.state == 'success'
942
- dvs = dvs_creation_task.info.result
943
- dvs
944
- .config
945
- .uplinkPortgroup[0]
946
- .Rename_Task(
947
- :newName => "#{switch_name}-uplink-pg"
948
- ).wait_for_completion
949
- else
950
- raise "The Distributed vSwitch #{switch_name} \
951
- could not be created. "
932
+ begin
933
+ dvs_creation_task = @item
934
+ .networkFolder
935
+ .CreateDVS_Task(
936
+ :spec => spec
937
+ )
938
+ dvs_creation_task.wait_for_completion
939
+
940
+ # If task finished successfuly we rename the uplink portgroup
941
+ dvs = nil
942
+ if dvs_creation_task.info.state == 'success'
943
+ dvs = dvs_creation_task.info.result
944
+ dvs
945
+ .config
946
+ .uplinkPortgroup[0]
947
+ .Rename_Task(
948
+ :newName => "#{switch_name}-uplink-pg"
949
+ ).wait_for_completion
950
+ else
951
+ raise "The Distributed vSwitch #{switch_name} \
952
+ could not be created. "
953
+ end
954
+ rescue StandardError => e
955
+ raise e
952
956
  end
953
957
 
954
958
  @net_rollback << {
data/lib/datastore.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -743,9 +743,9 @@ module VCenterDriver
743
743
  image_path = ''
744
744
 
745
745
  # Skip not relevant files
746
- next unless ['FloppyImageFileInfo',
747
- 'IsoImageFileInfo',
748
- 'VmDiskFileInfo'].include? image.class.to_s
746
+ next unless %w[FloppyImageFileInfo
747
+ IsoImageFileInfo
748
+ VmDiskFileInfo].include? image.class.to_s
749
749
 
750
750
  # Get image path and name
751
751
  image_path << folderpath << image.path
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
data/lib/file_helper.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -109,7 +109,7 @@ module VCenterDriver
109
109
  def self.needs_unpack?(file_path)
110
110
  type = get_type(file_path)
111
111
  type.gsub!(%r{^application/(x-)?}, '')
112
- ['bzip2', 'gzip', 'tar'].include?(type)
112
+ %w[bzip2 gzip tar].include?(type)
113
113
  end
114
114
 
115
115
  def self.vcenter_file_info(file_path)
data/lib/host.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -233,7 +233,7 @@ module VCenterDriver
233
233
  end
234
234
 
235
235
  nxs_type = @one_item['TEMPLATE/NSX_TYPE']
236
- return unless nxs_type == NSXDriver::NSXConstants::NSXT
236
+ unless nxs_type == NSXDriver::NSXConstants::NSXT; return; end
237
237
 
238
238
  # URL to test a connection
239
239
  url = '/api/v1/transport-zones'
@@ -352,7 +352,7 @@ module VCenterDriver
352
352
  str_info << 'USEDMEMORY=' << (total_mem - free_mem).to_s << "\n"
353
353
 
354
354
  # DRS enabled
355
- str_info << 'VCENTER_DRS=' << drs_enabled.to_s << "\n"
355
+ str_info << 'VCENTER_DRS=' << drs_enabled.to_s << "\n"
356
356
 
357
357
  # HA enabled
358
358
  str_info << 'VCENTER_HA=' << ha_enabled.to_s << "\n"
data/lib/logical_port.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
data/lib/memoize.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
data/lib/models/role.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # -------------------------------------------------------------------------- #
2
- # Copyright 2002-2023, OpenNebula Project, OpenNebula Systems #
2
+ # Copyright 2002-2022, OpenNebula Project, OpenNebula Systems #
3
3
  # #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License"); you may #
5
5
  # not use this file except in compliance with the License. You may obtain #
@@ -32,26 +32,26 @@ module OpenNebula
32
32
  attr_reader :service
33
33
 
34
34
  # Actions that can be performed on the VMs of a given Role
35
- SCHEDULE_ACTIONS = [
36
- 'terminate',
37
- 'terminate-hard',
38
- 'undeploy',
39
- 'undeploy-hard',
40
- 'hold',
41
- 'release',
42
- 'stop',
43
- 'suspend',
44
- 'resume',
45
- 'reboot',
46
- 'reboot-hard',
47
- 'poweroff',
48
- 'poweroff-hard',
49
- 'snapshot-create',
50
- 'snapshot-revert',
51
- 'snapshot-delete',
52
- 'disk-snapshot-create',
53
- 'disk-snapshot-revert',
54
- 'disk-snapshot-delete'
35
+ SCHEDULE_ACTIONS = %w[
36
+ terminate
37
+ terminate-hard
38
+ undeploy
39
+ undeploy-hard
40
+ hold
41
+ release
42
+ stop
43
+ suspend
44
+ resume
45
+ reboot
46
+ reboot-hard
47
+ poweroff
48
+ poweroff-hard
49
+ snapshot-create
50
+ snapshot-revert
51
+ snapshot-delete
52
+ disk-snapshot-create
53
+ disk-snapshot-revert
54
+ disk-snapshot-delete
55
55
  ]
56
56
 
57
57
  STATE = {
@@ -69,52 +69,52 @@ module OpenNebula
69
69
  'HOLD' => 11
70
70
  }
71
71
 
72
- STATE_STR = [
73
- 'PENDING',
74
- 'DEPLOYING',
75
- 'RUNNING',
76
- 'UNDEPLOYING',
77
- 'WARNING',
78
- 'DONE',
79
- 'FAILED_UNDEPLOYING',
80
- 'FAILED_DEPLOYING',
81
- 'SCALING',
82
- 'FAILED_SCALING',
83
- 'COOLDOWN',
84
- 'HOLD'
72
+ STATE_STR = %w[
73
+ PENDING
74
+ DEPLOYING
75
+ RUNNING
76
+ UNDEPLOYING
77
+ WARNING
78
+ DONE
79
+ FAILED_UNDEPLOYING
80
+ FAILED_DEPLOYING
81
+ SCALING
82
+ FAILED_SCALING
83
+ COOLDOWN
84
+ HOLD
85
85
  ]
86
86
 
87
- RECOVER_DEPLOY_STATES = [
88
- 'FAILED_DEPLOYING',
89
- 'DEPLOYING',
90
- 'PENDING'
87
+ RECOVER_DEPLOY_STATES = %w[
88
+ FAILED_DEPLOYING
89
+ DEPLOYING
90
+ PENDING
91
91
  ]
92
92
 
93
- RECOVER_UNDEPLOY_STATES = [
94
- 'FAILED_UNDEPLOYING',
95
- 'UNDEPLOYING'
93
+ RECOVER_UNDEPLOY_STATES = %w[
94
+ FAILED_UNDEPLOYING
95
+ UNDEPLOYING
96
96
  ]
97
97
 
98
- RECOVER_SCALE_STATES = [
99
- 'FAILED_SCALING',
100
- 'SCALING'
98
+ RECOVER_SCALE_STATES = %w[
99
+ FAILED_SCALING
100
+ SCALING
101
101
  ]
102
102
 
103
- VM_FAILURE_STATES = [
104
- 'BOOT_FAILURE',
105
- 'BOOT_MIGRATE_FAILURE',
106
- 'PROLOG_MIGRATE_FAILURE',
107
- 'PROLOG_FAILURE',
108
- 'EPILOG_FAILURE',
109
- 'EPILOG_STOP_FAILURE',
110
- 'EPILOG_UNDEPLOY_FAILURE',
111
- 'PROLOG_MIGRATE_POWEROFF_FAILURE',
112
- 'PROLOG_MIGRATE_SUSPEND_FAILURE',
113
- 'PROLOG_MIGRATE_UNKNOWN_FAILURE',
114
- 'BOOT_UNDEPLOY_FAILURE',
115
- 'BOOT_STOPPED_FAILURE',
116
- 'PROLOG_RESUME_FAILURE',
117
- 'PROLOG_UNDEPLOY_FAILURE'
103
+ VM_FAILURE_STATES = %w[
104
+ BOOT_FAILURE
105
+ BOOT_MIGRATE_FAILURE
106
+ PROLOG_MIGRATE_FAILURE
107
+ PROLOG_FAILURE
108
+ EPILOG_FAILURE
109
+ EPILOG_STOP_FAILURE
110
+ EPILOG_UNDEPLOY_FAILURE
111
+ PROLOG_MIGRATE_POWEROFF_FAILURE
112
+ PROLOG_MIGRATE_SUSPEND_FAILURE
113
+ PROLOG_MIGRATE_UNKNOWN_FAILURE
114
+ BOOT_UNDEPLOY_FAILURE
115
+ BOOT_STOPPED_FAILURE
116
+ PROLOG_RESUME_FAILURE
117
+ PROLOG_UNDEPLOY_FAILURE
118
118
  ]
119
119
 
120
120
  SCALE_WAYS = {
@@ -129,17 +129,17 @@ module OpenNebula
129
129
  # parents: this has only sense in deploy operation
130
130
  # state: this is internal information managed by OneFlow server
131
131
  # vm_template: this will affect scale operation
132
- IMMUTABLE_ATTRS = [
133
- 'cardinality',
134
- 'last_vmname',
135
- 'nodes',
136
- 'parents',
137
- 'state',
138
- 'vm_template'
132
+ IMMUTABLE_ATTRS = %w[
133
+ cardinality
134
+ last_vmname
135
+ nodes
136
+ parents
137
+ state
138
+ vm_template
139
139
  ]
140
140
 
141
141
  # VM information to save in document
142
- VM_INFO = ['ID', 'UID', 'GID', 'UNAME', 'GNAME', 'NAME']
142
+ VM_INFO = %w[ID UID GID UNAME GNAME NAME]
143
143
 
144
144
  LOG_COMP = 'ROL'
145
145
 
@@ -455,6 +455,9 @@ module OpenNebula
455
455
  extra_template << "\nSERVICE_ID = #{@service.id}"
456
456
  extra_template << "\nROLE_NAME = \"#{@body['name']}\""
457
457
 
458
+ # Evaluate attributes with parent roles
459
+ evaluate(extra_template)
460
+
458
461
  n_nodes.times do
459
462
  vm_name = @@vm_name_template
460
463
  .gsub('$SERVICE_ID', @service.id.to_s)
@@ -1122,7 +1125,7 @@ module OpenNebula
1122
1125
  # Min is a hard limit, if the current cardinality + adjustment does
1123
1126
  # not reach it, the difference is added
1124
1127
 
1125
- max = [cardinality, max_cardinality.to_i].max
1128
+ max = [cardinality, max_cardinality.to_i].max()
1126
1129
  # min = [cardinality(), min_cardinality.to_i].min()
1127
1130
  min = min_cardinality.to_i
1128
1131
 
@@ -1168,6 +1171,49 @@ module OpenNebula
1168
1171
  new_cardinality
1169
1172
  end
1170
1173
 
1174
+ # Evaluate rules that references to parent roles
1175
+ #
1176
+ # @param template [String] Role template with $ to replace
1177
+ def evaluate(template)
1178
+ client = service.client
1179
+
1180
+ template.scan(/\$\{(.*?)\}/).flatten.each do |value|
1181
+ s_value = value.split('.') # 0 -> parent, 1..N -> XPATH
1182
+
1183
+ # If parent not found, instead of error, replace it by blank
1184
+ unless parents.include?(s_value[0])
1185
+ template.gsub!("${#{value}}", '')
1186
+ next
1187
+ end
1188
+
1189
+ found = false
1190
+ p_nodes = service.roles[s_value[0]].nodes
1191
+ xpath = "//#{s_value[1..-1].join('/').upcase}"
1192
+
1193
+ # Iterate over parent nodes to find the XPATH on their template
1194
+ p_nodes.each do |node|
1195
+ id = node['deploy_id']
1196
+ vm = OpenNebula::VirtualMachine.new_with_id(id, client)
1197
+
1198
+ # If error continue searching in other nodes
1199
+ next if OpenNebula.is_error?(vm.info)
1200
+
1201
+ next unless vm[xpath]
1202
+
1203
+ template.gsub!("${#{value}}", vm[xpath])
1204
+
1205
+ # If found, continue with next expression
1206
+ found = true
1207
+ break
1208
+ end
1209
+
1210
+ next if found
1211
+
1212
+ # If value not found, replace it by blank to avoid issues
1213
+ template.gsub!("${#{value}}", '')
1214
+ end
1215
+ end
1216
+
1171
1217
  end
1172
1218
 
1173
1219
  end