mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-25 02:50:08 +03:00
Co-authored-by: Tino Vázquez <cvazquez@opennebula.io> (cherry picked from commit 1fc5b5afe67d643d042c8b9c5a3f7cde0ee474bc)
This commit is contained in:
parent
409248c9e6
commit
186694626a
@ -712,7 +712,7 @@ module VCenterDriver
|
||||
|
||||
# Only take care of VMs, not templates
|
||||
if !hashed_properties['config.template']
|
||||
vms[r.obj._ref] = hashed_properties
|
||||
vms[r.obj._ref + "_" + vc_uuid] = hashed_properties
|
||||
vm_objects << r.obj
|
||||
end
|
||||
end
|
||||
|
@ -117,6 +117,16 @@ module VCenterDriver
|
||||
|
||||
return_if_error(rc, item, exit_if_fail)
|
||||
end
|
||||
|
||||
# Since https://github.com/OpenNebula/one/issues/5689
|
||||
# there two deploy_ids allowed:
|
||||
# * moref, eg: vm-567
|
||||
# * moref +"_" + vcenter uuid, eg:
|
||||
# 2499952a-6c85-480e-b7df-4cbd2137eb69_vm-456
|
||||
# This function will always return the moref
|
||||
def self.get_deploy_id(deploy_id)
|
||||
return deploy_id.split("_")[0]
|
||||
end
|
||||
|
||||
def self.find_by_name(the_class, name, pool = nil, raise_if_fail = true)
|
||||
pool = one_pool(the_class, raise_if_fail) if pool.nil?
|
||||
|
@ -103,6 +103,7 @@ end
|
||||
|
||||
def initialize(vi_client, ref, one_id)
|
||||
if ref
|
||||
ref = VCenterDriver::VIHelper.get_deploy_id(ref)
|
||||
@item = RbVmomi::VIM::VirtualMachine.new(vi_client.vim, ref)
|
||||
check_item(@item, RbVmomi::VIM::VirtualMachine)
|
||||
end
|
||||
|
@ -46,6 +46,7 @@ module VCenterDriver
|
||||
vm_ref = selected['DEPLOY_ID'] || selected[:wild]['DEPLOY_ID']
|
||||
vm = selected[:one_item] || build
|
||||
template = selected[:template] || import_tmplt
|
||||
template = "DEPLOY_ID = #{vm_ref}\n" + template
|
||||
host_id = selected[:host] || @list.keys[0]
|
||||
|
||||
vc_uuid = @vi_client.vim.serviceContent.about.instanceUuid
|
||||
|
3
src/vmm_mad/remotes/vcenter/deploy
Executable file → Normal file
3
src/vmm_mad/remotes/vcenter/deploy
Executable file → Normal file
@ -75,6 +75,7 @@ deploy[:boot] = drv_action['TEMPLATE/OS/BOOT'] \
|
||||
begin
|
||||
retries ||= 0
|
||||
vi_client = VCenterDriver::VIClient.new_from_host(host_id)
|
||||
vc_uuid = vi_client.vim.serviceContent.about.instanceUuid
|
||||
one_vm = VCenterDriver::VIHelper.one_item(OpenNebula::VirtualMachine, vm_id)
|
||||
|
||||
if !drv_action.retrieve_xmlelements('USER_TEMPLATE/VCENTER_TAG').empty? &&
|
||||
@ -132,7 +133,7 @@ begin
|
||||
vm.poweron(set_running)
|
||||
end
|
||||
|
||||
puts vm['_ref']
|
||||
puts vm['_ref'] + "_" + vc_uuid
|
||||
rescue StandardError => e
|
||||
message = "Deploy of VM #{vm_id} on vCenter cluster #{cluster_name} " \
|
||||
"with #{dfile} failed due to \"#{e.message}\"" \
|
||||
|
Loading…
x
Reference in New Issue
Block a user