Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add support for deleting nova service #2427

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions 7 openstack/compute/v2/extensions/services/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ Example of updating a service
if err != nil {
panic(err)
}

Example of delete a service

updated, err := services.Delete(client, serviceID).Extract()
if err != nil {
panic(err)
}
*/

package services
9 changes: 9 additions & 0 deletions 9 openstack/compute/v2/extensions/services/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,12 @@ func Update(client *gophercloud.ServiceClient, id string, opts UpdateOpts) (r Up
_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
return
}

// Delete will delete the existing service with the provided ID.
func Delete(client *gophercloud.ServiceClient, id string) (r DeleteResult) {
resp, err := client.Delete(updateURL(client, id), &gophercloud.RequestOpts{
OkCodes: []int{204},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

})
_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
return
}
6 changes: 6 additions & 0 deletions 6 openstack/compute/v2/extensions/services/results.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,9 @@ func ExtractServices(r pagination.Page) ([]Service, error) {
err := (r.(ServicePage)).ExtractInto(&s)
return s.Service, err
}

// DeleteResult is the response from a Delete operation. Call its ExtractErr
// method to determine if the call succeeded or failed.
type DeleteResult struct {
gophercloud.ErrResult
}
10 changes: 10 additions & 0 deletions 10 openstack/compute/v2/extensions/services/testing/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,3 +288,13 @@ func HandleUpdateSuccessfully(t *testing.T) {
fmt.Fprintf(w, ServiceUpdate)
})
}

// HandleDeleteSuccessfully configures the test server to respond to a Delete
// request to a Compute server with Pike+ release.
func HandleDeleteSuccessfully(t *testing.T) {
th.Mux.HandleFunc("/os-services/fake-service-id", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "DELETE")
th.TestHeader(t, r, "X-Auth-Token", client.TokenID)
w.WriteHeader(http.StatusNoContent)
})
}
11 changes: 11 additions & 0 deletions 11 openstack/compute/v2/extensions/services/testing/requests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,14 @@ func TestUpdateService(t *testing.T) {

testhelper.CheckDeepEquals(t, FakeServiceUpdateBody, *actual)
}

func TestDeleteService(t *testing.T) {
testhelper.SetupHTTP()
defer testhelper.TeardownHTTP()
HandleDeleteSuccessfully(t)

client := client.ServiceClient()
res := services.Delete(client, "fake-service-id")

testhelper.AssertNoErr(t, res.Err)
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.