[rfr]Support Extra routes extension in router api
http://developer.openstack.org/api-ref-networking-v2-ext.html#extraroute-ext
diff --git a/openstack/networking/v2/extensions/layer3/routers/requests.go b/openstack/networking/v2/extensions/layer3/routers/requests.go
old mode 100755
new mode 100644
index 077a717..fe70e34
--- a/openstack/networking/v2/extensions/layer3/routers/requests.go
+++ b/openstack/networking/v2/extensions/layer3/routers/requests.go
@@ -97,6 +97,7 @@
Name string
AdminStateUp *bool
GatewayInfo *GatewayInfo
+ Routes []Route
}
// Update allows routers to be updated. You can update the name, administrative
@@ -109,6 +110,7 @@
Name *string `json:"name,omitempty"`
AdminStateUp *bool `json:"admin_state_up,omitempty"`
GatewayInfo *GatewayInfo `json:"external_gateway_info,omitempty"`
+ Routes []Route `json:"routes,omitempty"`
}
type request struct {
@@ -124,6 +126,10 @@
reqBody.Router.GatewayInfo = opts.GatewayInfo
}
+ if opts.Routes != nil {
+ reqBody.Router.Routes = opts.Routes
+ }
+
// Send request to API
var res UpdateResult
_, res.Err = c.Put(resourceURL(c, id), reqBody, &res.Body, &gophercloud.RequestOpts{
diff --git a/openstack/networking/v2/extensions/layer3/routers/requests_test.go b/openstack/networking/v2/extensions/layer3/routers/requests_test.go
old mode 100755
new mode 100644
index c34264d..3db45ff
--- a/openstack/networking/v2/extensions/layer3/routers/requests_test.go
+++ b/openstack/networking/v2/extensions/layer3/routers/requests_test.go
@@ -167,6 +167,12 @@
"external_gateway_info": {
"network_id": "85d76829-6415-48ff-9c63-5c5ca8c61ac6"
},
+ "routes": [
+ {
+ "nexthop": "10.1.0.10",
+ "destination": "40.0.1.0/24"
+ }
+ ],
"name": "router1",
"admin_state_up": true,
"tenant_id": "d6554fe62e2f41efbb6e026fad5c1542",
@@ -185,6 +191,7 @@
th.AssertEquals(t, n.AdminStateUp, true)
th.AssertEquals(t, n.TenantID, "d6554fe62e2f41efbb6e026fad5c1542")
th.AssertEquals(t, n.ID, "a07eea83-7710-4860-931b-5fe220fae533")
+ th.AssertDeepEquals(t, n.Routes, []Route{Route{DestinationCIDR: "40.0.1.0/24", NextHop: "10.1.0.10"}})
}
func TestUpdate(t *testing.T) {
@@ -202,7 +209,13 @@
"name": "new_name",
"external_gateway_info": {
"network_id": "8ca37218-28ff-41cb-9b10-039601ea7e6b"
- }
+ },
+ "routes": [
+ {
+ "nexthop": "10.1.0.10",
+ "destination": "40.0.1.0/24"
+ }
+ ]
}
}
`)
@@ -220,20 +233,28 @@
"name": "new_name",
"admin_state_up": true,
"tenant_id": "6b96ff0cb17a4b859e1e575d221683d3",
- "id": "8604a0de-7f6b-409a-a47c-a1cc7bc77b2e"
+ "id": "8604a0de-7f6b-409a-a47c-a1cc7bc77b2e",
+ "routes": [
+ {
+ "nexthop": "10.1.0.10",
+ "destination": "40.0.1.0/24"
+ }
+ ]
}
}
`)
})
gwi := GatewayInfo{NetworkID: "8ca37218-28ff-41cb-9b10-039601ea7e6b"}
- options := UpdateOpts{Name: "new_name", GatewayInfo: &gwi}
+ r := []Route{Route{DestinationCIDR: "40.0.1.0/24", NextHop: "10.1.0.10"}}
+ options := UpdateOpts{Name: "new_name", GatewayInfo: &gwi, Routes: r}
n, err := Update(fake.ServiceClient(), "4e8e5957-649f-477b-9e5b-f1f75b21c03c", options).Extract()
th.AssertNoErr(t, err)
th.AssertEquals(t, n.Name, "new_name")
th.AssertDeepEquals(t, n.GatewayInfo, GatewayInfo{NetworkID: "8ca37218-28ff-41cb-9b10-039601ea7e6b"})
+ th.AssertDeepEquals(t, n.Routes, []Route{Route{DestinationCIDR: "40.0.1.0/24", NextHop: "10.1.0.10"}})
}
func TestDelete(t *testing.T) {
diff --git a/openstack/networking/v2/extensions/layer3/routers/results.go b/openstack/networking/v2/extensions/layer3/routers/results.go
old mode 100755
new mode 100644
index bdad4cb..5e297ab
--- a/openstack/networking/v2/extensions/layer3/routers/results.go
+++ b/openstack/networking/v2/extensions/layer3/routers/results.go
@@ -12,6 +12,11 @@
NetworkID string `json:"network_id" mapstructure:"network_id"`
}
+type Route struct {
+ NextHop string `mapstructure:"nexthop" json:"nexthop"`
+ DestinationCIDR string `mapstructure:"destination" json:"destination"`
+}
+
// Router represents a Neutron router. A router is a logical entity that
// forwards packets across internal subnets and NATs (network address
// translation) them on external networks through an appropriate gateway.
@@ -39,6 +44,8 @@
// Owner of the router. Only admin users can specify a tenant identifier
// other than its own.
TenantID string `json:"tenant_id" mapstructure:"tenant_id"`
+
+ Routes []Route `json:"routes" mapstructure:"routes"`
}
// RouterPage is the page returned by a pager when traversing over a