blob: 27076b7a25a0e2ef85d2914c033349bee891fabf [file] [log] [blame]
Jamie Hannaford583e23d2014-11-13 13:22:29 +01001package startstop
2
Jon Perritt27249f42016-02-18 10:35:59 -06003import "github.com/gophercloud/gophercloud"
Jamie Hannaford583e23d2014-11-13 13:22:29 +01004
5func actionURL(client *gophercloud.ServiceClient, id string) string {
6 return client.ServiceURL("servers", id, "action")
7}
8
Jamie Hannaford1c015e12014-11-13 13:23:14 +01009// Start is the operation responsible for starting a Compute server.
Jon Perritt3860b512016-03-29 12:01:48 -050010func Start(client *gophercloud.ServiceClient, id string) (r gophercloud.ErrResult) {
Jon Perrittdb0ae142016-03-13 00:33:41 -060011 _, r.Err = client.Post(actionURL(client, id), map[string]interface{}{"os-start": nil}, nil, nil)
Jamie Hannaford583e23d2014-11-13 13:22:29 +010012}
13
Jamie Hannaford1c015e12014-11-13 13:23:14 +010014// Stop is the operation responsible for stopping a Compute server.
Jon Perritt3860b512016-03-29 12:01:48 -050015func Stop(client *gophercloud.ServiceClient, id string) (r gophercloud.ErrResult) {
Jon Perrittdb0ae142016-03-13 00:33:41 -060016 _, r.Err = client.Post(actionURL(client, id), map[string]interface{}{"os-stop": nil}, nil, nil)
Jamie Hannaford583e23d2014-11-13 13:22:29 +010017}