Add support for forced delete
Signed-off-by: Ian Duffy <ian.x.duffy@aib.ie>
diff --git a/openstack/compute/v2/servers/fixtures.go b/openstack/compute/v2/servers/fixtures.go
index 4339a16..151fea2 100644
--- a/openstack/compute/v2/servers/fixtures.go
+++ b/openstack/compute/v2/servers/fixtures.go
@@ -399,6 +399,18 @@
})
}
+// HandleAdminPasswordChangeSuccessfully sets up the test server to respond to a server password
+// change request.
+func HandleServerForceDeletionSuccessfully(t *testing.T) {
+ th.Mux.HandleFunc("/servers/asdfasdfasdf/action", func(w http.ResponseWriter, r *http.Request) {
+ th.TestMethod(t, r, "POST")
+ th.TestHeader(t, r, "X-Auth-Token", client.TokenID)
+ th.TestJSONRequest(t, r, `{ "forceDelete": "" }`)
+
+ w.WriteHeader(http.StatusAccepted)
+ })
+}
+
// HandleServerGetSuccessfully sets up the test server to respond to a server Get request.
func HandleServerGetSuccessfully(t *testing.T) {
th.Mux.HandleFunc("/servers/1234asdf", func(w http.ResponseWriter, r *http.Request) {
diff --git a/openstack/compute/v2/servers/requests.go b/openstack/compute/v2/servers/requests.go
index f9839d9..8e60daa 100644
--- a/openstack/compute/v2/servers/requests.go
+++ b/openstack/compute/v2/servers/requests.go
@@ -303,6 +303,17 @@
return res
}
+func ForceDelete(client *gophercloud.ServiceClient, id string) ActionResult {
+ var req struct {
+ ForceDelete string `json:"forceDelete"`
+ }
+
+ var res ActionResult
+ _, res.Err = client.Post(actionURL(client, id), req, nil, nil)
+ return res
+
+}
+
// Get requests details on a single server, by ID.
func Get(client *gophercloud.ServiceClient, id string) GetResult {
var result GetResult
diff --git a/openstack/compute/v2/servers/requests_test.go b/openstack/compute/v2/servers/requests_test.go
index 88cb54d..e042074 100644
--- a/openstack/compute/v2/servers/requests_test.go
+++ b/openstack/compute/v2/servers/requests_test.go
@@ -78,6 +78,15 @@
th.AssertNoErr(t, res.Err)
}
+func TestForceDeleteServer(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+ HandleServerForceDeletionSuccessfully(t)
+
+ res := ForceDelete(client.ServiceClient(), "asdfasdfasdf")
+ th.AssertNoErr(t, res.Err)
+}
+
func TestGetServer(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()