blob: 460223a4a699c3d000d1634e3b75953d0c40d896 [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.
Jamie Hannaford583e23d2014-11-13 13:22:29 +010010func Start(client *gophercloud.ServiceClient, id string) gophercloud.ErrResult {
Jon Perrittdb0ae142016-03-13 00:33:41 -060011 var r gophercloud.ErrResult
12 _, r.Err = client.Post(actionURL(client, id), map[string]interface{}{"os-start": nil}, nil, nil)
13 return r
Jamie Hannaford583e23d2014-11-13 13:22:29 +010014}
15
Jamie Hannaford1c015e12014-11-13 13:23:14 +010016// Stop is the operation responsible for stopping a Compute server.
Jamie Hannaford583e23d2014-11-13 13:22:29 +010017func Stop(client *gophercloud.ServiceClient, id string) gophercloud.ErrResult {
Jon Perrittdb0ae142016-03-13 00:33:41 -060018 var r gophercloud.ErrResult
19 _, r.Err = client.Post(actionURL(client, id), map[string]interface{}{"os-stop": nil}, nil, nil)
20 return r
Jamie Hannaford583e23d2014-11-13 13:22:29 +010021}