@ -861,6 +861,13 @@ def reconfigure_vm(vsphere_client, vm, module, esxi, resource_pool, cluster_name
# Resize hard drives
# Resize hard drives
if vm_disk :
if vm_disk :
spec = spec_singleton ( spec , request , vm )
spec = spec_singleton ( spec , request , vm )
# Get a list of the VM's hard drives
dev_list = [ d for d in vm . properties . config . hardware . device if d . _type == ' VirtualDisk ' ]
if len ( vm_disk ) > len ( dev_list ) :
vsphere_client . disconnect ( )
module . fail_json ( msg = " Error in vm_disk definition. Too many disks defined in comparison to the VM ' s disk profile. " )
disk_num = 0
disk_num = 0
dev_changes = [ ]
dev_changes = [ ]
disks_changed = { }
disks_changed = { }
@ -873,12 +880,6 @@ def reconfigure_vm(vsphere_client, vm, module, esxi, resource_pool, cluster_name
vsphere_client . disconnect ( )
vsphere_client . disconnect ( )
module . fail_json ( msg = " Error in ' %s ' definition. Size needs to be specified as an integer. " % disk )
module . fail_json ( msg = " Error in ' %s ' definition. Size needs to be specified as an integer. " % disk )
# Get a list of the hard drives
dev_list = [ d for d in vm . properties . config . hardware . device if d . _type == ' VirtualDisk ' ]
if disk_num > = len ( dev_list ) :
vsphere_client . disconnect ( )
module . fail_json ( msg = " Error in ' %s ' definition. Too many disks defined in comparison to the VM ' s disk profile. " % disk )
# Make sure the new disk size is higher than the current value
# Make sure the new disk size is higher than the current value
dev = dev_list [ disk_num ]
dev = dev_list [ disk_num ]
if disksize < int ( dev . capacityInKB ) :
if disksize < int ( dev . capacityInKB ) :