pools

package
v0.0.0-...-8db8df1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2017 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package pools provides information and interaction with the Pools of the Load Balancing as a Service extension for the OpenStack Networking service.

Example to List Pools

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

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

allPools, err := pools.ExtractPools(allPages)
if err != nil {
	panic(err)
}

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

Example to Create a Pool

createOpts := pools.CreateOpts{
	LBMethod: pools.LBMethodRoundRobin,
	Protocol: "HTTP",
	Name:     "Example pool",
	SubnetID: "1981f108-3c48-48d2-b908-30f7d28532c9",
	Provider: "haproxy",
}

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

Example to Update a Pool

poolID := "166db5e6-c72a-4d77-8776-3573e27ae271"

updateOpts := pools.UpdateOpts{
	LBMethod: pools.LBMethodLeastConnections,
}

pool, err := pools.Update(networkClient, poolID, updateOpts).Extract()
if err != nil {
	panic(err)
}

Example to Delete a Pool

poolID := "166db5e6-c72a-4d77-8776-3573e27ae271"
err := pools.Delete(networkClient, poolID).ExtractErr()
if err != nil {
	panic(err)
}

Example to Associate a Monitor to a Pool

poolID := "166db5e6-c72a-4d77-8776-3573e27ae271"
monitorID := "8bbfbe1c-6faa-4d97-abdb-0df6c90df70b"

pool, err := pools.AssociateMonitor(networkClient, poolID, monitorID).Extract()
if err != nil {
	panic(err)
}

Example to Disassociate a Monitor from a Pool

poolID := "166db5e6-c72a-4d77-8776-3573e27ae271"
monitorID := "8bbfbe1c-6faa-4d97-abdb-0df6c90df70b"

pool, err := pools.DisassociateMonitor(networkClient, poolID, monitorID).Extract()
if err != nil {
	panic(err)
}

Index

Constants

View Source
const (
	LBMethodRoundRobin       LBMethod = "ROUND_ROBIN"
	LBMethodLeastConnections LBMethod = "LEAST_CONNECTIONS"

	ProtocolTCP   LBProtocol = "TCP"
	ProtocolHTTP  LBProtocol = "HTTP"
	ProtocolHTTPS LBProtocol = "HTTPS"
)

Supported attributes for create/update operations.

Variables

This section is empty.

Functions

func List

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

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

Types

type AssociateResult

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

AssociateResult represents the result of an association operation. Call its Extract method to interpret it as a Pool.

func AssociateMonitor

func AssociateMonitor(c *gophercloud.ServiceClient, poolID, monitorID string) (r AssociateResult)

AssociateMonitor will associate a health monitor with a particular pool. Once associated, the health monitor will start monitoring the members of the pool and will deactivate these members if they are deemed unhealthy. A member can be deactivated (status set to INACTIVE) if any of health monitors finds it unhealthy.

func DisassociateMonitor

func DisassociateMonitor(c *gophercloud.ServiceClient, poolID, monitorID string) (r AssociateResult)

DisassociateMonitor will disassociate a health monitor with a particular pool. When dissociation is successful, the health monitor will no longer check for the health of the members of the pool.

func (AssociateResult) Extract

func (r AssociateResult) Extract() (*Pool, error)

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

type CreateOpts

type CreateOpts struct {
	// Name of the pool.
	Name string `json:"name" required:"true"`

	// Protocol used by the pool members, you can use either
	// ProtocolTCP, ProtocolHTTP, or ProtocolHTTPS.
	Protocol LBProtocol `json:"protocol" 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"`

	// SubnetID is the network on which the members of the pool will be located.
	// Only members that are on this network can be added to the pool.
	SubnetID string `json:"subnet_id,omitempty"`

	// LBMethod is the algorithm used to distribute load between the members of
	// the pool. The current specification supports LBMethodRoundRobin and
	// LBMethodLeastConnections as valid values for this attribute.
	LBMethod LBMethod `json:"lb_method" required:"true"`

	// Provider of the pool.
	Provider string `json:"provider,omitempty"`
}

CreateOpts contains all the values needed to create a new pool.

func (CreateOpts) ToLBPoolCreateMap

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

ToLBPoolCreateMap builds a request body based on CreateOpts.

type CreateOptsBuilder

type CreateOptsBuilder interface {
	ToLBPoolCreateMap() (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 Pool.

func Create

Create accepts a CreateOptsBuilder and uses the values to create a new load balancer pool.

func (CreateResult) Extract

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

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

type DeleteResult

type DeleteResult struct {
	gophercloud.ErrResult
}

DeleteResult represents the result of a delete operation. Call its ExtractErr method to interpret it as a Pool.

func Delete

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

Delete will permanently delete a particular pool 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 Pool.

func Get

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

Get retrieves a particular pool based on its unique ID.

func (GetResult) Extract

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

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

type LBMethod

type LBMethod string

LBMethod is a type used for possible load balancing methods.

type LBProtocol

type LBProtocol string

LBProtocol is a type used for possible load balancing protocols.

type ListOpts

type ListOpts struct {
	Status       string `q:"status"`
	LBMethod     string `q:"lb_method"`
	Protocol     string `q:"protocol"`
	SubnetID     string `q:"subnet_id"`
	TenantID     string `q:"tenant_id"`
	AdminStateUp *bool  `q:"admin_state_up"`
	Name         string `q:"name"`
	ID           string `q:"id"`
	VIPID        string `q:"vip_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 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 Pool

type Pool struct {
	// Status of the pool. Indicates whether the pool is operational.
	Status string

	// LBMethod is the load-balancer algorithm, which is round-robin,
	// least-connections, and so on. This value, which must be supported, is
	// dependent on the provider.
	LBMethod string `json:"lb_method"`

	// Protocol of the pool, which is TCP, HTTP, or HTTPS.
	Protocol string

	// Description for the pool.
	Description string

	// MonitorIDs are the IDs of associated monitors which check the health of
	// the pool members.
	MonitorIDs []string `json:"health_monitors"`

	// SubnetID is the network on which the members of the pool will be located.
	// Only members that are on this network can be added to the pool.
	SubnetID string `json:"subnet_id"`

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

	// AdminStateUp is the administrative state of the pool, which is up
	// (true) or down (false).
	AdminStateUp bool `json:"admin_state_up"`

	// Name of the pool.
	Name string

	// MemberIDs is the list of member IDs that belong to the pool.
	MemberIDs []string `json:"members"`

	// ID is the unique ID for the pool.
	ID string

	// VIPID is the ID of the virtual IP associated with this pool.
	VIPID string `json:"vip_id"`

	// The provider.
	Provider string
}

Pool represents a logical set of devices, such as web servers, that you group together to receive and process traffic. The load balancing function chooses a member of the pool according to the configured load balancing method to handle the new requests or connections received on the VIP address. There is only one pool per virtual IP.

func ExtractPools

func ExtractPools(r pagination.Page) ([]Pool, error)

ExtractPools accepts a Page struct, specifically a PoolPage struct, and extracts the elements into a slice of Router structs. In other words, a generic collection is mapped into a relevant slice.

type PoolPage

type PoolPage struct {
	pagination.LinkedPageBase
}

PoolPage is the page returned by a pager when traversing over a collection of pools.

func (PoolPage) IsEmpty

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

IsEmpty checks whether a PoolPage struct is empty.

func (PoolPage) NextPageURL

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

NextPageURL is invoked when a paginated collection of pools 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 of the pool.
	Name string `json:"name,omitempty"`

	// LBMethod is the algorithm used to distribute load between the members of
	// the pool. The current specification supports LBMethodRoundRobin and
	// LBMethodLeastConnections as valid values for this attribute.
	LBMethod LBMethod `json:"lb_method,omitempty"`
}

UpdateOpts contains the values used when updating a pool.

func (UpdateOpts) ToLBPoolUpdateMap

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

ToLBPoolUpdateMap builds a request body based on UpdateOpts.

type UpdateOptsBuilder

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

UpdateOptsBuilder allows extensions to add additional parameters ot 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 Pool.

func Update

Update allows pools to be updated.

func (UpdateResult) Extract

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

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

Directories

Path Synopsis
pools unit tests
pools unit tests

Jump to

Keyboard shortcuts

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