gophercloud: github.com/rackspace/gophercloud/openstack/networking/v2/ports Index | Files

package ports

import "github.com/rackspace/gophercloud/openstack/networking/v2/ports"

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

Package Files

doc.go errors.go requests.go results.go urls.go

func ExtractPorts Uses

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.

func IDFromName Uses

func IDFromName(client *gophercloud.ServiceClient, name string) (string, error)

IDFromName is a convenience function that returns a port's ID given its name.

func List Uses

func List(c *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager

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.

type AddressPair Uses

type AddressPair struct {
    IPAddress  string `mapstructure:"ip_address" json:"ip_address,omitempty"`
    MACAddress string `mapstructure:"mac_address" json:"mac_address,omitempty"`
}

type AdminState Uses

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 Uses

type CreateOpts struct {
    NetworkID           string
    Name                string
    AdminStateUp        *bool
    MACAddress          string
    FixedIPs            interface{}
    DeviceID            string
    DeviceOwner         string
    TenantID            string
    SecurityGroups      []string
    AllowedAddressPairs []AddressPair
}

CreateOpts represents the attributes used when creating a new port.

func (CreateOpts) ToPortCreateMap Uses

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

ToPortCreateMap casts a CreateOpts struct to a map.

type CreateOptsBuilder Uses

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 Uses

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

CreateResult represents the result of a create operation.

func Create Uses

func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) CreateResult

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 Uses

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

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

type DeleteResult Uses

type DeleteResult struct {
    gophercloud.ErrResult
}

DeleteResult represents the result of a delete operation.

func Delete Uses

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

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

type GetResult Uses

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

GetResult represents the result of a get operation.

func Get Uses

func Get(c *gophercloud.ServiceClient, id string) GetResult

Get retrieves a specific port based on its unique ID.

func (GetResult) Extract Uses

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

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

type IP Uses

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 Uses

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 Uses

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

ToPortListQuery formats a ListOpts into a query string.

type ListOptsBuilder Uses

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

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

type Port Uses

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"`
    // Identifies the list of IP addresses the port will recognize/accept
    AllowedAddressPairs []AddressPair `mapstructure:"allowed_address_pairs" json:"allowed_address_pairs"`
}

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

type PortPage Uses

type PortPage struct {
    pagination.LinkedPageBase
}

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

func (PortPage) IsEmpty Uses

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

IsEmpty checks whether a PortPage struct is empty.

func (PortPage) NextPageURL Uses

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 Uses

type UpdateOpts struct {
    Name                string
    AdminStateUp        *bool
    FixedIPs            interface{}
    DeviceID            string
    DeviceOwner         string
    SecurityGroups      []string
    AllowedAddressPairs []AddressPair
}

UpdateOpts represents the attributes used when updating an existing port.

func (UpdateOpts) ToPortUpdateMap Uses

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

ToPortUpdateMap casts an UpdateOpts struct to a map.

type UpdateOptsBuilder Uses

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 Uses

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

UpdateResult represents the result of an update operation.

func Update Uses

func Update(c *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) UpdateResult

Update accepts a UpdateOpts struct and updates an existing port using the values provided.

func (UpdateResult) Extract Uses

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

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

Package ports imports 4 packages (graph) and is imported by 105 packages. Updated 2016-07-28. Refresh now. Tools for package owners.