vendor: Updating gophercloud for openstack

This commit is contained in:
Joe Topjian 2016-04-08 02:51:36 +00:00
parent a152089e7c
commit e9f627ba92
6 changed files with 145 additions and 103 deletions

144
Godeps/Godeps.json generated
View File

@ -970,183 +970,183 @@
}, },
{ {
"ImportPath": "github.com/rackspace/gophercloud", "ImportPath": "github.com/rackspace/gophercloud",
"Comment": "v1.0.0-831-gf3d0534", "Comment": "v1.0.0-868-ga09b5b4",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
}, },
{ {
"ImportPath": "github.com/rackspace/gophercloud/openstack", "ImportPath": "github.com/rackspace/gophercloud/openstack",
"Comment": "v1.0.0-831-gf3d0534", "Comment": "v1.0.0-868-ga09b5b4",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
}, },
{ {
"ImportPath": "github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumes", "ImportPath": "github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumes",
"Comment": "v1.0.0-831-gf3d0534", "Comment": "v1.0.0-868-ga09b5b4",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
}, },
{ {
"ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/bootfromvolume", "ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/bootfromvolume",
"Comment": "v1.0.0-831-gf3d0534", "Comment": "v1.0.0-868-ga09b5b4",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
}, },
{ {
"ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/floatingip", "ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/floatingip",
"Comment": "v1.0.0-831-gf3d0534", "Comment": "v1.0.0-868-ga09b5b4",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
}, },
{ {
"ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/keypairs", "ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/keypairs",
"Comment": "v1.0.0-831-gf3d0534", "Comment": "v1.0.0-868-ga09b5b4",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
}, },
{ {
"ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/schedulerhints", "ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/schedulerhints",
"Comment": "v1.0.0-831-gf3d0534", "Comment": "v1.0.0-868-ga09b5b4",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
}, },
{ {
"ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/secgroups", "ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/secgroups",
"Comment": "v1.0.0-831-gf3d0534", "Comment": "v1.0.0-868-ga09b5b4",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
}, },
{ {
"ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/servergroups", "ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/servergroups",
"Comment": "v1.0.0-831-gf3d0534", "Comment": "v1.0.0-868-ga09b5b4",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
}, },
{ {
"ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/tenantnetworks", "ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/tenantnetworks",
"Comment": "v1.0.0-831-gf3d0534", "Comment": "v1.0.0-868-ga09b5b4",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
}, },
{ {
"ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/volumeattach", "ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/volumeattach",
"Comment": "v1.0.0-831-gf3d0534", "Comment": "v1.0.0-868-ga09b5b4",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
}, },
{ {
"ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/flavors", "ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/flavors",
"Comment": "v1.0.0-831-gf3d0534", "Comment": "v1.0.0-868-ga09b5b4",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
}, },
{ {
"ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/images", "ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/images",
"Comment": "v1.0.0-831-gf3d0534", "Comment": "v1.0.0-868-ga09b5b4",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
}, },
{ {
"ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/servers", "ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/servers",
"Comment": "v1.0.0-831-gf3d0534", "Comment": "v1.0.0-868-ga09b5b4",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
}, },
{ {
"ImportPath": "github.com/rackspace/gophercloud/openstack/identity/v2/tenants", "ImportPath": "github.com/rackspace/gophercloud/openstack/identity/v2/tenants",
"Comment": "v1.0.0-831-gf3d0534", "Comment": "v1.0.0-868-ga09b5b4",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
}, },
{ {
"ImportPath": "github.com/rackspace/gophercloud/openstack/identity/v2/tokens", "ImportPath": "github.com/rackspace/gophercloud/openstack/identity/v2/tokens",
"Comment": "v1.0.0-831-gf3d0534", "Comment": "v1.0.0-868-ga09b5b4",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
}, },
{ {
"ImportPath": "github.com/rackspace/gophercloud/openstack/identity/v3/tokens", "ImportPath": "github.com/rackspace/gophercloud/openstack/identity/v3/tokens",
"Comment": "v1.0.0-831-gf3d0534", "Comment": "v1.0.0-868-ga09b5b4",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
}, },
{ {
"ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/firewalls", "ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/firewalls",
"Comment": "v1.0.0-831-gf3d0534", "Comment": "v1.0.0-868-ga09b5b4",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
}, },
{ {
"ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/policies", "ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/policies",
"Comment": "v1.0.0-831-gf3d0534", "Comment": "v1.0.0-868-ga09b5b4",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
}, },
{ {
"ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/rules", "ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/rules",
"Comment": "v1.0.0-831-gf3d0534", "Comment": "v1.0.0-868-ga09b5b4",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
}, },
{ {
"ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/layer3/floatingips", "ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/layer3/floatingips",
"Comment": "v1.0.0-831-gf3d0534", "Comment": "v1.0.0-868-ga09b5b4",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
}, },
{ {
"ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/layer3/routers", "ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/layer3/routers",
"Comment": "v1.0.0-831-gf3d0534", "Comment": "v1.0.0-868-ga09b5b4",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
}, },
{ {
"ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/members", "ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/members",
"Comment": "v1.0.0-831-gf3d0534", "Comment": "v1.0.0-868-ga09b5b4",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
}, },
{ {
"ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/monitors", "ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/monitors",
"Comment": "v1.0.0-831-gf3d0534", "Comment": "v1.0.0-868-ga09b5b4",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
}, },
{ {
"ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/pools", "ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/pools",
"Comment": "v1.0.0-831-gf3d0534", "Comment": "v1.0.0-868-ga09b5b4",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
}, },
{ {
"ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/vips", "ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/vips",
"Comment": "v1.0.0-831-gf3d0534", "Comment": "v1.0.0-868-ga09b5b4",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
}, },
{ {
"ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/networks", "ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/networks",
"Comment": "v1.0.0-831-gf3d0534", "Comment": "v1.0.0-868-ga09b5b4",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
}, },
{ {
"ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/ports", "ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/ports",
"Comment": "v1.0.0-831-gf3d0534", "Comment": "v1.0.0-868-ga09b5b4",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
}, },
{ {
"ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/subnets", "ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/subnets",
"Comment": "v1.0.0-831-gf3d0534", "Comment": "v1.0.0-868-ga09b5b4",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
}, },
{ {
"ImportPath": "github.com/rackspace/gophercloud/openstack/objectstorage/v1/accounts", "ImportPath": "github.com/rackspace/gophercloud/openstack/objectstorage/v1/accounts",
"Comment": "v1.0.0-831-gf3d0534", "Comment": "v1.0.0-868-ga09b5b4",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
}, },
{ {
"ImportPath": "github.com/rackspace/gophercloud/openstack/objectstorage/v1/containers", "ImportPath": "github.com/rackspace/gophercloud/openstack/objectstorage/v1/containers",
"Comment": "v1.0.0-831-gf3d0534", "Comment": "v1.0.0-868-ga09b5b4",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
}, },
{ {
"ImportPath": "github.com/rackspace/gophercloud/openstack/objectstorage/v1/objects", "ImportPath": "github.com/rackspace/gophercloud/openstack/objectstorage/v1/objects",
"Comment": "v1.0.0-831-gf3d0534", "Comment": "v1.0.0-868-ga09b5b4",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
}, },
{ {
"ImportPath": "github.com/rackspace/gophercloud/openstack/utils", "ImportPath": "github.com/rackspace/gophercloud/openstack/utils",
"Comment": "v1.0.0-831-gf3d0534", "Comment": "v1.0.0-868-ga09b5b4",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
}, },
{ {
"ImportPath": "github.com/rackspace/gophercloud/pagination", "ImportPath": "github.com/rackspace/gophercloud/pagination",
"Comment": "v1.0.0-831-gf3d0534", "Comment": "v1.0.0-868-ga09b5b4",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
}, },
{ {
"ImportPath": "github.com/rackspace/gophercloud/testhelper", "ImportPath": "github.com/rackspace/gophercloud/testhelper",
"Comment": "v1.0.0-831-gf3d0534", "Comment": "v1.0.0-868-ga09b5b4",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
}, },
{ {
"ImportPath": "github.com/rackspace/gophercloud/testhelper/client", "ImportPath": "github.com/rackspace/gophercloud/testhelper/client",
"Comment": "v1.0.0-831-gf3d0534", "Comment": "v1.0.0-868-ga09b5b4",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb" "Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
}, },
{ {
"ImportPath": "github.com/satori/go.uuid", "ImportPath": "github.com/satori/go.uuid",

View File

@ -134,13 +134,17 @@ func v3auth(client *gophercloud.ProviderClient, endpoint string, options gopherc
v3Client.Endpoint = endpoint v3Client.Endpoint = endpoint
} }
// copy the auth options to a local variable that we can change. `options`
// needs to stay as-is for reauth purposes
v3Options := options
var scope *tokens3.Scope var scope *tokens3.Scope
if options.TenantID != "" { if options.TenantID != "" {
scope = &tokens3.Scope{ scope = &tokens3.Scope{
ProjectID: options.TenantID, ProjectID: options.TenantID,
} }
options.TenantID = "" v3Options.TenantID = ""
options.TenantName = "" v3Options.TenantName = ""
} else { } else {
if options.TenantName != "" { if options.TenantName != "" {
scope = &tokens3.Scope{ scope = &tokens3.Scope{
@ -148,11 +152,11 @@ func v3auth(client *gophercloud.ProviderClient, endpoint string, options gopherc
DomainID: options.DomainID, DomainID: options.DomainID,
DomainName: options.DomainName, DomainName: options.DomainName,
} }
options.TenantName = "" v3Options.TenantName = ""
} }
} }
result := tokens3.Create(v3Client, options, scope) result := tokens3.Create(v3Client, v3Options, scope)
token, err := result.ExtractToken() token, err := result.ExtractToken()
if err != nil { if err != nil {

View File

@ -1,3 +1,5 @@
// +build fixtures
package secgroups package secgroups
import ( import (

View File

@ -42,6 +42,14 @@ func List(c *gophercloud.ServiceClient, opts ListOpts) pagination.Pager {
}) })
} }
// CreateOptsBuilder is the interface options structs have to satisfy in order
// to be used in the main Create operation in this package. Since many
// extensions decorate or modify the common logic, it is useful for them to
// satisfy a basic interface in order for them to be used.
type CreateOptsBuilder interface {
ToRouterCreateMap() (map[string]interface{}, error)
}
// CreateOpts contains all the values needed to create a new router. There are // CreateOpts contains all the values needed to create a new router. There are
// no required values. // no required values.
type CreateOpts struct { type CreateOpts struct {
@ -52,6 +60,33 @@ type CreateOpts struct {
GatewayInfo *GatewayInfo GatewayInfo *GatewayInfo
} }
// ToRouterCreateMap casts a CreateOpts struct to a map.
func (opts CreateOpts) ToRouterCreateMap() (map[string]interface{}, error) {
r := make(map[string]interface{})
if gophercloud.MaybeString(opts.Name) != nil {
r["name"] = opts.Name
}
if opts.AdminStateUp != nil {
r["admin_state_up"] = opts.AdminStateUp
}
if opts.Distributed != nil {
r["distributed"] = opts.Distributed
}
if gophercloud.MaybeString(opts.TenantID) != nil {
r["tenant_id"] = opts.TenantID
}
if opts.GatewayInfo != nil {
r["external_gateway_info"] = opts.GatewayInfo
}
return map[string]interface{}{"router": r}, nil
}
// Create accepts a CreateOpts struct and uses the values to create a new // Create accepts a CreateOpts struct and uses the values to create a new
// logical router. When it is created, the router does not have an internal // logical router. When it is created, the router does not have an internal
// interface - it is not associated to any subnet. // interface - it is not associated to any subnet.
@ -60,31 +95,15 @@ type CreateOpts struct {
// GatewayInfo struct. The external gateway for the router must be plugged into // GatewayInfo struct. The external gateway for the router must be plugged into
// an external network (it is external if its `router:external' field is set to // an external network (it is external if its `router:external' field is set to
// true). // true).
func Create(c *gophercloud.ServiceClient, opts CreateOpts) CreateResult { func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) 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"`
}
type request struct {
Router router `json:"router"`
}
reqBody := request{Router: router{
Name: gophercloud.MaybeString(opts.Name),
AdminStateUp: opts.AdminStateUp,
Distributed: opts.Distributed,
TenantID: gophercloud.MaybeString(opts.TenantID),
}}
if opts.GatewayInfo != nil {
reqBody.Router.GatewayInfo = opts.GatewayInfo
}
var res CreateResult var res CreateResult
reqBody, err := opts.ToRouterCreateMap()
if err != nil {
res.Err = err
return res
}
_, res.Err = c.Post(rootURL(c), reqBody, &res.Body, nil) _, res.Err = c.Post(rootURL(c), reqBody, &res.Body, nil)
return res return res
} }

View File

@ -7,7 +7,8 @@ func err(str string) error {
} }
var ( var (
errNetworkIDRequired = err("A network ID is required") errNetworkIDRequired = err("A network ID is required")
errCIDRRequired = err("A valid CIDR is required") errCIDRRequired = err("A valid CIDR is required")
errInvalidIPType = err("An IP type must either be 4 or 6") errInvalidIPType = err("An IP type must either be 4 or 6")
errInvalidGatewayConfig = err("Both disabling the gateway and specifying a gateway is not allowed")
) )

View File

@ -108,6 +108,7 @@ type CreateOpts struct {
TenantID string TenantID string
AllocationPools []AllocationPool AllocationPools []AllocationPool
GatewayIP string GatewayIP string
NoGateway bool
IPVersion int IPVersion int
EnableDHCP *bool EnableDHCP *bool
DNSNameservers []string DNSNameservers []string
@ -128,6 +129,11 @@ func (opts CreateOpts) ToSubnetCreateMap() (map[string]interface{}, error) {
return nil, errInvalidIPType return nil, errInvalidIPType
} }
// Both GatewayIP and NoGateway should not be set
if opts.GatewayIP != "" && opts.NoGateway {
return nil, errInvalidGatewayConfig
}
s["network_id"] = opts.NetworkID s["network_id"] = opts.NetworkID
s["cidr"] = opts.CIDR s["cidr"] = opts.CIDR
@ -139,6 +145,8 @@ func (opts CreateOpts) ToSubnetCreateMap() (map[string]interface{}, error) {
} }
if opts.GatewayIP != "" { if opts.GatewayIP != "" {
s["gateway_ip"] = opts.GatewayIP s["gateway_ip"] = opts.GatewayIP
} else if opts.NoGateway {
s["gateway_ip"] = nil
} }
if opts.TenantID != "" { if opts.TenantID != "" {
s["tenant_id"] = opts.TenantID s["tenant_id"] = opts.TenantID
@ -184,6 +192,7 @@ type UpdateOptsBuilder interface {
type UpdateOpts struct { type UpdateOpts struct {
Name string Name string
GatewayIP string GatewayIP string
NoGateway bool
DNSNameservers []string DNSNameservers []string
HostRoutes []HostRoute HostRoutes []HostRoute
EnableDHCP *bool EnableDHCP *bool
@ -193,6 +202,11 @@ type UpdateOpts struct {
func (opts UpdateOpts) ToSubnetUpdateMap() (map[string]interface{}, error) { func (opts UpdateOpts) ToSubnetUpdateMap() (map[string]interface{}, error) {
s := make(map[string]interface{}) s := make(map[string]interface{})
// Both GatewayIP and NoGateway should not be set
if opts.GatewayIP != "" && opts.NoGateway {
return nil, errInvalidGatewayConfig
}
if opts.EnableDHCP != nil { if opts.EnableDHCP != nil {
s["enable_dhcp"] = &opts.EnableDHCP s["enable_dhcp"] = &opts.EnableDHCP
} }
@ -201,6 +215,8 @@ func (opts UpdateOpts) ToSubnetUpdateMap() (map[string]interface{}, error) {
} }
if opts.GatewayIP != "" { if opts.GatewayIP != "" {
s["gateway_ip"] = opts.GatewayIP s["gateway_ip"] = opts.GatewayIP
} else if opts.NoGateway {
s["gateway_ip"] = nil
} }
if opts.DNSNameservers != nil { if opts.DNSNameservers != nil {
s["dns_nameservers"] = opts.DNSNameservers s["dns_nameservers"] = opts.DNSNameservers