1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

force evaluation of vars memory_mb, num_cpus to be int fixes #7903

This commit is contained in:
Dann Bohn 2014-06-23 11:16:03 -04:00
parent 65a8ffef6e
commit 677e99e375

View file

@ -496,7 +496,7 @@ def reconfigure_vm(vsphere_client, vm, module, esxi, resource_pool, cluster_name
# Change Memory # Change Memory
if vm_hardware['memory_mb']: if vm_hardware['memory_mb']:
if vm_hardware['memory_mb'] != vm.properties.config.hardware.memoryMB: if int(vm_hardware['memory_mb']) != vm.properties.config.hardware.memoryMB:
spec = spec_singleton(spec, request, vm) spec = spec_singleton(spec, request, vm)
if vm.is_powered_on(): if vm.is_powered_on():
@ -504,7 +504,7 @@ def reconfigure_vm(vsphere_client, vm, module, esxi, resource_pool, cluster_name
# No hot add but force # No hot add but force
if not memoryHotAddEnabled: if not memoryHotAddEnabled:
shutdown = True shutdown = True
elif vm_hardware['memory_mb'] < vm.properties.config.hardware.memoryMB: elif int(vm_hardware['memory_mb']) < vm.properties.config.hardware.memoryMB:
shutdown = True shutdown = True
else: else:
# Fail on no hot add and no force # Fail on no hot add and no force
@ -514,7 +514,7 @@ def reconfigure_vm(vsphere_client, vm, module, esxi, resource_pool, cluster_name
"required for shutdown") "required for shutdown")
# Fail on no force and memory shrink # Fail on no force and memory shrink
elif vm_hardware['memory_mb'] < vm.properties.config.hardware.memoryMB: elif int(vm_hardware['memory_mb']) < vm.properties.config.hardware.memoryMB:
module.fail_json( module.fail_json(
msg="Cannot lower memory on a live VM. force is " msg="Cannot lower memory on a live VM. force is "
"required for shutdown") "required for shutdown")
@ -525,7 +525,7 @@ def reconfigure_vm(vsphere_client, vm, module, esxi, resource_pool, cluster_name
# ====( Config Memory )====# # ====( Config Memory )====#
if vm_hardware['num_cpus']: if vm_hardware['num_cpus']:
if vm_hardware['num_cpus'] != vm.properties.config.hardware.numCPU: if int(vm_hardware['num_cpus']) != vm.properties.config.hardware.numCPU:
spec = spec_singleton(spec, request, vm) spec = spec_singleton(spec, request, vm)
if vm.is_powered_on(): if vm.is_powered_on():
@ -533,7 +533,7 @@ def reconfigure_vm(vsphere_client, vm, module, esxi, resource_pool, cluster_name
# No hot add but force # No hot add but force
if not cpuHotAddEnabled: if not cpuHotAddEnabled:
shutdown = True shutdown = True
elif vm_hardware['num_cpus'] < vm.properties.config.hardware.numCPU: elif int(vm_hardware['num_cpus']) < vm.properties.config.hardware.numCPU:
if not cpuHotRemoveEnabled: if not cpuHotRemoveEnabled:
shutdown = True shutdown = True
else: else:
@ -544,7 +544,7 @@ def reconfigure_vm(vsphere_client, vm, module, esxi, resource_pool, cluster_name
"required for shutdown") "required for shutdown")
# Fail on no force and cpu shrink without hot remove # Fail on no force and cpu shrink without hot remove
elif vm_hardware['num_cpus'] < vm.properties.config.hardware.numCPU: elif int(vm_hardware['num_cpus']) < vm.properties.config.hardware.numCPU:
if not cpuHotRemoveEnabled: if not cpuHotRemoveEnabled:
module.fail_json( module.fail_json(
msg="Cannot lower CPU on a live VM without " msg="Cannot lower CPU on a live VM without "