blob: 27638327cec418b15d67c0b8eacb345abf1793ec [file] [log] [blame]
Jamie Hannaford583e23d2014-11-13 13:22:29 +01001package startstop
2
3import (
4 "github.com/racker/perigee"
5 "github.com/rackspace/gophercloud"
6)
7
8func actionURL(client *gophercloud.ServiceClient, id string) string {
9 return client.ServiceURL("servers", id, "action")
10}
11
12func 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
26func 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}