LoadBalancer Base API

class libcloud.loadbalancer.base.Driver(key, secret=None, secure=True, host=None, port=None, **kwargs)[source]

A base Driver class to derive from

This class is always subclassed by a specific driver.

Parameters:
  • key (str) – API key or username to be used (required)

  • secret (str) – Secret password to be used (required)

  • secure (bool) – Whether to use HTTPS or HTTP. Note: Some providers only support HTTPS, and it is on by default.

  • host (str) – Override hostname used for connections.

  • port (int) – Override port used for connections.

  • api_version (str) – Optional API version. Only used by drivers which support multiple API versions.

  • region (str) – Optional driver region. Only used by drivers which support multiple regions.

Return type:

None

balancer_attach_compute_node(balancer, node)[source]

Attach a compute node as a member to the load balancer.

Parameters:
  • balancer (LoadBalancer) – LoadBalancer which should be used

  • node (Node) – Node to join to the balancer

Returns:

Member after joining the balancer.

Return type:

Member

balancer_attach_member(balancer, member)[source]

Attach a member to balancer

Parameters:
  • balancer (LoadBalancer) – LoadBalancer which should be used

  • member (Member) – Member to join to the balancer

Returns:

Member after joining the balancer.

Return type:

Member

balancer_detach_member(balancer, member)[source]

Detach member from balancer

Parameters:
  • balancer (LoadBalancer) – LoadBalancer which should be used

  • member (Member) – Member which should be used

Returns:

True if member detach was successful, otherwise False.

Return type:

bool

balancer_list_members(balancer)[source]

Return list of members attached to balancer

Parameters:

balancer (LoadBalancer) – LoadBalancer which should be used

Return type:

list of Member

connectionCls

alias of ConnectionKey

create_balancer(name, port, protocol, algorithm, members)[source]

Create a new load balancer instance

Parameters:
  • name (str) – Name of the new load balancer (required)

  • port (str) – Port the load balancer should listen on, defaults to 80

  • protocol (str) – Loadbalancer protocol, defaults to http.

  • members (list of Member) – list of Members to attach to balancer

  • algorithm (Algorithm) – Load balancing algorithm, defaults to ROUND_ROBIN.

Return type:

LoadBalancer

destroy_balancer(balancer)[source]

Destroy a load balancer

Parameters:

balancer (LoadBalancer) – LoadBalancer which should be used

Returns:

True if the destroy was successful, otherwise False.

Return type:

bool

get_balancer(balancer_id)[source]

Return a LoadBalancer object.

Parameters:

balancer_id (str) – id of a load balancer you want to fetch

Return type:

LoadBalancer

list_balancers()[source]

List all loadbalancers

Return type:

list of LoadBalancer

list_protocols()[source]

Return a list of supported protocols.

Return type:

list of str

list_supported_algorithms()[source]

Return algorithms supported by this driver.

Return type:

list of str

update_balancer(balancer, **kwargs)[source]

Sets the name, algorithm, protocol, or port on a load balancer.

Parameters:
  • balancer (LoadBalancer) – LoadBalancer which should be used

  • name (str) – New load balancer name

  • algorithm (Algorithm) – New load balancer algorithm

  • protocol (str) – New load balancer protocol

  • port (int) – New load balancer port

Return type:

LoadBalancer

class libcloud.loadbalancer.base.LoadBalancer(id, name, state, ip, port, driver, extra=None)[source]

Provide a common interface for handling Load Balancers.

Parameters:
  • id (str) – Load balancer ID.

  • name (str) – Load balancer name.

  • state (libcloud.loadbalancer.types.State) – State this loadbalancer is in.

  • ip (str) – IP address of this loadbalancer.

  • port (int) – Port of this loadbalancer.

  • driver (Driver) – Driver this loadbalancer belongs to.

  • extra (dict) – Provider specific attributes. (optional)

class libcloud.loadbalancer.base.Member(id, ip, port, balancer=None, extra=None)[source]

Represents a load balancer member.

Parameters:
  • id (str) – Member ID.

  • ip – IP address of this member.

  • ipstr

  • port – Port of this member

  • portstr

  • balancer – Balancer this member is attached to. (optional)

  • balancerLoadBalancer

  • extra (dict) – Provider specific attributes.

class libcloud.loadbalancer.base.Algorithm[source]

Represents a load balancing algorithm.

class libcloud.loadbalancer.types.State[source]

Standard states for a loadbalancer

Variables:
  • RUNNING – loadbalancer is running and ready to use

  • UNKNOWN – loabalancer state is unknown

class libcloud.loadbalancer.types.MemberCondition[source]

Each member of a load balancer can have an associated condition which determines its role within the load balancer.