mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-25 06:03:36 +03:00
Co-authored-by: Tino Vázquez <cvazquez@opennebula.io>
This commit is contained in:
parent
630168f903
commit
e8ff50320e
@ -463,6 +463,32 @@ module VCenterDriver
|
||||
def clone_vm(drv_action)
|
||||
vcenter_name = get_vcenter_name
|
||||
|
||||
dc = cluster.get_dc
|
||||
|
||||
vcenter_vm_folder = drv_action['USER_TEMPLATE/VCENTER_VM_FOLDER']
|
||||
|
||||
if !vcenter_vm_folder.nil? && !vcenter_vm_folder.empty?
|
||||
vcenter_vm_folder =
|
||||
vcenter_folder_name(vcenter_vm_folder, drv_action)
|
||||
|
||||
vcenter_vm_folder_object =
|
||||
dc.item.find_folder(vcenter_vm_folder)
|
||||
|
||||
if vcenter_vm_folder_object.nil?
|
||||
begin
|
||||
dc.item.vmFolder.CreateFolder(
|
||||
:name => vcenter_vm_folder
|
||||
)
|
||||
rescue StandardError => e
|
||||
error_message = e.message
|
||||
if VCenterDriver::CONFIG[:debug_information]
|
||||
error_message += " " + e.backtrace
|
||||
end
|
||||
raise "Cannot create Folder in vCenter: #{error_message}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
vc_template_ref = drv_action['USER_TEMPLATE/VCENTER_TEMPLATE_REF']
|
||||
vc_template = RbVmomi::VIM::VirtualMachine(@vi_client.vim, vc_template_ref)
|
||||
|
||||
@ -477,10 +503,6 @@ module VCenterDriver
|
||||
|
||||
clone_spec = RbVmomi::VIM.VirtualMachineCloneSpec(spec_hash)
|
||||
|
||||
# Specify vm folder in vSpere's VM and Templates view F#4823
|
||||
vcenter_vm_folder = nil
|
||||
vcenter_vm_folder = drv_action["USER_TEMPLATE/VCENTER_VM_FOLDER"]
|
||||
dc = cluster.get_dc
|
||||
vcenter_vm_folder_object = vcenter_folder(vcenter_vm_folder, vc_template, dc)
|
||||
|
||||
if ds.instance_of? RbVmomi::VIM::StoragePod
|
||||
@ -638,6 +660,17 @@ module VCenterDriver
|
||||
disk_move_type
|
||||
end
|
||||
|
||||
# @return String vcenter folder name
|
||||
def vcenter_folder_name(vm_folder_name, drv_action)
|
||||
uname = drv_action['UNAME']
|
||||
gname = drv_action['GNAME']
|
||||
|
||||
vm_folder_name.gsub!('$uname', uname)
|
||||
vm_folder_name.gsub!('$gname', gname)
|
||||
|
||||
vm_folder_name
|
||||
end
|
||||
|
||||
# Get vcenter folder object from the reference
|
||||
# If folder is not found, the folder of the
|
||||
# vCenter VM Template is returned
|
||||
|
Loading…
x
Reference in New Issue
Block a user