blob: 0e090e69f26bd6d10597e2bb2b65a57fa4f3f09e [file] [log] [blame]
Jamie Hannaford583e23d2014-11-13 13:22:29 +01001package startstop
2
Ash Wilson59fb6c42015-02-12 16:21:13 -05003import "github.com/rackspace/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 {
11 var res gophercloud.ErrResult
Jamie Hannaford3f8c8d82014-11-17 10:55:24 +010012 reqBody := map[string]interface{}{"os-start": nil}
Jamie Hannaford6a3a78f2015-03-24 14:56:12 +010013 _, res.Err = client.Post(actionURL(client, id), reqBody, nil, nil)
Jamie Hannaford583e23d2014-11-13 13:22:29 +010014 return res
15}
16
Jamie Hannaford1c015e12014-11-13 13:23:14 +010017// Stop is the operation responsible for stopping a Compute server.
Jamie Hannaford583e23d2014-11-13 13:22:29 +010018func Stop(client *gophercloud.ServiceClient, id string) gophercloud.ErrResult {
19 var res gophercloud.ErrResult
Jamie Hannaford3f8c8d82014-11-17 10:55:24 +010020 reqBody := map[string]interface{}{"os-stop": nil}
Jamie Hannaford6a3a78f2015-03-24 14:56:12 +010021 _, res.Err = client.Post(actionURL(client, id), reqBody, nil, nil)
Jamie Hannaford583e23d2014-11-13 13:22:29 +010022 return res
23}