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 | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame^] | 11 | // ListResult abstracts the raw results of making a List() request against the API. |
| 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. |
| 14 | type ListResult struct { |
| 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. |
| 19 | func (page ListResult) IsEmpty() (bool, error) { |
| 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. |
| 28 | func (page ListResult) LastMarker() (string, error) { |
| 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 { |
| 47 | p := ListResult{pagination.MarkerPageBase{LastHTTPResponse: r}} |
| 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 | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame^] | 52 | return pagination.NewPager(client, getListURL(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 | |
| 78 | // GetDetail requests details on a single server, by ID. |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame^] | 79 | func GetDetail(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 { |
| 103 | _, err := perigee.Request("POST", getActionURL(client, id), perigee.Options{ |
Jon Perritt | 3055864 | 2014-04-14 17:07:12 -0500 | [diff] [blame] | 104 | ReqBody: struct { |
| 105 | C map[string]string `json:"changePassword"` |
| 106 | }{ |
Samuel A. Falvo II | ca5f9a3 | 2014-03-11 17:52:58 -0700 | [diff] [blame] | 107 | map[string]string{"adminPass": newPassword}, |
| 108 | }, |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame^] | 109 | MoreHeaders: client.Provider.AuthenticatedHeaders(), |
Jon Perritt | 3055864 | 2014-04-14 17:07:12 -0500 | [diff] [blame] | 110 | OkCodes: []int{202}, |
Samuel A. Falvo II | ca5f9a3 | 2014-03-11 17:52:58 -0700 | [diff] [blame] | 111 | }) |
| 112 | return err |
| 113 | } |
Samuel A. Falvo II | 41c9f61 | 2014-03-11 19:00:10 -0700 | [diff] [blame] | 114 | |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 115 | // 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] | 116 | // fails to fall within acceptable values. For example, the Reboot() function |
| 117 | // expects the "how" parameter to be one of HardReboot or SoftReboot. These |
| 118 | // constants are (currently) strings, leading someone to wonder if they can pass |
| 119 | // other string values instead, perhaps in an effort to break the API of their |
| 120 | // provider. Reboot() returns this error in this situation. |
| 121 | // |
| 122 | // Function identifies which function was called/which function is generating |
| 123 | // the error. |
| 124 | // Argument identifies which formal argument was responsible for producing the |
| 125 | // error. |
| 126 | // 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] | 127 | type ErrArgument struct { |
Samuel A. Falvo II | 41c9f61 | 2014-03-11 19:00:10 -0700 | [diff] [blame] | 128 | Function, Argument string |
Jon Perritt | 3055864 | 2014-04-14 17:07:12 -0500 | [diff] [blame] | 129 | Value interface{} |
Samuel A. Falvo II | 41c9f61 | 2014-03-11 19:00:10 -0700 | [diff] [blame] | 130 | } |
| 131 | |
| 132 | // Error yields a useful diagnostic for debugging purposes. |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 133 | func (e *ErrArgument) Error() string { |
Samuel A. Falvo II | 41c9f61 | 2014-03-11 19:00:10 -0700 | [diff] [blame] | 134 | return fmt.Sprintf("Bad argument in call to %s, formal parameter %s, value %#v", e.Function, e.Argument, e.Value) |
| 135 | } |
| 136 | |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 137 | func (e *ErrArgument) String() string { |
Samuel A. Falvo II | 41c9f61 | 2014-03-11 19:00:10 -0700 | [diff] [blame] | 138 | return e.Error() |
| 139 | } |
| 140 | |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame^] | 141 | // RebootMethod describes the mechanisms by which a server reboot can be requested. |
| 142 | type RebootMethod string |
| 143 | |
Samuel A. Falvo II | 41c9f61 | 2014-03-11 19:00:10 -0700 | [diff] [blame] | 144 | // These constants determine how a server should be rebooted. |
| 145 | // See the Reboot() function for further details. |
| 146 | const ( |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame^] | 147 | SoftReboot RebootMethod = "SOFT" |
| 148 | HardReboot RebootMethod = "HARD" |
| 149 | OSReboot = SoftReboot |
| 150 | PowerCycle = HardReboot |
Samuel A. Falvo II | 41c9f61 | 2014-03-11 19:00:10 -0700 | [diff] [blame] | 151 | ) |
| 152 | |
| 153 | // Reboot requests that a given server reboot. |
| 154 | // Two methods exist for rebooting a server: |
| 155 | // |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame^] | 156 | // HardReboot (aka PowerCycle) restarts the server instance by physically cutting power to the machine, or if a VM, |
| 157 | // terminating it at the hypervisor level. |
| 158 | // It's done. Caput. Full stop. |
| 159 | // 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] | 160 | // |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame^] | 161 | // SoftReboot (aka OSReboot) simply tells the OS to restart under its own procedures. |
| 162 | // E.g., in Linux, asking it to enter runlevel 6, or executing "sudo shutdown -r now", or by asking Windows to restart the machine. |
| 163 | func Reboot(client *gophercloud.ServiceClient, id string, how RebootMethod) error { |
Samuel A. Falvo II | 41c9f61 | 2014-03-11 19:00:10 -0700 | [diff] [blame] | 164 | if (how != SoftReboot) && (how != HardReboot) { |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 165 | return &ErrArgument{ |
Samuel A. Falvo II | 41c9f61 | 2014-03-11 19:00:10 -0700 | [diff] [blame] | 166 | Function: "Reboot", |
| 167 | Argument: "how", |
Jon Perritt | 3055864 | 2014-04-14 17:07:12 -0500 | [diff] [blame] | 168 | Value: how, |
Samuel A. Falvo II | 41c9f61 | 2014-03-11 19:00:10 -0700 | [diff] [blame] | 169 | } |
| 170 | } |
Jon Perritt | 3055864 | 2014-04-14 17:07:12 -0500 | [diff] [blame] | 171 | |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame^] | 172 | _, err := perigee.Request("POST", getActionURL(client, id), perigee.Options{ |
Jon Perritt | 3055864 | 2014-04-14 17:07:12 -0500 | [diff] [blame] | 173 | ReqBody: struct { |
| 174 | C map[string]string `json:"reboot"` |
| 175 | }{ |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame^] | 176 | map[string]string{"type": string(how)}, |
Samuel A. Falvo II | 41c9f61 | 2014-03-11 19:00:10 -0700 | [diff] [blame] | 177 | }, |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame^] | 178 | MoreHeaders: client.Provider.AuthenticatedHeaders(), |
Jon Perritt | 3055864 | 2014-04-14 17:07:12 -0500 | [diff] [blame] | 179 | OkCodes: []int{202}, |
Samuel A. Falvo II | 41c9f61 | 2014-03-11 19:00:10 -0700 | [diff] [blame] | 180 | }) |
| 181 | return err |
| 182 | } |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 183 | |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame^] | 184 | // Rebuild requests that the Openstack provider reprovision the server. |
| 185 | // The rebuild will need to know the server's name and new image reference or ID. |
| 186 | // 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] | 187 | // |
| 188 | // Additional options may be specified with the additional map. |
| 189 | // This function treats a nil map the same as an empty map. |
| 190 | // |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame^] | 191 | // Rebuild returns a server result as though you had called GetDetail() on the server's ID. |
| 192 | // The information, however, refers to the new server, not the old. |
| 193 | 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] | 194 | var sr ServerResult |
| 195 | |
| 196 | if id == "" { |
| 197 | return sr, &ErrArgument{ |
| 198 | Function: "Rebuild", |
| 199 | Argument: "id", |
Jon Perritt | 3055864 | 2014-04-14 17:07:12 -0500 | [diff] [blame] | 200 | Value: "", |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 201 | } |
| 202 | } |
| 203 | |
| 204 | if name == "" { |
| 205 | return sr, &ErrArgument{ |
| 206 | Function: "Rebuild", |
| 207 | Argument: "name", |
Jon Perritt | 3055864 | 2014-04-14 17:07:12 -0500 | [diff] [blame] | 208 | Value: "", |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 209 | } |
| 210 | } |
| 211 | |
| 212 | if password == "" { |
| 213 | return sr, &ErrArgument{ |
| 214 | Function: "Rebuild", |
| 215 | Argument: "password", |
Jon Perritt | 3055864 | 2014-04-14 17:07:12 -0500 | [diff] [blame] | 216 | Value: "", |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 217 | } |
| 218 | } |
| 219 | |
| 220 | if imageRef == "" { |
| 221 | return sr, &ErrArgument{ |
| 222 | Function: "Rebuild", |
| 223 | Argument: "imageRef", |
Jon Perritt | 3055864 | 2014-04-14 17:07:12 -0500 | [diff] [blame] | 224 | Value: "", |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 225 | } |
| 226 | } |
| 227 | |
| 228 | if additional == nil { |
| 229 | additional = make(map[string]interface{}, 0) |
| 230 | } |
| 231 | |
| 232 | additional["name"] = name |
| 233 | additional["imageRef"] = imageRef |
| 234 | additional["adminPass"] = password |
| 235 | |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame^] | 236 | _, err := perigee.Request("POST", getActionURL(client, id), perigee.Options{ |
Jon Perritt | 3055864 | 2014-04-14 17:07:12 -0500 | [diff] [blame] | 237 | ReqBody: struct { |
| 238 | R map[string]interface{} `json:"rebuild"` |
| 239 | }{ |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 240 | additional, |
| 241 | }, |
Jon Perritt | 3055864 | 2014-04-14 17:07:12 -0500 | [diff] [blame] | 242 | Results: &sr, |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame^] | 243 | MoreHeaders: client.Provider.AuthenticatedHeaders(), |
Jon Perritt | 3055864 | 2014-04-14 17:07:12 -0500 | [diff] [blame] | 244 | OkCodes: []int{202}, |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 245 | }) |
| 246 | return sr, err |
| 247 | } |
| 248 | |
| 249 | // Resize instructs the provider to change the flavor of the server. |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame^] | 250 | // Note that this implies rebuilding it. |
| 251 | // Unfortunately, one cannot pass rebuild parameters to the resize function. |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 252 | // When the resize completes, the server will be in RESIZE_VERIFY state. |
| 253 | // While in this state, you can explore the use of the new server's configuration. |
| 254 | // If you like it, call ConfirmResize() to commit the resize permanently. |
| 255 | // Otherwise, call RevertResize() to restore the old configuration. |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame^] | 256 | func Resize(client *gophercloud.ServiceClient, id, flavorRef string) error { |
| 257 | _, err := perigee.Request("POST", getActionURL(client, id), perigee.Options{ |
Jon Perritt | 3055864 | 2014-04-14 17:07:12 -0500 | [diff] [blame] | 258 | ReqBody: struct { |
| 259 | R map[string]interface{} `json:"resize"` |
| 260 | }{ |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 261 | map[string]interface{}{"flavorRef": flavorRef}, |
| 262 | }, |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame^] | 263 | MoreHeaders: client.Provider.AuthenticatedHeaders(), |
Jon Perritt | 3055864 | 2014-04-14 17:07:12 -0500 | [diff] [blame] | 264 | OkCodes: []int{202}, |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 265 | }) |
| 266 | return err |
| 267 | } |
| 268 | |
| 269 | // ConfirmResize confirms a previous resize operation on a server. |
| 270 | // See Resize() for more details. |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame^] | 271 | func ConfirmResize(client *gophercloud.ServiceClient, id string) error { |
| 272 | _, err := perigee.Request("POST", getActionURL(client, id), perigee.Options{ |
Jon Perritt | 3055864 | 2014-04-14 17:07:12 -0500 | [diff] [blame] | 273 | ReqBody: map[string]interface{}{"confirmResize": nil}, |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame^] | 274 | MoreHeaders: client.Provider.AuthenticatedHeaders(), |
Jon Perritt | 3055864 | 2014-04-14 17:07:12 -0500 | [diff] [blame] | 275 | OkCodes: []int{204}, |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 276 | }) |
| 277 | return err |
| 278 | } |
| 279 | |
| 280 | // RevertResize cancels a previous resize operation on a server. |
| 281 | // See Resize() for more details. |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame^] | 282 | func RevertResize(client *gophercloud.ServiceClient, id string) error { |
| 283 | _, err := perigee.Request("POST", getActionURL(client, id), perigee.Options{ |
Jon Perritt | 3055864 | 2014-04-14 17:07:12 -0500 | [diff] [blame] | 284 | ReqBody: map[string]interface{}{"revertResize": nil}, |
Ash Wilson | 01626a3 | 2014-09-17 10:38:07 -0400 | [diff] [blame^] | 285 | MoreHeaders: client.Provider.AuthenticatedHeaders(), |
Jon Perritt | 3055864 | 2014-04-14 17:07:12 -0500 | [diff] [blame] | 286 | OkCodes: []int{202}, |
Samuel A. Falvo II | 808bb63 | 2014-03-12 00:07:50 -0700 | [diff] [blame] | 287 | }) |
| 288 | return err |
| 289 | } |