ports

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: 5 Imported by: 453

Documentation

Overview

Package ports contains functionality for working with Neutron port resources. A port represents a virtual switch port on a logical network switch. Virtual instances attach their interfaces into ports. The logical port also defines the MAC address and the IP address(es) to be assigned to the interfaces plugged into them. When IP addresses are associated to a port, this also implies the port is associated with a subnet, as the IP address was taken from the allocation pool for a specific subnet.

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 ports. It accepts a ListOpts struct, which allows you to filter and sort the returned collection for greater efficiency.

Default policy settings return only those ports that are owned by the tenant who submits the request, unless the request is submitted by a user with administrative rights.

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 struct {
	NetworkID      string
	Name           string
	AdminStateUp   *bool
	MACAddress     string
	FixedIPs       interface{}
	DeviceID       string
	DeviceOwner    string
	TenantID       string
	SecurityGroups []string
}

CreateOpts represents the attributes used when creating a new port.

func (CreateOpts) ToPortCreateMap

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

ToPortCreateMap casts a CreateOpts struct to a map.

type CreateOptsBuilder

type CreateOptsBuilder interface {
	ToPortCreateMap() (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. You must remember to provide a NetworkID value.

func (CreateResult) Extract

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

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

type DeleteResult

type DeleteResult struct {
	gophercloud.ErrResult
}

DeleteResult represents the result of a delete operation.

func Delete

Delete accepts a unique ID and deletes the port 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 port based on its unique ID.

func (GetResult) Extract

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

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

type IP

type IP struct {
	SubnetID  string `mapstructure:"subnet_id" json:"subnet_id"`
	IPAddress string `mapstructure:"ip_address" json:"ip_address,omitempty"`
}

IP is a sub-struct that represents an individual IP.

type ListOpts

type ListOpts struct {
	Status       string `q:"status"`
	Name         string `q:"name"`
	AdminStateUp *bool  `q:"admin_state_up"`
	NetworkID    string `q:"network_id"`
	TenantID     string `q:"tenant_id"`
	DeviceOwner  string `q:"device_owner"`
	MACAddress   string `q:"mac_address"`
	ID           string `q:"id"`
	DeviceID     string `q:"device_id"`
	Limit        int    `q:"limit"`
	Marker       string `q:"marker"`
	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 port attributes you want to see returned. SortKey allows you to sort by a particular port attribute. SortDir sets the direction, and is either `asc' or `desc'. Marker and Limit are used for pagination.

func (ListOpts) ToPortListQuery

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

ToPortListQuery formats a ListOpts into a query string.

type ListOptsBuilder

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

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

type Port

type Port struct {
	// UUID for the port.
	ID string `mapstructure:"id" json:"id"`
	// Network that this port is associated with.
	NetworkID string `mapstructure:"network_id" json:"network_id"`
	// Human-readable name for the port. Might not be unique.
	Name string `mapstructure:"name" json:"name"`
	// Administrative state of port. If false (down), port 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"`
	// Mac address to use on this port.
	MACAddress string `mapstructure:"mac_address" json:"mac_address"`
	// Specifies IP addresses for the port thus associating the port itself with
	// the subnets where the IP addresses are picked from
	FixedIPs []IP `mapstructure:"fixed_ips" json:"fixed_ips"`
	// Owner of network. Only admin users can specify a tenant_id other than its own.
	TenantID string `mapstructure:"tenant_id" json:"tenant_id"`
	// Identifies the entity (e.g.: dhcp agent) using this port.
	DeviceOwner string `mapstructure:"device_owner" json:"device_owner"`
	// Specifies the IDs of any security groups associated with a port.
	SecurityGroups []string `mapstructure:"security_groups" json:"security_groups"`
	// Identifies the device (e.g., virtual server) using this port.
	DeviceID string `mapstructure:"device_id" json:"device_id"`
}

Port represents a Neutron port. See package documentation for a top-level description of what this is.

func ExtractPorts

func ExtractPorts(page pagination.Page) ([]Port, error)

ExtractPorts accepts a Page struct, specifically a PortPage struct, and extracts the elements into a slice of Port structs. In other words, a generic collection is mapped into a relevant slice.

type PortPage

type PortPage struct {
	pagination.LinkedPageBase
}

PortPage is the page returned by a pager when traversing over a collection of network ports.

func (PortPage) IsEmpty

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

IsEmpty checks whether a PortPage struct is empty.

func (PortPage) NextPageURL

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

NextPageURL is invoked when a paginated collection of ports 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 struct {
	Name           string
	AdminStateUp   *bool
	FixedIPs       interface{}
	DeviceID       string
	DeviceOwner    string
	SecurityGroups []string
}

UpdateOpts represents the attributes used when updating an existing port.

func (UpdateOpts) ToPortUpdateMap

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

ToPortUpdateMap casts an UpdateOpts struct to a map.

type UpdateOptsBuilder

type UpdateOptsBuilder interface {
	ToPortUpdateMap() (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 port using the values provided.

func (UpdateResult) Extract

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

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

Jump to

Keyboard shortcuts

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