Jamie Hannaford | 583e23d | 2014-11-13 13:22:29 +0100 | [diff] [blame^] | 1 | package startstop |
| 2 | |
| 3 | import ( |
| 4 | "github.com/racker/perigee" |
| 5 | "github.com/rackspace/gophercloud" |
| 6 | ) |
| 7 | |
| 8 | func actionURL(client *gophercloud.ServiceClient, id string) string { |
| 9 | return client.ServiceURL("servers", id, "action") |
| 10 | } |
| 11 | |
| 12 | func Start(client *gophercloud.ServiceClient, id string) gophercloud.ErrResult { |
| 13 | var res gophercloud.ErrResult |
| 14 | |
| 15 | reqBody := map[string](*interface{}){"os-start": nil} |
| 16 | |
| 17 | _, res.Err = perigee.Request("POST", actionURL(client, id), perigee.Options{ |
| 18 | MoreHeaders: client.AuthenticatedHeaders(), |
| 19 | ReqBody: reqBody, |
| 20 | OkCodes: []int{202}, |
| 21 | }) |
| 22 | |
| 23 | return res |
| 24 | } |
| 25 | |
| 26 | func Stop(client *gophercloud.ServiceClient, id string) gophercloud.ErrResult { |
| 27 | var res gophercloud.ErrResult |
| 28 | |
| 29 | reqBody := map[string](*interface{}){"os-stop": nil} |
| 30 | |
| 31 | _, res.Err = perigee.Request("POST", actionURL(client, id), perigee.Options{ |
| 32 | MoreHeaders: client.AuthenticatedHeaders(), |
| 33 | ReqBody: reqBody, |
| 34 | OkCodes: []int{202}, |
| 35 | }) |
| 36 | |
| 37 | return res |
| 38 | } |