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. |
Jon Perritt | 3860b51 | 2016-03-29 12:01:48 -0500 | [diff] [blame^] | 10 | func Start(client *gophercloud.ServiceClient, id string) (r gophercloud.ErrResult) { |
Jon Perritt | db0ae14 | 2016-03-13 00:33:41 -0600 | [diff] [blame] | 11 | _, r.Err = client.Post(actionURL(client, id), map[string]interface{}{"os-start": nil}, nil, nil) |
Jamie Hannaford | 583e23d | 2014-11-13 13:22:29 +0100 | [diff] [blame] | 12 | } |
| 13 | |
Jamie Hannaford | 1c015e1 | 2014-11-13 13:23:14 +0100 | [diff] [blame] | 14 | // Stop is the operation responsible for stopping a Compute server. |
Jon Perritt | 3860b51 | 2016-03-29 12:01:48 -0500 | [diff] [blame^] | 15 | func Stop(client *gophercloud.ServiceClient, id string) (r gophercloud.ErrResult) { |
Jon Perritt | db0ae14 | 2016-03-13 00:33:41 -0600 | [diff] [blame] | 16 | _, r.Err = client.Post(actionURL(client, id), map[string]interface{}{"os-stop": nil}, nil, nil) |
Jamie Hannaford | 583e23d | 2014-11-13 13:22:29 +0100 | [diff] [blame] | 17 | } |