Samuel A. Falvo II | c007c27 | 2014-02-10 20:49:26 -0800 | [diff] [blame] | 1 | package servers |
| 2 | |
| 3 | import ( |
Samuel A. Falvo II | 41c9f61 | 2014-03-11 19:00:10 -0700 | [diff] [blame] | 4 | "fmt" |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 5 | |
Jon Perritt | 3055864 | 2014-04-14 17:07:12 -0500 | [diff] [blame] | 6 | "github.com/racker/perigee" |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 7 | "github.com/rackspace/gophercloud" |
| 8 | "github.com/rackspace/gophercloud/pagination" |
Samuel A. Falvo II | c007c27 | 2014-02-10 20:49:26 -0800 | [diff] [blame] | 9 | ) |
| 10 | |
Ash Wilson | fd04379 | 2014-09-17 10:40:17 -0400 | [diff] [blame] | 11 | // ListPage abstracts the raw results of making a List() request against the API. |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 12 | // As OpenStack extensions may freely alter the response bodies of structures returned to the client, you may only safely access the |
| 13 | // data provided through the ExtractServers call. |
Ash Wilson | fd04379 | 2014-09-17 10:40:17 -0400 | [diff] [blame] | 14 | type ListPage struct { |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 15 | pagination.MarkerPageBase |
| 16 | } |
Samuel A. Falvo II | c007c27 | 2014-02-10 20:49:26 -0800 | [diff] [blame] | 17 | |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 18 | // IsEmpty returns true if a page contains no Server results. |
Ash Wilson | fd04379 | 2014-09-17 10:40:17 -0400 | [diff] [blame] | 19 | func (page ListPage) IsEmpty() (bool, error) { |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 20 | servers, err := ExtractServers(page) |
| 21 | if err != nil { |
| 22 | return true, err |
| 23 | } |
| 24 | return len(servers) == 0, nil |
| 25 | } |
| 26 | |
| 27 | // LastMarker returns the ID of the final server on the current page. |
Ash Wilson | fd04379 | 2014-09-17 10:40:17 -0400 | [diff] [blame] | 28 | func (page ListPage) LastMarker() (string, error) { |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 29 | servers, err := ExtractServers(page) |
| 30 | if err != nil { |
| 31 | return "", err |
| 32 | } |
| 33 | if len(servers) == 0 { |
| 34 | return "", nil |
| 35 | } |
| 36 | return servers[len(servers)-1].ID, nil |
| 37 | } |
| 38 | |
| 39 | // ServerResult abstracts a single server description, as returned by the OpenStack provider. |
| 40 | // As OpenStack extensions may freely alter the response bodies of the structures returned to the client, |
| 41 | // you may only safely access the data provided through separate, type-safe accessors or methods. |
Samuel A. Falvo II | ce00073 | 2014-02-13 18:53:53 -0800 | [diff] [blame] | 42 | type ServerResult map[string]interface{} |
| 43 | |
Samuel A. Falvo II | c007c27 | 2014-02-10 20:49:26 -0800 | [diff] [blame] | 44 | // List makes a request against the API to list servers accessible to you. |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 45 | func List(client *gophercloud.ServiceClient) pagination.Pager { |
| 46 | createPage := func(r pagination.LastHTTPResponse) pagination.Page { |
Ash Wilson | fd04379 | 2014-09-17 10:40:17 -0400 | [diff] [blame] | 47 | p := ListPage{pagination.MarkerPageBase{LastHTTPResponse: r}} |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 48 | p.MarkerPageBase.Owner = p |
| 49 | return p |
Samuel A. Falvo II | c007c27 | 2014-02-10 20:49:26 -0800 | [diff] [blame] | 50 | } |
| 51 | |
Ash Wilson | dc7daa8 | 2014-09-23 16:34:42 -0400 | [diff] [blame] | 52 | return pagination.NewPager(client, getDetailURL(client), createPage) |
Samuel A. Falvo II | c007c27 | 2014-02-10 20:49:26 -0800 | [diff] [blame] | 53 | } |
| 54 | |
Samuel A. Falvo II | ce00073 | 2014-02-13 18:53:53 -0800 | [diff] [blame] | 55 | // Create requests a server to be provisioned to the user in the current tenant. |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 56 | func Create(client *gophercloud.ServiceClient, opts map[string]interface{}) (ServerResult, error) { |
Samuel A. Falvo II | ce00073 | 2014-02-13 18:53:53 -0800 | [diff] [blame] | 57 | var sr ServerResult |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 58 | _, err := perigee.Request("POST", getListURL(client), perigee.Options{ |
Samuel A. Falvo II | ce00073 | 2014-02-13 18:53:53 -0800 | [diff] [blame] | 59 | Results: &sr, |
Samuel A. Falvo II | e246ac0 | 2014-02-13 23:20:09 -0800 | [diff] [blame] | 60 | ReqBody: map[string]interface{}{ |
Samuel A. Falvo II | ce00073 | 2014-02-13 18:53:53 -0800 | [diff] [blame] | 61 | "server": opts, |
| 62 | }, |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 63 | MoreHeaders: client.Provider.AuthenticatedHeaders(), |
Samuel A. Falvo II | e246ac0 | 2014-02-13 23:20:09 -0800 | [diff] [blame] | 64 | OkCodes: []int{202}, |
Samuel A. Falvo II | ce00073 | 2014-02-13 18:53:53 -0800 | [diff] [blame] | 65 | }) |
| 66 | return sr, err |
| 67 | } |
| 68 | |
| 69 | // Delete requests that a server previously provisioned be removed from your account. |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 70 | func Delete(client *gophercloud.ServiceClient, id string) error { |
| 71 | _, err := perigee.Request("DELETE", getServerURL(client, id), perigee.Options{ |
| 72 | MoreHeaders: client.Provider.AuthenticatedHeaders(), |
Samuel A. Falvo II | e246ac0 | 2014-02-13 23:20:09 -0800 | [diff] [blame] | 73 | OkCodes: []int{204}, |
Samuel A. Falvo II | ce00073 | 2014-02-13 18:53:53 -0800 | [diff] [blame] | 74 | }) |
| 75 | return err |
| 76 | } |
| 77 | |
Ash Wilson | 7ddf036 | 2014-09-17 10:59:09 -0400 | [diff] [blame] | 78 | // Get requests details on a single server, by ID. |
| 79 | func Get(client *gophercloud.ServiceClient, id string) (ServerResult, error) { |
Samuel A. Falvo II | ce00073 | 2014-02-13 18:53:53 -0800 | [diff] [blame] | 80 | var sr ServerResult |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 81 | _, err := perigee.Request("GET", getServerURL(client, id), perigee.Options{ |
Samuel A. Falvo II | e246ac0 | 2014-02-13 23:20:09 -0800 | [diff] [blame] | 82 | Results: &sr, |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 83 | MoreHeaders: client.Provider.AuthenticatedHeaders(), |
Samuel A. Falvo II | ce00073 | 2014-02-13 18:53:53 -0800 | [diff] [blame] | 84 | }) |
| 85 | return sr, err |
| 86 | } |
| 87 | |
Samuel A. Falvo II | 22d3b77 | 2014-02-13 19:27:05 -0800 | [diff] [blame] | 88 | // Update requests that various attributes of the indicated server be changed. |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 89 | func Update(client *gophercloud.ServiceClient, id string, opts map[string]interface{}) (ServerResult, error) { |
Samuel A. Falvo II | 22d3b77 | 2014-02-13 19:27:05 -0800 | [diff] [blame] | 90 | var sr ServerResult |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 91 | _, err := perigee.Request("PUT", getServerURL(client, id), perigee.Options{ |
Samuel A. Falvo II | 22d3b77 | 2014-02-13 19:27:05 -0800 | [diff] [blame] | 92 | Results: &sr, |
| 93 | ReqBody: map[string]interface{}{ |
| 94 | "server": opts, |
| 95 | }, |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 96 | MoreHeaders: client.Provider.AuthenticatedHeaders(), |
Samuel A. Falvo II | 22d3b77 | 2014-02-13 19:27:05 -0800 | [diff] [blame] | 97 | }) |
| 98 | return sr, err |
| 99 | } |
Samuel A. Falvo II | ca5f9a3 | 2014-03-11 17:52:58 -0700 | [diff] [blame] | 100 | |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 101 | // ChangeAdminPassword alters the administrator or root password for a specified server. |
| 102 | func ChangeAdminPassword(client *gophercloud.ServiceClient, id, newPassword string) error { |
Ash Wilson | dc7daa8 | 2014-09-23 16:34:42 -0400 | [diff] [blame] | 103 | var req struct { |
| 104 | ChangePassword struct { |
| 105 | AdminPass string `json:"adminPass"` |
| 106 | } `json:"changePassword"` |
| 107 | } |
| 108 | |
| 109 | req.ChangePassword.AdminPass = newPassword |
| 110 | |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 111 | _, err := perigee.Request("POST", getActionURL(client, id), perigee.Options{ |
Ash Wilson | dc7daa8 | 2014-09-23 16:34:42 -0400 | [diff] [blame] | 112 | ReqBody: req, |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 113 | MoreHeaders: client.Provider.AuthenticatedHeaders(), |
Jon Perritt | 3055864 | 2014-04-14 17:07:12 -0500 | [diff] [blame] | 114 | OkCodes: []int{202}, |
Samuel A. Falvo II | ca5f9a3 | 2014-03-11 17:52:58 -0700 | [diff] [blame] | 115 | }) |
| 116 | return err |
| 117 | } |
Samuel A. Falvo II | 41c9f61 | 2014-03-11 19:00:10 -0700 | [diff] [blame] | 118 | |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 119 | // ErrArgument errors occur when an argument supplied to a package function |
Samuel A. Falvo II | 41c9f61 | 2014-03-11 19:00:10 -0700 | [diff] [blame] | 120 | // fails to fall within acceptable values. For example, the Reboot() function |
| 121 | // expects the "how" parameter to be one of HardReboot or SoftReboot. These |
| 122 | // constants are (currently) strings, leading someone to wonder if they can pass |
| 123 | // other string values instead, perhaps in an effort to break the API of their |
| 124 | // provider. Reboot() returns this error in this situation. |
| 125 | // |
| 126 | // Function identifies which function was called/which function is generating |
| 127 | // the error. |
| 128 | // Argument identifies which formal argument was responsible for producing the |
| 129 | // error. |
| 130 | // Value provides the value as it was passed into the function. |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 131 | type ErrArgument struct { |
Samuel A. Falvo II | 41c9f61 | 2014-03-11 19:00:10 -0700 | [diff] [blame] | 132 | Function, Argument string |
Jon Perritt | 3055864 | 2014-04-14 17:07:12 -0500 | [diff] [blame] | 133 | Value interface{} |
Samuel A. Falvo II | 41c9f61 | 2014-03-11 19:00:10 -0700 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | // Error yields a useful diagnostic for debugging purposes. |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 137 | func (e *ErrArgument) Error() string { |
Samuel A. Falvo II | 41c9f61 | 2014-03-11 19:00:10 -0700 | [diff] [blame] | 138 | return fmt.Sprintf("Bad argument in call to %s, formal parameter %s, value %#v", e.Function, e.Argument, e.Value) |
| 139 | } |
| 140 | |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 141 | func (e *ErrArgument) String() string { |
Samuel A. Falvo II | 41c9f61 | 2014-03-11 19:00:10 -0700 | [diff] [blame] | 142 | return e.Error() |
| 143 | } |
| 144 | |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 145 | // RebootMethod describes the mechanisms by which a server reboot can be requested. |
| 146 | type RebootMethod string |
| 147 | |
Samuel A. Falvo II | 41c9f61 | 2014-03-11 19:00:10 -0700 | [diff] [blame] | 148 | // These constants determine how a server should be rebooted. |
| 149 | // See the Reboot() function for further details. |
| 150 | const ( |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 151 | SoftReboot RebootMethod = "SOFT" |
| 152 | HardReboot RebootMethod = "HARD" |
| 153 | OSReboot = SoftReboot |
| 154 | PowerCycle = HardReboot |
Samuel A. Falvo II | 41c9f61 | 2014-03-11 19:00:10 -0700 | [diff] [blame] | 155 | ) |
| 156 | |
| 157 | // Reboot requests that a given server reboot. |
| 158 | // Two methods exist for rebooting a server: |
| 159 | // |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 160 | // HardReboot (aka PowerCycle) restarts the server instance by physically cutting power to the machine, or if a VM, |
| 161 | // terminating it at the hypervisor level. |
| 162 | // It's done. Caput. Full stop. |
| 163 | // Then, after a brief while, power is restored or the VM instance restarted. |
Samuel A. Falvo II | 41c9f61 | 2014-03-11 19:00:10 -0700 | [diff] [blame] | 164 | // |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 165 | // SoftReboot (aka OSReboot) simply tells the OS to restart under its own procedures. |
| 166 | // E.g., in Linux, asking it to enter runlevel 6, or executing "sudo shutdown -r now", or by asking Windows to restart the machine. |
| 167 | func Reboot(client *gophercloud.ServiceClient, id string, how RebootMethod) error { |
Samuel A. Falvo II | 41c9f61 | 2014-03-11 19:00:10 -0700 | [diff] [blame] | 168 | if (how != SoftReboot) && (how != HardReboot) { |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 169 | return &ErrArgument{ |
Samuel A. Falvo II | 41c9f61 | 2014-03-11 19:00:10 -0700 | [diff] [blame] | 170 | Function: "Reboot", |
| 171 | Argument: "how", |
Jon Perritt | 3055864 | 2014-04-14 17:07:12 -0500 | [diff] [blame] | 172 | Value: how, |
Samuel A. Falvo II | 41c9f61 | 2014-03-11 19:00:10 -0700 | [diff] [blame] | 173 | } |
| 174 | } |
Jon Perritt | 3055864 | 2014-04-14 17:07:12 -0500 | [diff] [blame] | 175 | |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 176 | _, err := perigee.Request("POST", getActionURL(client, id), perigee.Options{ |
Jon Perritt | 3055864 | 2014-04-14 17:07:12 -0500 | [diff] [blame] | 177 | ReqBody: struct { |
| 178 | C map[string]string `json:"reboot"` |
| 179 | }{ |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 180 | map[string]string{"type": string(how)}, |
Samuel A. Falvo II | 41c9f61 | 2014-03-11 19:00:10 -0700 | [diff] [blame] | 181 | }, |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 182 | MoreHeaders: client.Provider.AuthenticatedHeaders(), |
Jon Perritt | 3055864 | 2014-04-14 17:07:12 -0500 | [diff] [blame] | 183 | OkCodes: []int{202}, |
Samuel A. Falvo II | 41c9f61 | 2014-03-11 19:00:10 -0700 | [diff] [blame] | 184 | }) |
| 185 | return err |
| 186 | } |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 187 | |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 188 | // Rebuild requests that the Openstack provider reprovision the server. |
| 189 | // The rebuild will need to know the server's name and new image reference or ID. |
| 190 | // In addition, and unlike building a server with Create(), you must provide an administrator password. |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 191 | // |
| 192 | // Additional options may be specified with the additional map. |
| 193 | // This function treats a nil map the same as an empty map. |
| 194 | // |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 195 | // Rebuild returns a server result as though you had called GetDetail() on the server's ID. |
| 196 | // The information, however, refers to the new server, not the old. |
| 197 | func Rebuild(client *gophercloud.ServiceClient, id, name, password, imageRef string, additional map[string]interface{}) (ServerResult, error) { |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 198 | var sr ServerResult |
| 199 | |
| 200 | if id == "" { |
| 201 | return sr, &ErrArgument{ |
| 202 | Function: "Rebuild", |
| 203 | Argument: "id", |
Jon Perritt | 3055864 | 2014-04-14 17:07:12 -0500 | [diff] [blame] | 204 | Value: "", |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 205 | } |
| 206 | } |
| 207 | |
| 208 | if name == "" { |
| 209 | return sr, &ErrArgument{ |
| 210 | Function: "Rebuild", |
| 211 | Argument: "name", |
Jon Perritt | 3055864 | 2014-04-14 17:07:12 -0500 | [diff] [blame] | 212 | Value: "", |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 213 | } |
| 214 | } |
| 215 | |
| 216 | if password == "" { |
| 217 | return sr, &ErrArgument{ |
| 218 | Function: "Rebuild", |
| 219 | Argument: "password", |
Jon Perritt | 3055864 | 2014-04-14 17:07:12 -0500 | [diff] [blame] | 220 | Value: "", |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 221 | } |
| 222 | } |
| 223 | |
| 224 | if imageRef == "" { |
| 225 | return sr, &ErrArgument{ |
| 226 | Function: "Rebuild", |
| 227 | Argument: "imageRef", |
Jon Perritt | 3055864 | 2014-04-14 17:07:12 -0500 | [diff] [blame] | 228 | Value: "", |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 229 | } |
| 230 | } |
| 231 | |
| 232 | if additional == nil { |
| 233 | additional = make(map[string]interface{}, 0) |
| 234 | } |
| 235 | |
| 236 | additional["name"] = name |
| 237 | additional["imageRef"] = imageRef |
| 238 | additional["adminPass"] = password |
| 239 | |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 240 | _, err := perigee.Request("POST", getActionURL(client, id), perigee.Options{ |
Jon Perritt | 3055864 | 2014-04-14 17:07:12 -0500 | [diff] [blame] | 241 | ReqBody: struct { |
| 242 | R map[string]interface{} `json:"rebuild"` |
| 243 | }{ |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 244 | additional, |
| 245 | }, |
Jon Perritt | 3055864 | 2014-04-14 17:07:12 -0500 | [diff] [blame] | 246 | Results: &sr, |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 247 | MoreHeaders: client.Provider.AuthenticatedHeaders(), |
Jon Perritt | 3055864 | 2014-04-14 17:07:12 -0500 | [diff] [blame] | 248 | OkCodes: []int{202}, |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 249 | }) |
| 250 | return sr, err |
| 251 | } |
| 252 | |
| 253 | // Resize instructs the provider to change the flavor of the server. |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 254 | // Note that this implies rebuilding it. |
| 255 | // Unfortunately, one cannot pass rebuild parameters to the resize function. |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 256 | // When the resize completes, the server will be in RESIZE_VERIFY state. |
| 257 | // While in this state, you can explore the use of the new server's configuration. |
| 258 | // If you like it, call ConfirmResize() to commit the resize permanently. |
| 259 | // Otherwise, call RevertResize() to restore the old configuration. |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 260 | func Resize(client *gophercloud.ServiceClient, id, flavorRef string) error { |
| 261 | _, err := perigee.Request("POST", getActionURL(client, id), perigee.Options{ |
Jon Perritt | 3055864 | 2014-04-14 17:07:12 -0500 | [diff] [blame] | 262 | ReqBody: struct { |
| 263 | R map[string]interface{} `json:"resize"` |
| 264 | }{ |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 265 | map[string]interface{}{"flavorRef": flavorRef}, |
| 266 | }, |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 267 | MoreHeaders: client.Provider.AuthenticatedHeaders(), |
Jon Perritt | 3055864 | 2014-04-14 17:07:12 -0500 | [diff] [blame] | 268 | OkCodes: []int{202}, |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 269 | }) |
| 270 | return err |
| 271 | } |
| 272 | |
| 273 | // ConfirmResize confirms a previous resize operation on a server. |
| 274 | // See Resize() for more details. |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 275 | func ConfirmResize(client *gophercloud.ServiceClient, id string) error { |
| 276 | _, err := perigee.Request("POST", getActionURL(client, id), perigee.Options{ |
Jon Perritt | 3055864 | 2014-04-14 17:07:12 -0500 | [diff] [blame] | 277 | ReqBody: map[string]interface{}{"confirmResize": nil}, |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 278 | MoreHeaders: client.Provider.AuthenticatedHeaders(), |
Jon Perritt | 3055864 | 2014-04-14 17:07:12 -0500 | [diff] [blame] | 279 | OkCodes: []int{204}, |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 280 | }) |
| 281 | return err |
| 282 | } |
| 283 | |
| 284 | // RevertResize cancels a previous resize operation on a server. |
| 285 | // See Resize() for more details. |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 286 | func RevertResize(client *gophercloud.ServiceClient, id string) error { |
| 287 | _, err := perigee.Request("POST", getActionURL(client, id), perigee.Options{ |
Jon Perritt | 3055864 | 2014-04-14 17:07:12 -0500 | [diff] [blame] | 288 | ReqBody: map[string]interface{}{"revertResize": nil}, |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame] | 289 | MoreHeaders: client.Provider.AuthenticatedHeaders(), |
Jon Perritt | 3055864 | 2014-04-14 17:07:12 -0500 | [diff] [blame] | 290 | OkCodes: []int{202}, |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 291 | }) |
| 292 | return err |
| 293 | } |