mirror of
https://github.com/OpenNebula/one.git
synced 2025-02-26 09:57:23 +03:00
Signed-off-by: Carlos J. Herrera Matos <cherrera@opennebula.systems>
This commit is contained in:
parent
8fb20107e2
commit
e1a6bf51cf
@ -930,6 +930,34 @@ module VCenterDriver
|
||||
{}
|
||||
end
|
||||
|
||||
def reference_disks_all(template_ref = nil, execute = true)
|
||||
extraconfig = []
|
||||
spec = {}
|
||||
|
||||
# Get unmanaged disks in OpenNebula's VM template
|
||||
xpath = "TEMPLATE/DISK[OPENNEBULA_MANAGED=\"NO\" or OPENNEBULA_MANAGED=\"no\"]"
|
||||
unmanaged_disks = one_item.retrieve_xmlelements(xpath)
|
||||
|
||||
managed = false
|
||||
extraconfig + reference_disks(template_ref, unmanaged_disks, managed)
|
||||
|
||||
# Get managed disks in OpenNebula's VM template
|
||||
xpath = "TEMPLATE/DISK[OPENNEBULA_MANAGED=\"YES\" or OPENNEBULA_MANAGED=\"yes\"]"
|
||||
managed_disks = one_item.retrieve_xmlelements(xpath)
|
||||
|
||||
managed = true
|
||||
extraconfig + reference_disks(template_ref, managed_disks, managed)
|
||||
|
||||
# Save in extraconfig the key for unmanaged disks
|
||||
unless extraconfig.empty?
|
||||
spec[:extraConfig] = extraconfig unless extraconfig.empty?
|
||||
|
||||
return spec unless execute
|
||||
|
||||
@item.ReconfigVM_Task(:spec => spec).wait_for_completion
|
||||
end
|
||||
end
|
||||
|
||||
# Build extraconfig section to reference disks
|
||||
# by key and avoid problems with changing paths
|
||||
# (mainly due to snapshots)
|
||||
@ -2242,6 +2270,7 @@ module VCenterDriver
|
||||
|
||||
def shutdown
|
||||
if !is_powered_off?
|
||||
reference_disks_all
|
||||
begin
|
||||
if vm_tools?
|
||||
@item.ShutdownGuest
|
||||
@ -2266,6 +2295,7 @@ module VCenterDriver
|
||||
end
|
||||
|
||||
def reset
|
||||
reference_disks_all
|
||||
@item.ResetVM_Task.wait_for_completion
|
||||
end
|
||||
|
||||
@ -2274,10 +2304,12 @@ module VCenterDriver
|
||||
end
|
||||
|
||||
def reboot
|
||||
reference_disks_all
|
||||
@item.RebootGuest
|
||||
end
|
||||
|
||||
def poweron(set_running = false)
|
||||
reference_disks_all
|
||||
begin
|
||||
@item.PowerOnVM_Task.wait_for_completion
|
||||
rescue RbVmomi::Fault => e
|
||||
|
@ -37,6 +37,7 @@ require 'vcenter_driver'
|
||||
|
||||
vm_ref = ARGV[0]
|
||||
vc_cluster_name = ARGV[1]
|
||||
vm_id = ARGV[2]
|
||||
|
||||
drv_action = OpenNebula::XMLElement.new
|
||||
drv_action.initialize_xml(Base64.decode64(STDIN.read), 'VMM_DRIVER_ACTION_DATA')
|
||||
@ -46,7 +47,7 @@ host_id = drv_action['VM/HISTORY_RECORDS/HISTORY/HID']
|
||||
begin
|
||||
vi_client = VCenterDriver::VIClient.new_from_host(host_id)
|
||||
|
||||
vm = VCenterDriver::VirtualMachine.new_without_id(vi_client, vm_ref)
|
||||
vm = VCenterDriver::VirtualMachine.new(vi_client, vm_ref, vm_id)
|
||||
|
||||
vm.reboot
|
||||
rescue StandardError => e
|
||||
|
@ -37,6 +37,7 @@ require 'vcenter_driver'
|
||||
|
||||
vm_ref = ARGV[0]
|
||||
vc_cluster_name = ARGV[1]
|
||||
vm_id = ARGV[2]
|
||||
|
||||
drv_action = OpenNebula::XMLElement.new
|
||||
drv_action.initialize_xml(Base64.decode64(STDIN.read), 'VMM_DRIVER_ACTION_DATA')
|
||||
@ -45,7 +46,7 @@ host_id = drv_action['VM/HISTORY_RECORDS/HISTORY/HID']
|
||||
|
||||
begin
|
||||
vi_client = VCenterDriver::VIClient.new_from_host(host_id)
|
||||
vm = VCenterDriver::VirtualMachine.new_without_id(vi_client, vm_ref)
|
||||
vm = VCenterDriver::VirtualMachine.new(vi_client, vm_ref, vm_id)
|
||||
|
||||
vm.reset
|
||||
rescue StandardError => e
|
||||
|
Loading…
x
Reference in New Issue
Block a user