mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 21:00:22 -07:00
VMware: Check if VM is poweredoff before destroy (#35151)
This fix checks if VM is poweredoff before it can be destroyed. Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
parent
8d775a332e
commit
912729b6a7
3 changed files with 85 additions and 0 deletions
|
@ -617,6 +617,10 @@ class PyVmomiHelper(PyVmomi):
|
|||
|
||||
def remove_vm(self, vm):
|
||||
# https://www.vmware.com/support/developer/converter-sdk/conv60_apireference/vim.ManagedEntity.html#destroy
|
||||
if vm.summary.runtime.powerState.lower() == 'poweredon':
|
||||
self.module.fail_json(msg="Virtual machine %s found in 'powered on' state, "
|
||||
"please use 'force' parameter to remove or poweroff VM "
|
||||
"and try removing VM again." % vm.name)
|
||||
task = vm.Destroy()
|
||||
self.wait_for_task(task)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue