Jamie Hannaford | 583e23d | 2014-11-13 13:22:29 +0100 | [diff] [blame] | 1 | package startstop |
| 2 | |
Jon Perritt | 27249f4 | 2016-02-18 10:35:59 -0600 | [diff] [blame^] | 3 | import "github.com/gophercloud/gophercloud" |
Jamie Hannaford | 583e23d | 2014-11-13 13:22:29 +0100 | [diff] [blame] | 4 | |
| 5 | func actionURL(client *gophercloud.ServiceClient, id string) string { |
| 6 | return client.ServiceURL("servers", id, "action") |
| 7 | } |
| 8 | |
Jamie Hannaford | 1c015e1 | 2014-11-13 13:23:14 +0100 | [diff] [blame] | 9 | // Start is the operation responsible for starting a Compute server. |
Jamie Hannaford | 583e23d | 2014-11-13 13:22:29 +0100 | [diff] [blame] | 10 | func Start(client *gophercloud.ServiceClient, id string) gophercloud.ErrResult { |
| 11 | var res gophercloud.ErrResult |
Jamie Hannaford | 3f8c8d8 | 2014-11-17 10:55:24 +0100 | [diff] [blame] | 12 | reqBody := map[string]interface{}{"os-start": nil} |
Jamie Hannaford | 6a3a78f | 2015-03-24 14:56:12 +0100 | [diff] [blame] | 13 | _, res.Err = client.Post(actionURL(client, id), reqBody, nil, nil) |
Jamie Hannaford | 583e23d | 2014-11-13 13:22:29 +0100 | [diff] [blame] | 14 | return res |
| 15 | } |
| 16 | |
Jamie Hannaford | 1c015e1 | 2014-11-13 13:23:14 +0100 | [diff] [blame] | 17 | // Stop is the operation responsible for stopping a Compute server. |
Jamie Hannaford | 583e23d | 2014-11-13 13:22:29 +0100 | [diff] [blame] | 18 | func Stop(client *gophercloud.ServiceClient, id string) gophercloud.ErrResult { |
| 19 | var res gophercloud.ErrResult |
Jamie Hannaford | 3f8c8d8 | 2014-11-17 10:55:24 +0100 | [diff] [blame] | 20 | reqBody := map[string]interface{}{"os-stop": nil} |
Jamie Hannaford | 6a3a78f | 2015-03-24 14:56:12 +0100 | [diff] [blame] | 21 | _, res.Err = client.Post(actionURL(client, id), reqBody, nil, nil) |
Jamie Hannaford | 583e23d | 2014-11-13 13:22:29 +0100 | [diff] [blame] | 22 | return res |
| 23 | } |