From fe18bee1d28f4d4dcae1c21f0f2346fa9506c688 Mon Sep 17 00:00:00 2001 From: tgdkhvi1 Date: Mon, 10 Jun 2019 19:50:17 +0200 Subject: [PATCH 1/2] fix typo that undeploys vapp instead of vm --- vcd/resource_vcd_vapp_vm.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/vcd/resource_vcd_vapp_vm.go b/vcd/resource_vcd_vapp_vm.go index 914ea071a..fe869835d 100644 --- a/vcd/resource_vcd_vapp_vm.go +++ b/vcd/resource_vcd_vapp_vm.go @@ -825,15 +825,15 @@ func resourceVcdVAppVmDelete(d *schema.ResourceData, meta interface{}) error { return fmt.Errorf("error getting VM4 : %#v", err) } - status, err := vapp.GetStatus() + status, err := vm.GetStatus() if err != nil { - return fmt.Errorf("error getting vApp status: %#v", err) + return fmt.Errorf("error getting VM status: %#v", err) } - log.Printf("[TRACE] vApp Status:: %s", status) + log.Printf("[TRACE] VM Status:: %s", status) if status != "POWERED_OFF" { - log.Printf("[TRACE] Undeploying vApp: %s", vapp.VApp.Name) - task, err := vapp.Undeploy() + log.Printf("[TRACE] Undeploying VM: %s", vm.VM.Name) + task, err := vm.Undeploy() if err != nil { return fmt.Errorf("error Undeploying: %#v", err) } From 7f6125dc8b910560cb855727caba686dcf5174ed Mon Sep 17 00:00:00 2001 From: tgdkhvi1 Date: Fri, 14 Jun 2019 22:38:06 +0200 Subject: [PATCH 2/2] Remove the vapp deployment after vm deletion --- vcd/resource_vcd_vapp_vm.go | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/vcd/resource_vcd_vapp_vm.go b/vcd/resource_vcd_vapp_vm.go index fe869835d..47bc1a0aa 100644 --- a/vcd/resource_vcd_vapp_vm.go +++ b/vcd/resource_vcd_vapp_vm.go @@ -870,29 +870,6 @@ func resourceVcdVAppVmDelete(d *schema.ResourceData, meta interface{}) error { return fmt.Errorf("error deleting: %#v", err) } - if status != "POWERED_OFF" { - log.Printf("[TRACE] Redeploying vApp: %s", vapp.VApp.Name) - task, err := vapp.Deploy() - if err != nil { - return fmt.Errorf("error Deploying vApp: %#v", err) - } - err = task.WaitTaskCompletion() - if err != nil { - return fmt.Errorf(errorCompletingTask, err) - } - - log.Printf("[TRACE] Powering on vApp: %s", vapp.VApp.Name) - task, err = vapp.PowerOn() - if err != nil { - return fmt.Errorf("error Powering Up vApp: %#v", err) - } - - err = task.WaitTaskCompletion() - if err != nil { - return fmt.Errorf("error Powering Up vApp: %#v", err) - } - } - return nil }