github.com/emc-advanced-dev/unik@v0.0.0-20190717152701-a58d3e8e33b7/pkg/providers/photon/stop_instance.go (about)

     1  package photon
     2  
     3  import "github.com/emc-advanced-dev/pkg/errors"
     4  
     5  func (p *PhotonProvider) StopInstance(id string) error {
     6  	instance, err := p.GetInstance(id)
     7  	if err != nil {
     8  		return errors.New("retrieving instance "+id, err)
     9  	}
    10  	task, err := p.client.VMs.Stop(instance.Id)
    11  	if err != nil {
    12  		return errors.New("Stopping vm", err)
    13  	}
    14  
    15  	task, err = p.waitForTaskSuccess(task)
    16  	if err != nil {
    17  		return errors.New("Stopping vm", err)
    18  	}
    19  	return nil
    20  }