mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	Merge pull request #32663 from anguslees/extraroutes
Automatic merge from submit-queue
openstack: Implement the `Routes` provider API
``` release-note
Implement the Routes provider API for OpenStack using Neutron extraroute extension.  This removes the need for flannel/etc where supported.  To use, ensure all your nodes are on the same Neutron (private) network and specify the router ID in new `[Route]` section of provider config:
    [Route]
    router-id = <router UUID>
```
			
			
This commit is contained in:
		
							
								
								
									
										256
									
								
								vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/layer3/routers/requests.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										256
									
								
								vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/layer3/routers/requests.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,256 @@
 | 
			
		||||
package routers
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"errors"
 | 
			
		||||
 | 
			
		||||
	"github.com/rackspace/gophercloud"
 | 
			
		||||
	"github.com/rackspace/gophercloud/pagination"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// ListOpts allows the filtering and sorting of paginated collections through
 | 
			
		||||
// the API. Filtering is achieved by passing in struct field values that map to
 | 
			
		||||
// the floating IP attributes you want to see returned. SortKey allows you to
 | 
			
		||||
// sort by a particular network attribute. SortDir sets the direction, and is
 | 
			
		||||
// either `asc' or `desc'. Marker and Limit are used for pagination.
 | 
			
		||||
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"`
 | 
			
		||||
	Marker       string `q:"marker"`
 | 
			
		||||
	SortKey      string `q:"sort_key"`
 | 
			
		||||
	SortDir      string `q:"sort_dir"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// List returns a Pager which allows you to iterate over a collection of
 | 
			
		||||
// routers. It accepts a ListOpts struct, which allows you to filter and sort
 | 
			
		||||
// the returned collection for greater efficiency.
 | 
			
		||||
//
 | 
			
		||||
// Default policy settings return only those routers that are owned by the
 | 
			
		||||
// tenant who submits the request, unless an admin user submits the request.
 | 
			
		||||
func List(c *gophercloud.ServiceClient, opts ListOpts) pagination.Pager {
 | 
			
		||||
	q, err := gophercloud.BuildQueryString(&opts)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return pagination.Pager{Err: err}
 | 
			
		||||
	}
 | 
			
		||||
	u := rootURL(c) + q.String()
 | 
			
		||||
	return pagination.NewPager(c, u, func(r pagination.PageResult) pagination.Page {
 | 
			
		||||
		return RouterPage{pagination.LinkedPageBase{PageResult: r}}
 | 
			
		||||
	})
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 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 {
 | 
			
		||||
	Name         string
 | 
			
		||||
	AdminStateUp *bool
 | 
			
		||||
	Distributed  *bool
 | 
			
		||||
	TenantID     string
 | 
			
		||||
	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.
 | 
			
		||||
//
 | 
			
		||||
// You can optionally specify an external gateway for a router using the
 | 
			
		||||
// 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 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
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Get retrieves a particular router based on its unique ID.
 | 
			
		||||
func Get(c *gophercloud.ServiceClient, id string) GetResult {
 | 
			
		||||
	var res GetResult
 | 
			
		||||
	_, res.Err = c.Get(resourceURL(c, id), &res.Body, nil)
 | 
			
		||||
	return res
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// UpdateOpts contains the values used when updating a router.
 | 
			
		||||
type UpdateOpts struct {
 | 
			
		||||
	Name         string
 | 
			
		||||
	AdminStateUp *bool
 | 
			
		||||
	Distributed  *bool
 | 
			
		||||
	GatewayInfo  *GatewayInfo
 | 
			
		||||
	Routes       []Route
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Update allows routers to be updated. You can update the name, administrative
 | 
			
		||||
// state, and the external gateway. For more information about how to set the
 | 
			
		||||
// external gateway for a router, see Create. This operation does not enable
 | 
			
		||||
// the update of router interfaces. To do this, use the AddInterface and
 | 
			
		||||
// RemoveInterface functions.
 | 
			
		||||
func Update(c *gophercloud.ServiceClient, id string, opts UpdateOpts) UpdateResult {
 | 
			
		||||
	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"`
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	type request struct {
 | 
			
		||||
		Router router `json:"router"`
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	reqBody := request{Router: router{
 | 
			
		||||
		Name:         gophercloud.MaybeString(opts.Name),
 | 
			
		||||
		AdminStateUp: opts.AdminStateUp,
 | 
			
		||||
		Distributed:  opts.Distributed,
 | 
			
		||||
	}}
 | 
			
		||||
 | 
			
		||||
	if opts.GatewayInfo != nil {
 | 
			
		||||
		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{
 | 
			
		||||
		OkCodes: []int{200},
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	return res
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Delete will permanently delete a particular router based on its unique ID.
 | 
			
		||||
func Delete(c *gophercloud.ServiceClient, id string) DeleteResult {
 | 
			
		||||
	var res DeleteResult
 | 
			
		||||
	_, res.Err = c.Delete(resourceURL(c, id), nil)
 | 
			
		||||
	return res
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var errInvalidInterfaceOpts = errors.New("When adding a router interface you must provide either a subnet ID or a port ID")
 | 
			
		||||
 | 
			
		||||
// InterfaceOpts allow you to work with operations that either add or remote
 | 
			
		||||
// an internal interface from a router.
 | 
			
		||||
type InterfaceOpts struct {
 | 
			
		||||
	SubnetID string
 | 
			
		||||
	PortID   string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// AddInterface attaches a subnet to an internal router interface. You must
 | 
			
		||||
// specify either a SubnetID or PortID in the request body. If you specify both,
 | 
			
		||||
// the operation will fail and an error will be returned.
 | 
			
		||||
//
 | 
			
		||||
// If you specify a SubnetID, the gateway IP address for that particular subnet
 | 
			
		||||
// is used to create the router interface. Alternatively, if you specify a
 | 
			
		||||
// PortID, the IP address associated with the port is used to create the router
 | 
			
		||||
// interface.
 | 
			
		||||
//
 | 
			
		||||
// If you reference a port that is associated with multiple IP addresses, or
 | 
			
		||||
// if the port is associated with zero IP addresses, the operation will fail and
 | 
			
		||||
// a 400 Bad Request error will be returned.
 | 
			
		||||
//
 | 
			
		||||
// If you reference a port already in use, the operation will fail and a 409
 | 
			
		||||
// Conflict error will be returned.
 | 
			
		||||
//
 | 
			
		||||
// The PortID that is returned after using Extract() on the result of this
 | 
			
		||||
// operation can either be the same PortID passed in or, on the other hand, the
 | 
			
		||||
// identifier of a new port created by this operation. After the operation
 | 
			
		||||
// completes, the device ID of the port is set to the router ID, and the
 | 
			
		||||
// device owner attribute is set to `network:router_interface'.
 | 
			
		||||
func AddInterface(c *gophercloud.ServiceClient, id string, opts InterfaceOpts) InterfaceResult {
 | 
			
		||||
	var res InterfaceResult
 | 
			
		||||
 | 
			
		||||
	// Validate
 | 
			
		||||
	if (opts.SubnetID == "" && opts.PortID == "") || (opts.SubnetID != "" && opts.PortID != "") {
 | 
			
		||||
		res.Err = errInvalidInterfaceOpts
 | 
			
		||||
		return res
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	type request struct {
 | 
			
		||||
		SubnetID string `json:"subnet_id,omitempty"`
 | 
			
		||||
		PortID   string `json:"port_id,omitempty"`
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	body := request{SubnetID: opts.SubnetID, PortID: opts.PortID}
 | 
			
		||||
 | 
			
		||||
	_, res.Err = c.Put(addInterfaceURL(c, id), body, &res.Body, &gophercloud.RequestOpts{
 | 
			
		||||
		OkCodes: []int{200},
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	return res
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// RemoveInterface removes an internal router interface, which detaches a
 | 
			
		||||
// subnet from the router. You must specify either a SubnetID or PortID, since
 | 
			
		||||
// these values are used to identify the router interface to remove.
 | 
			
		||||
//
 | 
			
		||||
// Unlike AddInterface, you can also specify both a SubnetID and PortID. If you
 | 
			
		||||
// choose to specify both, the subnet ID must correspond to the subnet ID of
 | 
			
		||||
// the first IP address on the port specified by the port ID. Otherwise, the
 | 
			
		||||
// operation will fail and return a 409 Conflict error.
 | 
			
		||||
//
 | 
			
		||||
// If the router, subnet or port which are referenced do not exist or are not
 | 
			
		||||
// visible to you, the operation will fail and a 404 Not Found error will be
 | 
			
		||||
// returned. After this operation completes, the port connecting the router
 | 
			
		||||
// with the subnet is removed from the subnet for the network.
 | 
			
		||||
func RemoveInterface(c *gophercloud.ServiceClient, id string, opts InterfaceOpts) InterfaceResult {
 | 
			
		||||
	var res InterfaceResult
 | 
			
		||||
 | 
			
		||||
	type request struct {
 | 
			
		||||
		SubnetID string `json:"subnet_id,omitempty"`
 | 
			
		||||
		PortID   string `json:"port_id,omitempty"`
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	body := request{SubnetID: opts.SubnetID, PortID: opts.PortID}
 | 
			
		||||
 | 
			
		||||
	_, res.Err = c.Put(removeInterfaceURL(c, id), body, &res.Body, &gophercloud.RequestOpts{
 | 
			
		||||
		OkCodes: []int{200},
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	return res
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										171
									
								
								vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/layer3/routers/results.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										171
									
								
								vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/layer3/routers/results.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,171 @@
 | 
			
		||||
package routers
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"github.com/mitchellh/mapstructure"
 | 
			
		||||
	"github.com/rackspace/gophercloud"
 | 
			
		||||
	"github.com/rackspace/gophercloud/pagination"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// GatewayInfo represents the information of an external gateway for any
 | 
			
		||||
// particular network router.
 | 
			
		||||
type GatewayInfo struct {
 | 
			
		||||
	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.
 | 
			
		||||
//
 | 
			
		||||
// A router has an interface for each subnet with which it is associated. By
 | 
			
		||||
// default, the IP address of such interface is the subnet's gateway IP. Also,
 | 
			
		||||
// whenever a router is associated with a subnet, a port for that router
 | 
			
		||||
// interface is added to the subnet's network.
 | 
			
		||||
type Router struct {
 | 
			
		||||
	// Indicates whether or not a router is currently operational.
 | 
			
		||||
	Status string `json:"status" mapstructure:"status"`
 | 
			
		||||
 | 
			
		||||
	// Information on external gateway for the router.
 | 
			
		||||
	GatewayInfo GatewayInfo `json:"external_gateway_info" mapstructure:"external_gateway_info"`
 | 
			
		||||
 | 
			
		||||
	// 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"`
 | 
			
		||||
 | 
			
		||||
	// Unique identifier for the router.
 | 
			
		||||
	ID string `json:"id" mapstructure:"id"`
 | 
			
		||||
 | 
			
		||||
	// 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
 | 
			
		||||
// collection of routers.
 | 
			
		||||
type RouterPage struct {
 | 
			
		||||
	pagination.LinkedPageBase
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// NextPageURL is invoked when a paginated collection of routers has reached
 | 
			
		||||
// the end of a page and the pager seeks to traverse over a new one. In order
 | 
			
		||||
// to do this, it needs to construct the next page's URL.
 | 
			
		||||
func (p RouterPage) NextPageURL() (string, error) {
 | 
			
		||||
	type resp struct {
 | 
			
		||||
		Links []gophercloud.Link `mapstructure:"routers_links"`
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var r resp
 | 
			
		||||
	err := mapstructure.Decode(p.Body, &r)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return gophercloud.ExtractNextURL(r.Links)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IsEmpty checks whether a RouterPage struct is empty.
 | 
			
		||||
func (p RouterPage) IsEmpty() (bool, error) {
 | 
			
		||||
	is, err := ExtractRouters(p)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return true, nil
 | 
			
		||||
	}
 | 
			
		||||
	return len(is) == 0, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ExtractRouters accepts a Page struct, specifically a RouterPage struct,
 | 
			
		||||
// and extracts the elements into a slice of Router structs. In other words,
 | 
			
		||||
// a generic collection is mapped into a relevant slice.
 | 
			
		||||
func ExtractRouters(page pagination.Page) ([]Router, error) {
 | 
			
		||||
	var resp struct {
 | 
			
		||||
		Routers []Router `mapstructure:"routers" json:"routers"`
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	err := mapstructure.Decode(page.(RouterPage).Body, &resp)
 | 
			
		||||
 | 
			
		||||
	return resp.Routers, err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type commonResult struct {
 | 
			
		||||
	gophercloud.Result
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Extract is a function that accepts a result and extracts a router.
 | 
			
		||||
func (r commonResult) Extract() (*Router, error) {
 | 
			
		||||
	if r.Err != nil {
 | 
			
		||||
		return nil, r.Err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var res struct {
 | 
			
		||||
		Router *Router `json:"router"`
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	err := mapstructure.Decode(r.Body, &res)
 | 
			
		||||
 | 
			
		||||
	return res.Router, err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CreateResult represents the result of a create operation.
 | 
			
		||||
type CreateResult struct {
 | 
			
		||||
	commonResult
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetResult represents the result of a get operation.
 | 
			
		||||
type GetResult struct {
 | 
			
		||||
	commonResult
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// UpdateResult represents the result of an update operation.
 | 
			
		||||
type UpdateResult struct {
 | 
			
		||||
	commonResult
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// DeleteResult represents the result of a delete operation.
 | 
			
		||||
type DeleteResult struct {
 | 
			
		||||
	gophercloud.ErrResult
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// InterfaceInfo represents information about a particular router interface. As
 | 
			
		||||
// mentioned above, in order for a router to forward to a subnet, it needs an
 | 
			
		||||
// interface.
 | 
			
		||||
type InterfaceInfo struct {
 | 
			
		||||
	// The ID of the subnet which this interface is associated with.
 | 
			
		||||
	SubnetID string `json:"subnet_id" mapstructure:"subnet_id"`
 | 
			
		||||
 | 
			
		||||
	// The ID of the port that is a part of the subnet.
 | 
			
		||||
	PortID string `json:"port_id" mapstructure:"port_id"`
 | 
			
		||||
 | 
			
		||||
	// The UUID of the interface.
 | 
			
		||||
	ID string `json:"id" mapstructure:"id"`
 | 
			
		||||
 | 
			
		||||
	// Owner of the interface.
 | 
			
		||||
	TenantID string `json:"tenant_id" mapstructure:"tenant_id"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// InterfaceResult represents the result of interface operations, such as
 | 
			
		||||
// AddInterface() and RemoveInterface().
 | 
			
		||||
type InterfaceResult struct {
 | 
			
		||||
	gophercloud.Result
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Extract is a function that accepts a result and extracts an information struct.
 | 
			
		||||
func (r InterfaceResult) Extract() (*InterfaceInfo, error) {
 | 
			
		||||
	if r.Err != nil {
 | 
			
		||||
		return nil, r.Err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var res *InterfaceInfo
 | 
			
		||||
	err := mapstructure.Decode(r.Body, &res)
 | 
			
		||||
 | 
			
		||||
	return res, err
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										21
									
								
								vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/layer3/routers/urls.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/layer3/routers/urls.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,21 @@
 | 
			
		||||
package routers
 | 
			
		||||
 | 
			
		||||
import "github.com/rackspace/gophercloud"
 | 
			
		||||
 | 
			
		||||
const resourcePath = "routers"
 | 
			
		||||
 | 
			
		||||
func rootURL(c *gophercloud.ServiceClient) string {
 | 
			
		||||
	return c.ServiceURL(resourcePath)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func resourceURL(c *gophercloud.ServiceClient, id string) string {
 | 
			
		||||
	return c.ServiceURL(resourcePath, id)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func addInterfaceURL(c *gophercloud.ServiceClient, id string) string {
 | 
			
		||||
	return c.ServiceURL(resourcePath, id, "add_router_interface")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func removeInterfaceURL(c *gophercloud.ServiceClient, id string) string {
 | 
			
		||||
	return c.ServiceURL(resourcePath, id, "remove_router_interface")
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user