blob: 1d8a593b9f3867917168ca1771128682ddad40ca [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)
jrperritt29ae6b32016-04-13 12:59:37 -050012 return
Jamie Hannaford583e23d2014-11-13 13:22:29 +010013}
14
Jamie Hannaford1c015e12014-11-13 13:23:14 +010015// Stop is the operation responsible for stopping a Compute server.
Jon Perritt3860b512016-03-29 12:01:48 -050016func Stop(client *gophercloud.ServiceClient, id string) (r gophercloud.ErrResult) {
Jon Perrittdb0ae142016-03-13 00:33:41 -060017 _, r.Err = client.Post(actionURL(client, id), map[string]interface{}{"os-stop": nil}, nil, nil)
jrperritt29ae6b32016-04-13 12:59:37 -050018 return
Jamie Hannaford583e23d2014-11-13 13:22:29 +010019}