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

Commit eef7ebc

Browse files
committed
Merge pull request #519 from timbyr/deleteallroutes
[rfr] Allow all routes to be removed from a Neutron router
2 parents 0a866d9 + f8f23dd commit eef7ebc

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

openstack/networking/v2/extensions/layer3/routers/requests.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func Update(c *gophercloud.ServiceClient, id string, opts UpdateOpts) UpdateResu
110110
Name *string `json:"name,omitempty"`
111111
AdminStateUp *bool `json:"admin_state_up,omitempty"`
112112
GatewayInfo *GatewayInfo `json:"external_gateway_info,omitempty"`
113-
Routes []Route `json:"routes,omitempty"`
113+
Routes []Route `json:"routes"`
114114
}
115115

116116
type request struct {

openstack/networking/v2/extensions/layer3/routers/requests_test.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,52 @@ func TestUpdate(t *testing.T) {
257257
th.AssertDeepEquals(t, n.Routes, []Route{Route{DestinationCIDR: "40.0.1.0/24", NextHop: "10.1.0.10"}})
258258
}
259259

260+
func TestAllRoutesRemoved(t *testing.T) {
261+
th.SetupHTTP()
262+
defer th.TeardownHTTP()
263+
264+
th.Mux.HandleFunc("/v2.0/routers/4e8e5957-649f-477b-9e5b-f1f75b21c03c", func(w http.ResponseWriter, r *http.Request) {
265+
th.TestMethod(t, r, "PUT")
266+
th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
267+
th.TestHeader(t, r, "Content-Type", "application/json")
268+
th.TestHeader(t, r, "Accept", "application/json")
269+
th.TestJSONRequest(t, r, `
270+
{
271+
"router": {
272+
"routes": []
273+
}
274+
}
275+
`)
276+
277+
w.Header().Add("Content-Type", "application/json")
278+
w.WriteHeader(http.StatusOK)
279+
280+
fmt.Fprintf(w, `
281+
{
282+
"router": {
283+
"status": "ACTIVE",
284+
"external_gateway_info": {
285+
"network_id": "8ca37218-28ff-41cb-9b10-039601ea7e6b"
286+
},
287+
"name": "name",
288+
"admin_state_up": true,
289+
"tenant_id": "6b96ff0cb17a4b859e1e575d221683d3",
290+
"id": "8604a0de-7f6b-409a-a47c-a1cc7bc77b2e",
291+
"routes": []
292+
}
293+
}
294+
`)
295+
})
296+
297+
r := []Route{}
298+
options := UpdateOpts{Routes: r}
299+
300+
n, err := Update(fake.ServiceClient(), "4e8e5957-649f-477b-9e5b-f1f75b21c03c", options).Extract()
301+
th.AssertNoErr(t, err)
302+
303+
th.AssertDeepEquals(t, n.Routes, []Route{})
304+
}
305+
260306
func TestDelete(t *testing.T) {
261307
th.SetupHTTP()
262308
defer th.TeardownHTTP()

0 commit comments

Comments
 (0)