Skip to content

Commit

Permalink
Undeploy before deleting
Browse files Browse the repository at this point in the history
  • Loading branch information
juanfont authored Feb 15, 2021
1 parent 6cc1db7 commit 275349d
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions driver/vcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,18 +480,23 @@ func (d *Driver) Remove() error {
return err
}

status, _ := vapp.GetStatus()
if status != "POWERED_OFF" {
task, err := vapp.PowerOff() // we no longer care, so no shutdown
if err != nil {
task, err := vapp.PowerOff()
if err == nil {
log.Infof("Powering off...")
if err = task.WaitTaskCompletion(); err != nil {
return err
}
}

task, err = vapp.Undeploy()
if err == nil {
log.Infof("Undeploying...")
if err = task.WaitTaskCompletion(); err != nil {
return err
}
}

task, err := vapp.Delete()
task, err = vapp.Delete()
if err != nil {
return err
}
Expand Down Expand Up @@ -588,7 +593,7 @@ func (d *Driver) Start() error {
return nil
}

// Stop a host gracefully
// Stop a host not so gracefully
func (d *Driver) Stop() error {
client, err := newClient(*d.VcdURL, d.VcdUser, d.VcdPassword, d.VcdOrg, d.VcdInsecure)
if err != nil {
Expand All @@ -600,7 +605,7 @@ func (d *Driver) Stop() error {
if err != nil {
return err
}
task, err := vapp.Shutdown()
task, err := vapp.PowerOff()
if err != nil {
return err
}
Expand All @@ -609,4 +614,4 @@ func (d *Driver) Stop() error {
}

return nil
}
}

0 comments on commit 275349d

Please sign in to comment.