mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
VMware: Handle exception gracefully (#36619)
This fix adds logic to handle exception raised from conversion of user parameter 'memory_mb'. Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
parent
7a4c3e5cad
commit
aadbb6c0b4
1 changed files with 6 additions and 1 deletions
|
@ -786,7 +786,12 @@ class PyVmomiHelper(PyVmomi):
|
|||
self.module.fail_json(msg="hardware.num_cpus attribute is mandatory for VM creation")
|
||||
|
||||
if 'memory_mb' in self.params['hardware']:
|
||||
try:
|
||||
self.configspec.memoryMB = int(self.params['hardware']['memory_mb'])
|
||||
except ValueError:
|
||||
self.module.fail_json(msg="Failed to parse hardware.memory_mb value."
|
||||
" Please refer the documentation and provide"
|
||||
" correct value.")
|
||||
if vm_obj is None or self.configspec.memoryMB != vm_obj.config.hardware.memoryMB:
|
||||
self.change_detected = True
|
||||
# memory_mb is mandatory for VM creation
|
||||
|
|
Loading…
Reference in a new issue