B #5740: Remove unnecessary disks only on VM creation (#1808)

This commit is contained in:
Christian González authored and GitHub committed 2022-02-23 17:47:03 +01:00
1 parent 472893e254
commit ba5db04bb3
2 files changed
+10 -5

No files matched your search

@@ -1714,8 +1714,13 @@ end
def sync(deploy = {})
extraconfig = []
device_change = []
sync_opt = nil
disks = sync_disks(:all, false)
# Disk are only synced with :all option when VM is first created
# NOTE: Detach actions are implemented through TM (not sync)
sync_opt = :all if deploy[:new] == true
disks = sync_disks(sync_opt, false)
resize_unmanaged_disks
if deploy[:boot] && !deploy[:boot].empty?
@@ -2308,10 +2313,6 @@ end
extra_config = []
keys = disk_keys.invert
if keys.nil? || keys.empty?
raise 'Unable to find disk mapping information on vmx file.'
end
ipool = VCenterDriver::VIHelper.one_pool(OpenNebula::ImagePool)
disks_each(:detached?) do |d|
key = d.key.to_s
@@ -3435,6 +3436,7 @@ end
config[:esx_migration_list] = 'Selected_by_DRS'
end
vc_vm.reference_all_disks
vc_vm.migrate(config)
vm.replace({ 'VCENTER_CCR_REF' => ccr_ref })
+3
View File
@@ -85,8 +85,10 @@ begin
if deploy_id_valid?(deploy_id)
# VM is not new, we just need to reconfigure it and to power it on
deploy[:new] = false
vm = VCenterDriver::VirtualMachine.new_one(vi_client, deploy_id, one_vm)
else
deploy[:new] = true
vm = VCenterDriver::VirtualMachine.new_from_clone(vi_client,
drv_action,
vm_id)
@@ -127,6 +129,7 @@ begin
:spec => spec
).wait_for_completion
vm.reference_all_disks
vm.sync(deploy)
# Only mark the VM as running if we are deploying it for the first time
set_running = !deploy_id_valid?(deploy_id)