networks

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2014 License: Apache-2.0 Imports: 4 Imported by: 936

Documentation

Overview

Package networks contains functionality for working with Neutron network resources. A network is an isolated virtual layer-2 broadcast domain that is typically reserved for the tenant who created it (unless you configure the network to be shared). Tenants can create multiple networks until the thresholds per-tenant quota is reached.

In the v2.0 Networking API, the network is the main entity. Ports and subnets are always associated with a network.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

List returns a Pager which allows you to iterate over a collection of networks. It accepts a ListOpts struct, which allows you to filter and sort the returned collection for greater efficiency.

Types

type AdminState

type AdminState *bool

AdminState gives users a solid type to work with for create and update operations. It is recommended that users use the `Up` and `Down` enums.

var (
	Up   AdminState = &iTrue
	Down AdminState = &iFalse
)

Convenience vars for AdminStateUp values.

type CreateOpts

type CreateOpts networkOpts

CreateOpts is the common options struct used in this package's Create operation.

func (CreateOpts) ToNetworkCreateMap

func (opts CreateOpts) ToNetworkCreateMap() (map[string]interface{}, error)

ToNetworkCreateMap casts a CreateOpts struct to a map.

type CreateOptsBuilder

type CreateOptsBuilder interface {
	ToNetworkCreateMap() (map[string]interface{}, error)
}

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 CreateResult

type CreateResult struct {
	// contains filtered or unexported fields
}

CreateResult represents the result of a create operation.

func Create

Create accepts a CreateOpts struct and creates a new network using the values provided. This operation does not actually require a request body, i.e. the CreateOpts struct argument can be empty.

The tenant ID that is contained in the URI is the tenant that creates the network. An admin user, however, has the option of specifying another tenant ID in the CreateOpts struct.

func (CreateResult) Extract

func (r CreateResult) Extract() (*Network, error)

Extract is a function that accepts a result and extracts a network resource.

type DeleteResult

type DeleteResult struct {
	gophercloud.ErrResult
}

DeleteResult represents the result of a delete operation.

func Delete

func Delete(c *gophercloud.ServiceClient, networkID string) DeleteResult

Delete accepts a unique ID and deletes the network associated with it.

type GetResult

type GetResult struct {
	// contains filtered or unexported fields
}

GetResult represents the result of a get operation.

func Get

Get retrieves a specific network based on its unique ID.

func (GetResult) Extract

func (r GetResult) Extract() (*Network, error)

Extract is a function that accepts a result and extracts a network resource.

type ListOpts

type ListOpts struct {
	Status       string `q:"status"`
	Name         string `q:"name"`
	AdminStateUp *bool  `q:"admin_state_up"`
	TenantID     string `q:"tenant_id"`
	Shared       *bool  `q:"shared"`
	ID           string `q:"id"`
	Marker       string `q:"marker"`
	Limit        int    `q:"limit"`
	SortKey      string `q:"sort_key"`
	SortDir      string `q:"sort_dir"`
}

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 network 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.

func (ListOpts) ToNetworkListQuery

func (opts ListOpts) ToNetworkListQuery() (string, error)

ToNetworkListQuery formats a ListOpts into a query string.

type ListOptsBuilder

type ListOptsBuilder interface {
	ToNetworkListQuery() (string, error)
}

ListOptsBuilder allows extensions to add additional parameters to the List request.

type Network

type Network struct {
	// UUID for the network
	ID string `mapstructure:"id" json:"id"`

	// Human-readable name for the network. Might not be unique.
	Name string `mapstructure:"name" json:"name"`

	// The administrative state of network. If false (down), the network does not forward packets.
	AdminStateUp bool `mapstructure:"admin_state_up" json:"admin_state_up"`

	// Indicates whether network is currently operational. Possible values include
	// `ACTIVE', `DOWN', `BUILD', or `ERROR'. Plug-ins might define additional values.
	Status string `mapstructure:"status" json:"status"`

	// Subnets associated with this network.
	Subnets []string `mapstructure:"subnets" json:"subnets"`

	// Owner of network. Only admin users can specify a tenant_id other than its own.
	TenantID string `mapstructure:"tenant_id" json:"tenant_id"`

	// Specifies whether the network resource can be accessed by any tenant or not.
	Shared bool `mapstructure:"shared" json:"shared"`
}

Network represents, well, a network.

func ExtractNetworks

func ExtractNetworks(page pagination.Page) ([]Network, error)

ExtractNetworks accepts a Page struct, specifically a NetworkPage struct, and extracts the elements into a slice of Network structs. In other words, a generic collection is mapped into a relevant slice.

type NetworkPage

type NetworkPage struct {
	pagination.LinkedPageBase
}

NetworkPage is the page returned by a pager when traversing over a collection of networks.

func (NetworkPage) IsEmpty

func (p NetworkPage) IsEmpty() (bool, error)

IsEmpty checks whether a NetworkPage struct is empty.

func (NetworkPage) NextPageURL

func (p NetworkPage) NextPageURL() (string, error)

NextPageURL is invoked when a paginated collection of networks 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.

type UpdateOpts

type UpdateOpts networkOpts

UpdateOpts is the common options struct used in this package's Update operation.

func (UpdateOpts) ToNetworkUpdateMap

func (opts UpdateOpts) ToNetworkUpdateMap() (map[string]interface{}, error)

ToNetworkUpdateMap casts a UpdateOpts struct to a map.

type UpdateOptsBuilder

type UpdateOptsBuilder interface {
	ToNetworkUpdateMap() (map[string]interface{}, error)
}

UpdateOptsBuilder is the interface options structs have to satisfy in order to be used in the main Update 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 UpdateResult

type UpdateResult struct {
	// contains filtered or unexported fields
}

UpdateResult represents the result of an update operation.

func Update

Update accepts a UpdateOpts struct and updates an existing network using the values provided. For more information, see the Create function.

func (UpdateResult) Extract

func (r UpdateResult) Extract() (*Network, error)

Extract is a function that accepts a result and extracts a network resource.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL