Checking for powered off state before deletion (#6283)
This commit is contained in:
parent
b1c215f5e2
commit
db558ddc6b
|
@ -638,7 +638,12 @@ func resourceVSphereVirtualMachineDelete(d *schema.ResourceData, meta interface{
|
|||
}
|
||||
|
||||
log.Printf("[INFO] Deleting virtual machine: %s", d.Id())
|
||||
state, err := vm.PowerState(context.TODO())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if state == types.VirtualMachinePowerStatePoweredOn {
|
||||
task, err := vm.PowerOff(context.TODO())
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -648,8 +653,9 @@ func resourceVSphereVirtualMachineDelete(d *schema.ResourceData, meta interface{
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
task, err = vm.Destroy(context.TODO())
|
||||
task, err := vm.Destroy(context.TODO())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue