Documentation
¶
Overview ¶
Package pools provides information and interaction with Pools and Members of the LBaaS v2 extension for the OpenStack Networking service.
Example to List Pools
listOpts := pools.ListOpts{ LoadbalancerID: "c79a4468-d788-410c-bf79-9a8ef6354852", } allPages, err := pools.List(networkClient, listOpts).AllPages() if err != nil { panic(err) } allPools, err := pools.ExtractMonitors(allPages) if err != nil { panic(err) } for _, pools := range allPools { fmt.Printf("%+v\n", pool) }
Example to Create a Pool
createOpts := pools.CreateOpts{ LBMethod: pools.LBMethodRoundRobin, Protocol: "HTTP", Name: "Example pool", Tags: []string{"test"}, LoadbalancerID: "79e05663-7f03-45d2-a092-8b94062f22ab", } pool, err := pools.Create(networkClient, createOpts).Extract() if err != nil { panic(err) }
Example to Update a Pool
poolID := "d67d56a6-4a86-4688-a282-f46444705c64" newTags := []string{"prod"} updateOpts := pools.UpdateOpts{ Name: "new-name", Tags: &newTags, } pool, err := pools.Update(networkClient, poolID, updateOpts).Extract() if err != nil { panic(err) }
Example to Delete a Pool
poolID := "d67d56a6-4a86-4688-a282-f46444705c64" err := pools.Delete(networkClient, poolID).ExtractErr() if err != nil { panic(err) }
Example to List Pool Members
poolID := "d67d56a6-4a86-4688-a282-f46444705c64" listOpts := pools.ListMemberOpts{ ProtocolPort: 80, } allPages, err := pools.ListMembers(networkClient, poolID, listOpts).AllPages() if err != nil { panic(err) } allMembers, err := pools.ExtractMembers(allPages) if err != nil { panic(err) } for _, member := allMembers { fmt.Printf("%+v\n", member) }
Example to Create a Member
poolID := "d67d56a6-4a86-4688-a282-f46444705c64" weight := 10 createOpts := pools.CreateMemberOpts{ Name: "db", SubnetID: "1981f108-3c48-48d2-b908-30f7d28532c9", Address: "10.0.2.11", ProtocolPort: 80, Weight: &weight, } member, err := pools.CreateMember(networkClient, poolID, createOpts).Extract() if err != nil { panic(err) }
Example to Update a Member
poolID := "d67d56a6-4a86-4688-a282-f46444705c64" memberID := "64dba99f-8af8-4200-8882-e32a0660f23e" weight := 4 updateOpts := pools.UpdateMemberOpts{ Name: "new-name", Weight: &weight, } member, err := pools.UpdateMember(networkClient, poolID, memberID, updateOpts).Extract() if err != nil { panic(err) }
Example to Delete a Member
poolID := "d67d56a6-4a86-4688-a282-f46444705c64" memberID := "64dba99f-8af8-4200-8882-e32a0660f23e" err := pools.DeleteMember(networkClient, poolID, memberID).ExtractErr() if err != nil { panic(err) }
Example to Update Members:
poolID := "d67d56a6-4a86-4688-a282-f46444705c64" weight_1 := 20 member1 := pools.BatchUpdateMemberOpts{ Address: "192.0.2.16", ProtocolPort: 80, Name: "web-server-1", SubnetID: "bbb35f84-35cc-4b2f-84c2-a6a29bba68aa", Weight: &weight_1, } weight_2 := 10 member2 := pools.BatchUpdateMemberOpts{ Address: "192.0.2.17", ProtocolPort: 80, Name: "web-server-2", Weight: &weight_2, SubnetID: "bbb35f84-35cc-4b2f-84c2-a6a29bba68aa", } members := []pools.BatchUpdateMemberOpts{member1, member2} err := pools.BatchUpdateMembers(networkClient, poolID, members).ExtractErr() if err != nil { panic(err) }
Index ¶
- Constants
- func List(c *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
- func ListMembers(c *gophercloud.ServiceClient, poolID string, opts ListMembersOptsBuilder) pagination.Pager
- type BatchUpdateMemberOpts
- type BatchUpdateMemberOptsBuilder
- type CreateMemberOpts
- type CreateMemberOptsBuilder
- type CreateMemberResult
- type CreateOpts
- type CreateOptsBuilder
- type CreateResult
- type DeleteMemberResult
- type DeleteResult
- type GetMemberResult
- type GetResult
- type LBMethod
- type ListMembersOpts
- type ListMembersOptsBuilder
- type ListOpts
- type ListOptsBuilder
- type ListenerID
- type LoadBalancerID
- type Member
- type MemberPage
- type Pool
- type PoolPage
- type Protocol
- type SessionPersistence
- type UpdateMemberOpts
- type UpdateMemberOptsBuilder
- type UpdateMemberResult
- type UpdateMembersResult
- type UpdateOpts
- type UpdateOptsBuilder
- type UpdateResult
Constants ¶
const ( LBMethodRoundRobin LBMethod = "ROUND_ROBIN" LBMethodLeastConnections LBMethod = "LEAST_CONNECTIONS" LBMethodSourceIp LBMethod = "SOURCE_IP" ProtocolTCP Protocol = "TCP" ProtocolUDP Protocol = "UDP" ProtocolPROXY Protocol = "PROXY" ProtocolHTTP Protocol = "HTTP" ProtocolHTTPS Protocol = "HTTPS" // Protocol PROXYV2 requires octavia microversion 2.22 ProtocolPROXYV2 Protocol = "PROXYV2" // Protocol SCTP requires octavia microversion 2.23 ProtocolSCTP Protocol = "SCTP" )
Supported attributes for create/update operations.
Variables ¶
This section is empty.
Functions ¶
func List ¶
func List(c *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
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 project who submits the request, unless an admin user submits the request.
func ListMembers ¶
func ListMembers(c *gophercloud.ServiceClient, poolID string, opts ListMembersOptsBuilder) pagination.Pager
ListMembers returns a Pager which allows you to iterate over a collection of members. It accepts a ListMembersOptsBuilder, which allows you to filter and sort the returned collection for greater efficiency.
Default policy settings return only those members that are owned by the project who submits the request, unless an admin user submits the request.
Types ¶
type BatchUpdateMemberOpts ¶
type BatchUpdateMemberOpts struct { // The IP address of the member to receive traffic from the load balancer. Address string `json:"address" required:"true"` // The port on which to listen for client traffic. ProtocolPort int `json:"protocol_port" required:"true"` // Name of the Member. Name *string `json:"name,omitempty"` // ProjectID is the UUID of the project who owns the Member. // Only administrative users can specify a project UUID other than their own. ProjectID string `json:"project_id,omitempty"` // A positive integer value that indicates the relative portion of traffic // that this member should receive from the pool. For example, a member with // a weight of 10 receives five times as much traffic as a member with a // weight of 2. Weight *int `json:"weight,omitempty"` // If you omit this parameter, LBaaS uses the vip_subnet_id parameter value // for the subnet UUID. SubnetID *string `json:"subnet_id,omitempty"` // The administrative state of the Pool. A valid value is true (UP) // or false (DOWN). AdminStateUp *bool `json:"admin_state_up,omitempty"` // Is the member a backup? Backup members only receive traffic when all // non-backup members are down. // Requires microversion 2.1 or later. Backup *bool `json:"backup,omitempty"` // An alternate IP address used for health monitoring a backend member. MonitorAddress *string `json:"monitor_address,omitempty"` // An alternate protocol port used for health monitoring a backend member. MonitorPort *int `json:"monitor_port,omitempty"` // A list of simple strings assigned to the resource. // Requires microversion 2.5 or later. Tags []string `json:"tags,omitempty"` }
BatchUpdateMemberOpts is the common options struct used in this package's BatchUpdateMembers operation.
func (BatchUpdateMemberOpts) ToBatchMemberUpdateMap ¶
func (opts BatchUpdateMemberOpts) ToBatchMemberUpdateMap() (map[string]interface{}, error)
ToBatchMemberUpdateMap builds a request body from BatchUpdateMemberOpts.
type BatchUpdateMemberOptsBuilder ¶
type BatchUpdateMemberOptsBuilder interface {
ToBatchMemberUpdateMap() (map[string]interface{}, error)
}
BatchUpdateMemberOptsBuilder allows extensions to add additional parameters to the BatchUpdateMembers request.
type CreateMemberOpts ¶
type CreateMemberOpts struct { // A positive integer value that indicates the relative portion of traffic // that this member should receive from the pool. For example, a member with // a weight of 10 receives five times as much traffic as a member with a // weight of 2. Weight int `json:"weight,omitempty"` // The administrative state of the Pool. A valid value is true (UP) // or false (DOWN). AdminStateUp bool `json:"admin_state_up,omitempty"` // If you omit this parameter, LBaaS uses the vip_subnet_id parameter value // for the subnet UUID. SubnetID string `json:"subnet_id" required:"true"` // The IP address of the member to receive traffic from the load balancer. Address string `json:"address" required:"true"` // The port on which to listen for client traffic. ProtocolPort int `json:"protocol_port" required:"true"` }
CreateMemberOpts is the common options struct used in this package's CreateMember operation.
func (CreateMemberOpts) ToMemberCreateMap ¶
func (opts CreateMemberOpts) ToMemberCreateMap() (map[string]interface{}, error)
ToMemberCreateMap builds a request body from CreateMemberOpts.
type CreateMemberOptsBuilder ¶
CreateMemberOptsBuilder allows extensions to add additional parameters to the CreateMember request.
type CreateMemberResult ¶
type CreateMemberResult struct {
// contains filtered or unexported fields
}
CreateMemberResult represents the result of a CreateMember operation. Call its Extract method to interpret it as a Member.
func CreateMember ¶
func CreateMember(c *gophercloud.ServiceClient, poolID string, opts CreateMemberOptsBuilder) (r CreateMemberResult)
CreateMember will create and associate a Member with a particular Pool.
type CreateOpts ¶
type CreateOpts struct { // The Listener on which the members of the pool will be associated with. // Note: one of LoadbalancerID or ListenerID must be provided. ListenerID string `json:"listener_id" required:"true"` // The algorithm used to distribute load between the members of the pool. The // current specification supports LBMethodRoundRobin, LBMethodLeastConnections // and LBMethodSourceIp as valid values for this attribute. LBMethod LBMethod `json:"lb_algorithm" required:"true"` // The protocol used by the pool members, you can use either // ProtocolTCP, ProtocolUDP, ProtocolPROXY, ProtocolHTTP, ProtocolHTTPS, // ProtocolSCTP or ProtocolPROXYV2. Protocol Protocol `json:"protocol" required:"true"` // Human-readable description for the pool. Description string `json:"description,omitempty"` // The administrative state of the Pool. A valid value is true (UP) // or false (DOWN). AdminStateUp bool `json:"admin_state_up,omitempty"` // Member's port for receiving. Deliver traffic to this port. The default value is -1. MemberPort int `json:"member_port,omitempty"` // Added // Persistence is the session persistence of the pool. // Omit this field to prevent session persistence. Persistence *SessionPersistence `json:"session_persistence,omitempty"` // Name of the pool. Name string `json:"name,omitempty"` }
CreateOpts is the common options struct used in this package's Create operation.
func (CreateOpts) ToPoolCreateMap ¶
func (opts CreateOpts) ToPoolCreateMap() (map[string]interface{}, error)
ToPoolCreateMap builds a request body from CreateOpts.
type CreateOptsBuilder ¶
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 the result as a Pool.
func Create ¶
func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult)
Create accepts a CreateOpts struct and uses the values to create a new load balancer pool.
type DeleteMemberResult ¶
type DeleteMemberResult struct {
gophercloud.ErrResult
}
DeleteMemberResult represents the result of a DeleteMember operation. Call its ExtractErr method to determine if the request succeeded or failed.
func DeleteMember ¶
func DeleteMember(c *gophercloud.ServiceClient, poolID string, memberID string) (r DeleteMemberResult)
DeleteMember will remove and disassociate a Member from a particular Pool.
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 pool based on its unique ID.
type GetMemberResult ¶
type GetMemberResult struct {
// contains filtered or unexported fields
}
GetMemberResult represents the result of a GetMember operation. Call its Extract method to interpret it as a Member.
func GetMember ¶
func GetMember(c *gophercloud.ServiceClient, poolID string, memberID string) (r GetMemberResult)
GetMember retrieves a particular Pool Member 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 the result as a Pool.
type ListMembersOpts ¶
type ListMembersOpts struct { ID string `q:"id"` Weight int `q:"weight"` AdminStateUp *bool `q:"admin_state_up"` SubnetID string `q:"subnet_id"` // Added TenantID string `q:"tenant_id"` // Added Address string `q:"address"` ProtocolPort int `q:"protocol_port"` OperatingStatus string `q:"operating_status "` // Added }
ListMembersOpts allows the filtering and sorting of paginated collections through the API. Filtering is achieved by passing in struct field values that map to the Member attributes you want to see returned. SortKey allows you to sort by a particular Member attribute. SortDir sets the direction, and is either `asc' or `desc'. Marker and Limit are used for pagination.
func (ListMembersOpts) ToMembersListQuery ¶
func (opts ListMembersOpts) ToMembersListQuery() (string, error)
ToMemberListQuery formats a ListOpts into a query string.
type ListMembersOptsBuilder ¶
ListMemberOptsBuilder allows extensions to add additional parameters to the ListMembers request.
type ListOpts ¶
type ListOpts struct { ID string `q:"id"` Name string `q:"name"` LBMethod string `q:"lb_algorithm"` Protocol string `q:"protocol"` AdminStateUp bool `q:"admin_state_up"` MonitorID string `q:"healthmonitor_id"` // Added }
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 Pool attributes you want to see returned. SortKey allows you to sort by a particular Pool attribute. SortDir sets the direction, and is either `asc' or `desc'. Marker and Limit are used for pagination.
func (ListOpts) ToPoolListQuery ¶
ToPoolListQuery formats a ListOpts into a query string.
type ListOptsBuilder ¶
ListOptsBuilder allows extensions to add additional parameters to the List request.
type ListenerID ¶
type ListenerID struct {
ID string `json:"id"`
}
ListenerID represents a listener.
type LoadBalancerID ¶
type LoadBalancerID struct {
ID string `json:"id"`
}
LoadBalancerID represents a load balancer.
type Member ¶
type Member struct { // Weight of Member. Weight int `json:"weight"` // The administrative state of the member, which is up (true) or down (false). AdminStateUp bool `json:"admin_state_up"` // Parameter value for the subnet UUID. SubnetID string `json:"subnet_id"` // Owner of the Pool. TenantID string `json:"tenant_id"` // Added // The IP address of the Member. Address string `json:"address"` // The port on which the application is hosted. ProtocolPort int `json:"protocol_port"` // The unique ID for the Member. ID string `json:"id"` // The operating status of the member OperatingStatus string `json:"operating_status"` }
Member represents the application running on a backend server.
func ExtractMembers ¶
func ExtractMembers(r pagination.Page) ([]Member, error)
ExtractMembers accepts a Page struct, specifically a MemberPage struct, and extracts the elements into a slice of Members structs. In other words, a generic collection is mapped into a relevant slice.
func (*Member) UnmarshalJSON ¶
type MemberPage ¶
type MemberPage struct {
pagination.LinkedPageBase
}
MemberPage is the page returned by a pager when traversing over a collection of Members in a Pool.
func (MemberPage) IsEmpty ¶
func (r MemberPage) IsEmpty() (bool, error)
IsEmpty checks whether a MemberPage struct is empty.
func (MemberPage) NextPageURL ¶
func (r MemberPage) NextPageURL() (string, error)
NextPageURL is invoked when a paginated collection of members 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 Pool ¶
type Pool struct { // The load-balancer algorithm, which is round-robin, least-connections, and // so on. This value, which must be supported, is dependent on the provider. // Round-robin must be supported. LBMethod string `json:"lb_algorithm"` // The protocol of the Pool, which is TCP, HTTP, or HTTPS. Protocol string `json:"protocol"` // Description for the Pool. Description string `json:"description"` // The administrative state of the Pool, which is up (true) or down (false). AdminStateUp bool `json:"admin_state_up"` // Owner of the Pool. TenantID string `json:"tenant_id"` // Added // Member's port for receiving. Deliver traffic to this port. The default value is -1. MemberPort int `json:"member_port"` // Added Not Exits on API Manual. // Indicates whether connections in the same session will be processed by the // same Pool member or not. Persistence *SessionPersistence `json:"session_persistence"` // The ID of associated health monitor. MonitorID string `json:"healthmonitor_id"` // A list of listeners objects IDs. Listeners []ListenerID `json:"listeners"` //[]map[string]interface{} // A list of member objects IDs. Members []Member `json:"members"` // The unique ID for the Pool. ID string `json:"id"` // Pool name. Does not have to be unique. Name string `json:"name"` }
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.
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 Pool 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) NextPageURL ¶
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 SessionPersistence ¶
type SessionPersistence struct { // The type of persistence mode. Type string `json:"type"` // 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 UpdateMemberOpts ¶
type UpdateMemberOpts struct { // A positive integer value that indicates the relative portion of traffic // that this member should receive from the pool. For example, a member with // a weight of 10 receives five times as much traffic as a member with a // weight of 2. Weight *int `json:"weight,omitempty"` // The administrative state of the Pool. A valid value is true (UP) // or false (DOWN). AdminStateUp *bool `json:"admin_state_up,omitempty"` }
UpdateMemberOpts is the common options struct used in this package's Update operation.
func (UpdateMemberOpts) ToMemberUpdateMap ¶
func (opts UpdateMemberOpts) ToMemberUpdateMap() (map[string]interface{}, error)
ToMemberUpdateMap builds a request body from UpdateMemberOpts.
type UpdateMemberOptsBuilder ¶
UpdateMemberOptsBuilder allows extensions to add additional parameters to the List request.
type UpdateMemberResult ¶
type UpdateMemberResult struct {
// contains filtered or unexported fields
}
UpdateMemberResult represents the result of an UpdateMember operation. Call its Extract method to interpret it as a Member.
func UpdateMember ¶
func UpdateMember(c *gophercloud.ServiceClient, poolID string, memberID string, opts UpdateMemberOptsBuilder) (r UpdateMemberResult)
Update allows Member to be updated.
type UpdateMembersResult ¶
type UpdateMembersResult struct {
gophercloud.ErrResult
}
UpdateMembersResult represents the result of an UpdateMembers operation. Call its ExtractErr method to determine if the request succeeded or failed.
func BatchUpdateMembers ¶
func BatchUpdateMembers(c *gophercloud.ServiceClient, poolID string, opts []BatchUpdateMemberOpts) (r UpdateMembersResult)
BatchUpdateMembers updates the pool members in batch
type UpdateOpts ¶
type UpdateOpts struct { // The algorithm used to distribute load between the members of the pool. The // current specification supports LBMethodRoundRobin, LBMethodLeastConnections // and LBMethodSourceIp as valid values for this attribute. LBMethod LBMethod `json:"lb_algorithm,omitempty"` // Human-readable description for the pool. Description *string `json:"description,omitempty"` // The administrative state of the Pool. A valid value is true (UP) // or false (DOWN). AdminStateUp *bool `json:"admin_state_up,omitempty"` // Persistence is the session persistence of the pool. // Omit this field to prevent session persistence. Persistence *SessionPersistence `json:"session_persistence,omitempty"` // Added // Name of the pool. Name *string `json:"name,omitempty"` }
UpdateOpts is the common options struct used in this package's Update operation.
func (UpdateOpts) ToPoolUpdateMap ¶
func (opts UpdateOpts) ToPoolUpdateMap() (map[string]interface{}, error)
ToPoolUpdateMap builds a request body from UpdateOpts.
type UpdateOptsBuilder ¶
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 the result as a Pool.
func Update ¶
func Update(c *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult)
Update allows pools to be updated.