vips

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2019 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package vips provides information and interaction with the Virtual IPs of the Load Balancing as a Service extension for the OpenStack Networking service.

Example to List Virtual IPs

listOpts := vips.ListOpts{
	SubnetID: "d9bd223b-f1a9-4f98-953b-df977b0f902d",
}

allPages, err := vips.List(networkClient, listOpts).AllPages()
if err != nil {
	panic(err)
}

allVIPs, err := vips.ExtractVIPs(allPages)
if err != nil {
	panic(err)
}

for _, vip := range allVIPs {
	fmt.Printf("%+v\n", vip)
}

Example to Create a Virtual IP

createOpts := vips.CreateOpts{
	Protocol:     "HTTP",
	Name:         "NewVip",
	AdminStateUp: gophercloud.Enabled,
	SubnetID:     "8032909d-47a1-4715-90af-5153ffe39861",
	PoolID:       "61b1f87a-7a21-4ad3-9dda-7f81d249944f",
	ProtocolPort: 80,
	Persistence:  &vips.SessionPersistence{Type: "SOURCE_IP"},
}

vip, err := vips.Create(networkClient, createOpts).Extract()
if err != nil {
	panic(err)
}

Example to Update a Virtual IP

vipID := "93f1bad4-0423-40a8-afac-3fc541839912"

i1000 := 1000
updateOpts := vips.UpdateOpts{
	ConnLimit:   &i1000,
	Persistence: &vips.SessionPersistence{Type: "SOURCE_IP"},
}

vip, err := vips.Update(networkClient, vipID, updateOpts).Extract()
if err != nil {
	panic(err)
}

Example to Delete a Virtual IP

vipID := "93f1bad4-0423-40a8-afac-3fc541839912"
err := vips.Delete(networkClient, vipID).ExtractErr()
if err != nil {
	panic(err)
}

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

Default policy settings return only those virtual IPs that are owned by the tenant who submits the request, unless an admin user submits the request.

Types

type CreateOpts

type CreateOpts struct {
	// Name is the human-readable name for the VIP. Does not have to be unique.
	Name string `json:"name" required:"true"`

	// SubnetID is the network on which to allocate the VIP's address. A tenant
	// can only create VIPs on networks authorized by policy (e.g. networks that
	// belong to them or networks that are shared).
	SubnetID string `json:"subnet_id" required:"true"`

	// Protocol - can either be TCP, HTTP or HTTPS.
	Protocol string `json:"protocol" required:"true"`

	// ProtocolPort is the port on which to listen for client traffic.
	ProtocolPort int `json:"protocol_port" required:"true"`

	// PoolID is the ID of the pool with which the VIP is associated.
	PoolID string `json:"pool_id" required:"true"`

	// TenantID is only required if the caller has an admin role and wants
	// to create a pool for another tenant.
	TenantID string `json:"tenant_id,omitempty"`

	// Address is the IP address of the VIP.
	Address string `json:"address,omitempty"`

	// Description is the human-readable description for the VIP.
	Description string `json:"description,omitempty"`

	// Persistence is the the of session persistence to use.
	// Omit this field to prevent session persistence.
	Persistence *SessionPersistence `json:"session_persistence,omitempty"`

	// ConnLimit is the maximum number of connections allowed for the VIP.
	ConnLimit *int `json:"connection_limit,omitempty"`

	// AdminStateUp is the administrative state of the VIP. A valid value is
	// true (UP) or false (DOWN).
	AdminStateUp *bool `json:"admin_state_up,omitempty"`
}

CreateOpts contains all the values needed to create a new virtual IP.

func (CreateOpts) ToVIPCreateMap

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

ToVIPCreateMap builds a request body from CreateOpts.

type CreateOptsBuilder

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

CreateOptsBuilder allows extensions to add additional parameters to the Create Request.

type CreateResult

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

CreateResult represents the result of a create operation. Call its Extract method to interpret it as a VirtualIP

func Create

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

Create is an operation which provisions a new virtual IP based on the configuration defined in the CreateOpts struct. Once the request is validated and progress has started on the provisioning process, a CreateResult will be returned.

Please note that the PoolID should refer to a pool that is not already associated with another vip. If the pool is already used by another vip, then the operation will fail with a 409 Conflict error will be returned.

Users with an admin role can create VIPs on behalf of other tenants by specifying a TenantID attribute different than their own.

func (CreateResult) Extract

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

Extract is a function that accepts a result and extracts a VirtualIP.

type DeleteResult

type DeleteResult struct {
	gophercloud.ErrResult
}

DeleteResult represents the result of a delete operation. Call its ExtractErr method to determine if the request succeeded or failed.

func Delete

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

Delete will permanently delete a particular virtual IP based on its unique ID.

type GetResult

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

GetResult represents the result of a get operation. Call its Extract method to interpret it as a VirtualIP

func Get

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

Get retrieves a particular virtual IP based on its unique ID.

func (GetResult) Extract

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

Extract is a function that accepts a result and extracts a VirtualIP.

type ListOpts

type ListOpts struct {
	ID              string `q:"id"`
	Name            string `q:"name"`
	AdminStateUp    *bool  `q:"admin_state_up"`
	Status          string `q:"status"`
	TenantID        string `q:"tenant_id"`
	SubnetID        string `q:"subnet_id"`
	Address         string `q:"address"`
	PortID          string `q:"port_id"`
	Protocol        string `q:"protocol"`
	ProtocolPort    int    `q:"protocol_port"`
	ConnectionLimit int    `q:"connection_limit"`
	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 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 SessionPersistence

type SessionPersistence struct {
	// Type is the type of persistence mode.
	Type string `json:"type"`

	// CookieName is the name of cookie if persistence mode is set appropriately.
	CookieName string `json:"cookie_name,omitempty"`
}

SessionPersistence represents the session persistence feature of the load balancing service. It attempts to force connections or requests in the same session to be processed by the same member as long as it is ative. Three types of persistence are supported:

SOURCE_IP: With this mode, all connections originating from the same source

IP address, will be handled by the same member of the pool.

HTTP_COOKIE: With this persistence mode, the load balancing function will

create a cookie on the first request from a client. Subsequent
requests containing the same cookie value will be handled by
the same member of the pool.

APP_COOKIE: With this persistence mode, the load balancing function will

rely on a cookie established by the backend application. All
requests carrying the same cookie value will be handled by the
same member of the pool.

type UpdateOpts

type UpdateOpts struct {
	// Name is the human-readable name for the VIP. Does not have to be unique.
	Name *string `json:"name,omitempty"`

	// PoolID is the ID of the pool with which the VIP is associated.
	PoolID *string `json:"pool_id,omitempty"`

	// Description is the human-readable description for the VIP.
	Description *string `json:"description,omitempty"`

	// Persistence is the the of session persistence to use.
	// Omit this field to prevent session persistence.
	Persistence *SessionPersistence `json:"session_persistence,omitempty"`

	// ConnLimit is the maximum number of connections allowed for the VIP.
	ConnLimit *int `json:"connection_limit,omitempty"`

	// AdminStateUp is the administrative state of the VIP. A valid value is
	// true (UP) or false (DOWN).
	AdminStateUp *bool `json:"admin_state_up,omitempty"`
}

UpdateOpts contains all the values needed to update an existing virtual IP. Attributes not listed here but appear in CreateOpts are immutable and cannot be updated.

func (UpdateOpts) ToVIPUpdateMap

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

ToVIPUpdateMap builds a request body based on UpdateOpts.

type UpdateOptsBuilder

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

UpdateOptsBuilder allows extensions to add additional parameters to the Update request.

type UpdateResult

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

UpdateResult represents the result of an update operation. Call its Extract method to interpret it as a VirtualIP

func Update

Update is an operation which modifies the attributes of the specified VIP.

func (UpdateResult) Extract

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

Extract is a function that accepts a result and extracts a VirtualIP.

type VIPPage

type VIPPage struct {
	pagination.LinkedPageBase
}

VIPPage is the page returned by a pager when traversing over a collection of virtual IPs.

func (VIPPage) IsEmpty

func (r VIPPage) IsEmpty() (bool, error)

IsEmpty checks whether a VIPPage struct is empty.

func (VIPPage) NextPageURL

func (r VIPPage) NextPageURL() (string, error)

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.

type VirtualIP

type VirtualIP struct {
	// ID is the unique ID for the VIP.
	ID string `json:"id"`

	// TenantID is the owner of the VIP.
	TenantID string `json:"tenant_id"`

	// Name is the human-readable name for the VIP. Does not have to be unique.
	Name string `json:"name"`

	// Description is the human-readable description for the VIP.
	Description string `json:"description"`

	// SubnetID is the ID of the subnet on which to allocate the VIP address.
	SubnetID string `json:"subnet_id"`

	// Address is the IP address of the VIP.
	Address string `json:"address"`

	// Protocol of the VIP address. A valid value is TCP, HTTP, or HTTPS.
	Protocol string `json:"protocol"`

	// ProtocolPort is the port on which to listen to client traffic that is
	// associated with the VIP address. A valid value is from 0 to 65535.
	ProtocolPort int `json:"protocol_port"`

	// PoolID is the ID of the pool with which the VIP is associated.
	PoolID string `json:"pool_id"`

	// PortID is the ID of the port which belongs to the load balancer.
	PortID string `json:"port_id"`

	// Persistence indicates whether connections in the same session will be
	// processed by the same pool member or not.
	Persistence SessionPersistence `json:"session_persistence"`

	// ConnLimit is the maximum number of connections allowed for the VIP.
	// Default is -1, meaning no limit.
	ConnLimit int `json:"connection_limit"`

	// AdminStateUp is the administrative state of the VIP. A valid value is
	// true (UP) or false (DOWN).
	AdminStateUp bool `json:"admin_state_up"`

	// Status is the status of the VIP. Indicates whether the VIP is operational.
	Status string `json:"status"`
}

VirtualIP is the primary load balancing configuration object that specifies the virtual IP address and port on which client traffic is received, as well as other details such as the load balancing method to be use, protocol, etc. This entity is sometimes known in LB products under the name of a "virtual server", a "vserver" or a "listener".

func ExtractVIPs

func ExtractVIPs(r pagination.Page) ([]VirtualIP, error)

ExtractVIPs accepts a Page struct, specifically a VIPPage struct, and extracts the elements into a slice of VirtualIP structs. In other words, a generic collection is mapped into a relevant slice.

Directories

Path Synopsis
vips unit tests
vips unit tests

Jump to

Keyboard shortcuts

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