Merge pull request #6079 from jtopjian/openstack-vendor-update

vendor: Updating gophercloud for openstack
This commit is contained in:
Joe Topjian 2016-04-07 20:59:47 -06:00
commit 1889ab7bb3
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",
"Comment": "v1.0.0-831-gf3d0534",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb"
"Comment": "v1.0.0-868-ga09b5b4",
"Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
},
{
"ImportPath": "github.com/rackspace/gophercloud/openstack",
"Comment": "v1.0.0-831-gf3d0534",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb"
"Comment": "v1.0.0-868-ga09b5b4",
"Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
},
{
"ImportPath": "github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumes",
"Comment": "v1.0.0-831-gf3d0534",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb"
"Comment": "v1.0.0-868-ga09b5b4",
"Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
},
{
"ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/bootfromvolume",
"Comment": "v1.0.0-831-gf3d0534",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb"
"Comment": "v1.0.0-868-ga09b5b4",
"Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
},
{
"ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/floatingip",
"Comment": "v1.0.0-831-gf3d0534",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb"
"Comment": "v1.0.0-868-ga09b5b4",
"Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
},
{
"ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/keypairs",
"Comment": "v1.0.0-831-gf3d0534",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb"
"Comment": "v1.0.0-868-ga09b5b4",
"Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
},
{
"ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/schedulerhints",
"Comment": "v1.0.0-831-gf3d0534",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb"
"Comment": "v1.0.0-868-ga09b5b4",
"Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
},
{
"ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/secgroups",
"Comment": "v1.0.0-831-gf3d0534",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb"
"Comment": "v1.0.0-868-ga09b5b4",
"Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
},
{
"ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/servergroups",
"Comment": "v1.0.0-831-gf3d0534",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb"
"Comment": "v1.0.0-868-ga09b5b4",
"Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
},
{
"ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/tenantnetworks",
"Comment": "v1.0.0-831-gf3d0534",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb"
"Comment": "v1.0.0-868-ga09b5b4",
"Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
},
{
"ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/volumeattach",
"Comment": "v1.0.0-831-gf3d0534",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb"
"Comment": "v1.0.0-868-ga09b5b4",
"Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
},
{
"ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/flavors",
"Comment": "v1.0.0-831-gf3d0534",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb"
"Comment": "v1.0.0-868-ga09b5b4",
"Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
},
{
"ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/images",
"Comment": "v1.0.0-831-gf3d0534",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb"
"Comment": "v1.0.0-868-ga09b5b4",
"Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
},
{
"ImportPath": "github.com/rackspace/gophercloud/openstack/compute/v2/servers",
"Comment": "v1.0.0-831-gf3d0534",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb"
"Comment": "v1.0.0-868-ga09b5b4",
"Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
},
{
"ImportPath": "github.com/rackspace/gophercloud/openstack/identity/v2/tenants",
"Comment": "v1.0.0-831-gf3d0534",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb"
"Comment": "v1.0.0-868-ga09b5b4",
"Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
},
{
"ImportPath": "github.com/rackspace/gophercloud/openstack/identity/v2/tokens",
"Comment": "v1.0.0-831-gf3d0534",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb"
"Comment": "v1.0.0-868-ga09b5b4",
"Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
},
{
"ImportPath": "github.com/rackspace/gophercloud/openstack/identity/v3/tokens",
"Comment": "v1.0.0-831-gf3d0534",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb"
"Comment": "v1.0.0-868-ga09b5b4",
"Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
},
{
"ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/firewalls",
"Comment": "v1.0.0-831-gf3d0534",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb"
"Comment": "v1.0.0-868-ga09b5b4",
"Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
},
{
"ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/policies",
"Comment": "v1.0.0-831-gf3d0534",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb"
"Comment": "v1.0.0-868-ga09b5b4",
"Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
},
{
"ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/rules",
"Comment": "v1.0.0-831-gf3d0534",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb"
"Comment": "v1.0.0-868-ga09b5b4",
"Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
},
{
"ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/layer3/floatingips",
"Comment": "v1.0.0-831-gf3d0534",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb"
"Comment": "v1.0.0-868-ga09b5b4",
"Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
},
{
"ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/layer3/routers",
"Comment": "v1.0.0-831-gf3d0534",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb"
"Comment": "v1.0.0-868-ga09b5b4",
"Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
},
{
"ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/members",
"Comment": "v1.0.0-831-gf3d0534",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb"
"Comment": "v1.0.0-868-ga09b5b4",
"Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
},
{
"ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/monitors",
"Comment": "v1.0.0-831-gf3d0534",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb"
"Comment": "v1.0.0-868-ga09b5b4",
"Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
},
{
"ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/pools",
"Comment": "v1.0.0-831-gf3d0534",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb"
"Comment": "v1.0.0-868-ga09b5b4",
"Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
},
{
"ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/extensions/lbaas/vips",
"Comment": "v1.0.0-831-gf3d0534",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb"
"Comment": "v1.0.0-868-ga09b5b4",
"Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
},
{
"ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/networks",
"Comment": "v1.0.0-831-gf3d0534",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb"
"Comment": "v1.0.0-868-ga09b5b4",
"Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
},
{
"ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/ports",
"Comment": "v1.0.0-831-gf3d0534",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb"
"Comment": "v1.0.0-868-ga09b5b4",
"Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
},
{
"ImportPath": "github.com/rackspace/gophercloud/openstack/networking/v2/subnets",
"Comment": "v1.0.0-831-gf3d0534",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb"
"Comment": "v1.0.0-868-ga09b5b4",
"Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
},
{
"ImportPath": "github.com/rackspace/gophercloud/openstack/objectstorage/v1/accounts",
"Comment": "v1.0.0-831-gf3d0534",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb"
"Comment": "v1.0.0-868-ga09b5b4",
"Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
},
{
"ImportPath": "github.com/rackspace/gophercloud/openstack/objectstorage/v1/containers",
"Comment": "v1.0.0-831-gf3d0534",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb"
"Comment": "v1.0.0-868-ga09b5b4",
"Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
},
{
"ImportPath": "github.com/rackspace/gophercloud/openstack/objectstorage/v1/objects",
"Comment": "v1.0.0-831-gf3d0534",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb"
"Comment": "v1.0.0-868-ga09b5b4",
"Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
},
{
"ImportPath": "github.com/rackspace/gophercloud/openstack/utils",
"Comment": "v1.0.0-831-gf3d0534",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb"
"Comment": "v1.0.0-868-ga09b5b4",
"Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
},
{
"ImportPath": "github.com/rackspace/gophercloud/pagination",
"Comment": "v1.0.0-831-gf3d0534",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb"
"Comment": "v1.0.0-868-ga09b5b4",
"Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
},
{
"ImportPath": "github.com/rackspace/gophercloud/testhelper",
"Comment": "v1.0.0-831-gf3d0534",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb"
"Comment": "v1.0.0-868-ga09b5b4",
"Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
},
{
"ImportPath": "github.com/rackspace/gophercloud/testhelper/client",
"Comment": "v1.0.0-831-gf3d0534",
"Rev": "f3d053460f7c37970af6733bf370a3256e3648fb"
"Comment": "v1.0.0-868-ga09b5b4",
"Rev": "a09b5b4eb58195b6fb3898496586b8d6aeb558e0"
},
{
"ImportPath": "github.com/satori/go.uuid",

View File

@ -134,13 +134,17 @@ func v3auth(client *gophercloud.ProviderClient, endpoint string, options gopherc
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
if options.TenantID != "" {
scope = &tokens3.Scope{
ProjectID: options.TenantID,
}
options.TenantID = ""
options.TenantName = ""
v3Options.TenantID = ""
v3Options.TenantName = ""
} else {
if options.TenantName != "" {
scope = &tokens3.Scope{
@ -148,11 +152,11 @@ func v3auth(client *gophercloud.ProviderClient, endpoint string, options gopherc
DomainID: options.DomainID,
DomainName: options.DomainName,
}
options.TenantName = ""
v3Options.TenantName = ""
}
}
result := tokens3.Create(v3Client, options, scope)
result := tokens3.Create(v3Client, v3Options, scope)
token, err := result.ExtractToken()
if err != nil {

View File

@ -1,3 +1,5 @@
// +build fixtures
package secgroups
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
// no required values.
type CreateOpts struct {
@ -52,6 +60,33 @@ type CreateOpts struct {
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
// logical router. When it is created, the router does not have an internal
// 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
// an external network (it is external if its `router:external' field is set to
// true).
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"`
}
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
}
func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) 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)
return res
}

View File

@ -7,7 +7,8 @@ func err(str string) error {
}
var (
errNetworkIDRequired = err("A network ID is required")
errCIDRRequired = err("A valid CIDR is required")
errInvalidIPType = err("An IP type must either be 4 or 6")
errNetworkIDRequired = err("A network ID is required")
errCIDRRequired = err("A valid CIDR is required")
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
AllocationPools []AllocationPool
GatewayIP string
NoGateway bool
IPVersion int
EnableDHCP *bool
DNSNameservers []string
@ -128,6 +129,11 @@ func (opts CreateOpts) ToSubnetCreateMap() (map[string]interface{}, error) {
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["cidr"] = opts.CIDR
@ -139,6 +145,8 @@ func (opts CreateOpts) ToSubnetCreateMap() (map[string]interface{}, error) {
}
if opts.GatewayIP != "" {
s["gateway_ip"] = opts.GatewayIP
} else if opts.NoGateway {
s["gateway_ip"] = nil
}
if opts.TenantID != "" {
s["tenant_id"] = opts.TenantID
@ -184,6 +192,7 @@ type UpdateOptsBuilder interface {
type UpdateOpts struct {
Name string
GatewayIP string
NoGateway bool
DNSNameservers []string
HostRoutes []HostRoute
EnableDHCP *bool
@ -193,6 +202,11 @@ type UpdateOpts struct {
func (opts UpdateOpts) ToSubnetUpdateMap() (map[string]interface{}, error) {
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 {
s["enable_dhcp"] = &opts.EnableDHCP
}
@ -201,6 +215,8 @@ func (opts UpdateOpts) ToSubnetUpdateMap() (map[string]interface{}, error) {
}
if opts.GatewayIP != "" {
s["gateway_ip"] = opts.GatewayIP
} else if opts.NoGateway {
s["gateway_ip"] = nil
}
if opts.DNSNameservers != nil {
s["dns_nameservers"] = opts.DNSNameservers