Only undeploy a machine if it is switched on
This commit is contained in:
parent
5dde514281
commit
a02667389e
|
@ -315,6 +315,12 @@ func resourceVcdVAppDelete(d *schema.ResourceData, meta interface{}) error {
|
||||||
return fmt.Errorf("error finding vapp: %s", err)
|
return fmt.Errorf("error finding vapp: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
status, err := vapp.GetStatus()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error getting VApp status: %#v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if status == "POWERED_ON" {
|
||||||
err = retryCall(vcdClient.MaxRetryTimeout, func() error {
|
err = retryCall(vcdClient.MaxRetryTimeout, func() error {
|
||||||
task, err := vapp.Undeploy()
|
task, err := vapp.Undeploy()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -326,6 +332,7 @@ func resourceVcdVAppDelete(d *schema.ResourceData, meta interface{}) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
err = retryCall(vcdClient.MaxRetryTimeout, func() error {
|
err = retryCall(vcdClient.MaxRetryTimeout, func() error {
|
||||||
task, err := vapp.Delete()
|
task, err := vapp.Delete()
|
||||||
|
|
Loading…
Reference in New Issue