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

     1  package vsphere
     2  
     3  import (
     4  	"github.com/emc-advanced-dev/pkg/errors"
     5  )
     6  
     7  func (p *VsphereProvider) StopInstance(id string) error {
     8  	instance, err := p.GetInstance(id)
     9  	if err != nil {
    10  		return errors.New("retrieving instance "+id, err)
    11  	}
    12  	c := p.getClient()
    13  	err = c.PowerOffVm(instance.Name)
    14  	if err != nil {
    15  		return errors.New("failed to stop instance "+instance.Id, err)
    16  	}
    17  	return nil
    18  }