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

Commit ff407fa

Browse files
committed
Merge pull request #525 from Fodoj/extend-routers-attribute
Add support for distributed routers
2 parents b13ad9a + 043fa70 commit ff407fa

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ type ListOpts struct {
1616
ID string `q:"id"`
1717
Name string `q:"name"`
1818
AdminStateUp *bool `q:"admin_state_up"`
19+
Distributed *bool `q:"distributed"`
1920
Status string `q:"status"`
2021
TenantID string `q:"tenant_id"`
2122
Limit int `q:"limit"`
@@ -46,6 +47,7 @@ func List(c *gophercloud.ServiceClient, opts ListOpts) pagination.Pager {
4647
type CreateOpts struct {
4748
Name string
4849
AdminStateUp *bool
50+
Distributed *bool
4951
TenantID string
5052
GatewayInfo *GatewayInfo
5153
}
@@ -62,6 +64,7 @@ func Create(c *gophercloud.ServiceClient, opts CreateOpts) CreateResult {
6264
type router struct {
6365
Name *string `json:"name,omitempty"`
6466
AdminStateUp *bool `json:"admin_state_up,omitempty"`
67+
Distributed *bool `json:"distributed,omitempty"`
6568
TenantID *string `json:"tenant_id,omitempty"`
6669
GatewayInfo *GatewayInfo `json:"external_gateway_info,omitempty"`
6770
}
@@ -73,6 +76,7 @@ func Create(c *gophercloud.ServiceClient, opts CreateOpts) CreateResult {
7376
reqBody := request{Router: router{
7477
Name: gophercloud.MaybeString(opts.Name),
7578
AdminStateUp: opts.AdminStateUp,
79+
Distributed: opts.Distributed,
7680
TenantID: gophercloud.MaybeString(opts.TenantID),
7781
}}
7882

@@ -96,6 +100,7 @@ func Get(c *gophercloud.ServiceClient, id string) GetResult {
96100
type UpdateOpts struct {
97101
Name string
98102
AdminStateUp *bool
103+
Distributed *bool
99104
GatewayInfo *GatewayInfo
100105
Routes []Route
101106
}
@@ -109,6 +114,7 @@ func Update(c *gophercloud.ServiceClient, id string, opts UpdateOpts) UpdateResu
109114
type router struct {
110115
Name *string `json:"name,omitempty"`
111116
AdminStateUp *bool `json:"admin_state_up,omitempty"`
117+
Distributed *bool `json:"distributed,omitempty"`
112118
GatewayInfo *GatewayInfo `json:"external_gateway_info,omitempty"`
113119
Routes []Route `json:"routes"`
114120
}
@@ -120,6 +126,7 @@ func Update(c *gophercloud.ServiceClient, id string, opts UpdateOpts) UpdateResu
120126
reqBody := request{Router: router{
121127
Name: gophercloud.MaybeString(opts.Name),
122128
AdminStateUp: opts.AdminStateUp,
129+
Distributed: opts.Distributed,
123130
}}
124131

125132
if opts.GatewayInfo != nil {

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func TestList(t *testing.T) {
3737
"name": "second_routers",
3838
"admin_state_up": true,
3939
"tenant_id": "6b96ff0cb17a4b859e1e575d221683d3",
40+
"distributed": false,
4041
"id": "7177abc4-5ae9-4bb7-b0d4-89e94a4abf3b"
4142
},
4243
{
@@ -47,6 +48,7 @@ func TestList(t *testing.T) {
4748
"name": "router1",
4849
"admin_state_up": true,
4950
"tenant_id": "33a40233088643acb66ff6eb0ebea679",
51+
"distributed": false,
5052
"id": "a9254bdb-2613-4a13-ac4c-adc581fba50d"
5153
}
5254
]
@@ -69,6 +71,7 @@ func TestList(t *testing.T) {
6971
Status: "ACTIVE",
7072
GatewayInfo: GatewayInfo{NetworkID: ""},
7173
AdminStateUp: true,
74+
Distributed: false,
7275
Name: "second_routers",
7376
ID: "7177abc4-5ae9-4bb7-b0d4-89e94a4abf3b",
7477
TenantID: "6b96ff0cb17a4b859e1e575d221683d3",
@@ -77,6 +80,7 @@ func TestList(t *testing.T) {
7780
Status: "ACTIVE",
7881
GatewayInfo: GatewayInfo{NetworkID: "3c5bcddd-6af9-4e6b-9c3e-c153e521cab8"},
7982
AdminStateUp: true,
83+
Distributed: false,
8084
Name: "router1",
8185
ID: "a9254bdb-2613-4a13-ac4c-adc581fba50d",
8286
TenantID: "33a40233088643acb66ff6eb0ebea679",
@@ -127,6 +131,7 @@ func TestCreate(t *testing.T) {
127131
"name": "foo_router",
128132
"admin_state_up": false,
129133
"tenant_id": "6b96ff0cb17a4b859e1e575d221683d3",
134+
"distributed": false,
130135
"id": "8604a0de-7f6b-409a-a47c-a1cc7bc77b2e"
131136
}
132137
}
@@ -176,6 +181,7 @@ func TestGet(t *testing.T) {
176181
"name": "router1",
177182
"admin_state_up": true,
178183
"tenant_id": "d6554fe62e2f41efbb6e026fad5c1542",
184+
"distributed": false,
179185
"id": "a07eea83-7710-4860-931b-5fe220fae533"
180186
}
181187
}
@@ -233,6 +239,7 @@ func TestUpdate(t *testing.T) {
233239
"name": "new_name",
234240
"admin_state_up": true,
235241
"tenant_id": "6b96ff0cb17a4b859e1e575d221683d3",
242+
"distributed": false,
236243
"id": "8604a0de-7f6b-409a-a47c-a1cc7bc77b2e",
237244
"routes": [
238245
{
@@ -287,6 +294,7 @@ func TestAllRoutesRemoved(t *testing.T) {
287294
"name": "name",
288295
"admin_state_up": true,
289296
"tenant_id": "6b96ff0cb17a4b859e1e575d221683d3",
297+
"distributed": false,
290298
"id": "8604a0de-7f6b-409a-a47c-a1cc7bc77b2e",
291299
"routes": []
292300
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ type Router struct {
3535
// Administrative state of the router.
3636
AdminStateUp bool `json:"admin_state_up" mapstructure:"admin_state_up"`
3737

38+
// Whether router is disitrubted or not..
39+
Distributed bool `json:"distributed" mapstructure:"distributed"`
40+
3841
// Human readable name for the router. Does not have to be unique.
3942
Name string `json:"name" mapstructure:"name"`
4043

0 commit comments

Comments
 (0)