From 211ec39f37423309601f53275c02fb9ffeb9d206 Mon Sep 17 00:00:00 2001 From: Karol Stepniewski Date: Tue, 12 Apr 2016 14:47:50 -0700 Subject: [PATCH] Add ResetState for compute instances ResetState function allows to reset the state of instance to either "error" (default value) "active". --- openstack/compute/v2/servers/requests.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/openstack/compute/v2/servers/requests.go b/openstack/compute/v2/servers/requests.go index e6490539..925682de 100644 --- a/openstack/compute/v2/servers/requests.go +++ b/openstack/compute/v2/servers/requests.go @@ -382,6 +382,24 @@ func ChangeAdminPassword(client *gophercloud.ServiceClient, id, newPassword stri return res } +// ResetState resets the state of instance to a state specified by newState. +// Available newState values are: 'error' (default) or 'active'. +func ResetState(client *gophercloud.ServiceClient, id, newState string) ActionResult { + var req struct { + OSresetState struct { + State string `json:"state"` + } `json:"os-resetState"` + } + if newState == "" { + newState = "error" + } + req.OSresetState.State = newState + + var res ActionResult + _, res.Err = client.Post(actionURL(client, id), req, nil, nil) + return res +} + // ErrArgument errors occur when an argument supplied to a package function // fails to fall within acceptable values. For example, the Reboot() function // expects the "how" parameter to be one of HardReboot or SoftReboot. These