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

Commit

Permalink
Add support for distributed routers
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirill Shirinkin committed Jan 28, 2016
1 parent c70720d commit 043fa70
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions openstack/networking/v2/extensions/layer3/routers/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type ListOpts struct {
ID string `q:"id"`
Name string `q:"name"`
AdminStateUp *bool `q:"admin_state_up"`
Distributed *bool `q:"distributed"`
Status string `q:"status"`
TenantID string `q:"tenant_id"`
Limit int `q:"limit"`
Expand Down Expand Up @@ -46,6 +47,7 @@ func List(c *gophercloud.ServiceClient, opts ListOpts) pagination.Pager {
type CreateOpts struct {
Name string
AdminStateUp *bool
Distributed *bool
TenantID string
GatewayInfo *GatewayInfo
}
Expand All @@ -62,6 +64,7 @@ func Create(c *gophercloud.ServiceClient, opts CreateOpts) CreateResult {
type router struct {
Name *string `json:"name,omitempty"`
AdminStateUp *bool `json:"admin_state_up,omitempty"`
Distributed *bool `json:"distributed,omitempty"`
TenantID *string `json:"tenant_id,omitempty"`
GatewayInfo *GatewayInfo `json:"external_gateway_info,omitempty"`
}
Expand All @@ -73,6 +76,7 @@ func Create(c *gophercloud.ServiceClient, opts CreateOpts) CreateResult {
reqBody := request{Router: router{
Name: gophercloud.MaybeString(opts.Name),
AdminStateUp: opts.AdminStateUp,
Distributed: opts.Distributed,
TenantID: gophercloud.MaybeString(opts.TenantID),
}}

Expand All @@ -96,6 +100,7 @@ func Get(c *gophercloud.ServiceClient, id string) GetResult {
type UpdateOpts struct {
Name string
AdminStateUp *bool
Distributed *bool
GatewayInfo *GatewayInfo
Routes []Route
}
Expand All @@ -109,6 +114,7 @@ func Update(c *gophercloud.ServiceClient, id string, opts UpdateOpts) UpdateResu
type router struct {
Name *string `json:"name,omitempty"`
AdminStateUp *bool `json:"admin_state_up,omitempty"`
Distributed *bool `json:"distributed,omitempty"`
GatewayInfo *GatewayInfo `json:"external_gateway_info,omitempty"`
Routes []Route `json:"routes"`
}
Expand All @@ -120,6 +126,7 @@ func Update(c *gophercloud.ServiceClient, id string, opts UpdateOpts) UpdateResu
reqBody := request{Router: router{
Name: gophercloud.MaybeString(opts.Name),
AdminStateUp: opts.AdminStateUp,
Distributed: opts.Distributed,
}}

if opts.GatewayInfo != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func TestList(t *testing.T) {
"name": "second_routers",
"admin_state_up": true,
"tenant_id": "6b96ff0cb17a4b859e1e575d221683d3",
"distributed": false,
"id": "7177abc4-5ae9-4bb7-b0d4-89e94a4abf3b"
},
{
Expand All @@ -47,6 +48,7 @@ func TestList(t *testing.T) {
"name": "router1",
"admin_state_up": true,
"tenant_id": "33a40233088643acb66ff6eb0ebea679",
"distributed": false,
"id": "a9254bdb-2613-4a13-ac4c-adc581fba50d"
}
]
Expand All @@ -69,6 +71,7 @@ func TestList(t *testing.T) {
Status: "ACTIVE",
GatewayInfo: GatewayInfo{NetworkID: ""},
AdminStateUp: true,
Distributed: false,
Name: "second_routers",
ID: "7177abc4-5ae9-4bb7-b0d4-89e94a4abf3b",
TenantID: "6b96ff0cb17a4b859e1e575d221683d3",
Expand All @@ -77,6 +80,7 @@ func TestList(t *testing.T) {
Status: "ACTIVE",
GatewayInfo: GatewayInfo{NetworkID: "3c5bcddd-6af9-4e6b-9c3e-c153e521cab8"},
AdminStateUp: true,
Distributed: false,
Name: "router1",
ID: "a9254bdb-2613-4a13-ac4c-adc581fba50d",
TenantID: "33a40233088643acb66ff6eb0ebea679",
Expand Down Expand Up @@ -127,6 +131,7 @@ func TestCreate(t *testing.T) {
"name": "foo_router",
"admin_state_up": false,
"tenant_id": "6b96ff0cb17a4b859e1e575d221683d3",
"distributed": false,
"id": "8604a0de-7f6b-409a-a47c-a1cc7bc77b2e"
}
}
Expand Down Expand Up @@ -176,6 +181,7 @@ func TestGet(t *testing.T) {
"name": "router1",
"admin_state_up": true,
"tenant_id": "d6554fe62e2f41efbb6e026fad5c1542",
"distributed": false,
"id": "a07eea83-7710-4860-931b-5fe220fae533"
}
}
Expand Down Expand Up @@ -233,6 +239,7 @@ func TestUpdate(t *testing.T) {
"name": "new_name",
"admin_state_up": true,
"tenant_id": "6b96ff0cb17a4b859e1e575d221683d3",
"distributed": false,
"id": "8604a0de-7f6b-409a-a47c-a1cc7bc77b2e",
"routes": [
{
Expand Down Expand Up @@ -287,6 +294,7 @@ func TestAllRoutesRemoved(t *testing.T) {
"name": "name",
"admin_state_up": true,
"tenant_id": "6b96ff0cb17a4b859e1e575d221683d3",
"distributed": false,
"id": "8604a0de-7f6b-409a-a47c-a1cc7bc77b2e",
"routes": []
}
Expand Down
3 changes: 3 additions & 0 deletions openstack/networking/v2/extensions/layer3/routers/results.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ type Router struct {
// Administrative state of the router.
AdminStateUp bool `json:"admin_state_up" mapstructure:"admin_state_up"`

// Whether router is disitrubted or not..
Distributed bool `json:"distributed" mapstructure:"distributed"`

// Human readable name for the router. Does not have to be unique.
Name string `json:"name" mapstructure:"name"`

Expand Down

0 comments on commit 043fa70

Please sign in to comment.