Skip to content
This repository has been archived by the owner on Aug 1, 2023. It is now read-only.

Add ResetState for compute instances #555

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions openstack/compute/v2/servers/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down