libcloud.loadbalancer.drivers package

Submodules

libcloud.loadbalancer.drivers.alb module

class libcloud.loadbalancer.drivers.alb.ApplicationLBDriver(access_id, secret, region, token=None)[source]

Bases: libcloud.loadbalancer.base.Driver

balancer_list_members(balancer)[source]
connectionCls

alias of ALBConnection

ex_balancer_list_listeners(balancer)[source]
get_balancer(balancer_id)[source]
list_balancers()[source]
list_protocols()[source]
name = 'Amazon Application Load Balancing'
signature_version = '4'
website = 'http://aws.amazon.com/elasticloadbalancing/'

libcloud.loadbalancer.drivers.brightbox module

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

Bases: libcloud.loadbalancer.base.Driver

LB_STATE_MAP = {'creating': 1, 'deleted': 2, 'failing': 2, 'failed': 2, 'active': 0, 'deleting': 2}
balancer_attach_compute_node(balancer, node)[source]
balancer_attach_member(balancer, member)[source]
balancer_detach_member(balancer, member)[source]
balancer_list_members(balancer)[source]
connectionCls

alias of BrightboxConnection

create_balancer(name, port, protocol, algorithm, members)[source]
destroy_balancer(balancer)[source]
get_balancer(balancer_id)[source]
list_balancers()[source]
list_protocols()[source]
name = 'Brightbox'
website = 'http://www.brightbox.co.uk/'

libcloud.loadbalancer.drivers.cloudstack module

class libcloud.loadbalancer.drivers.cloudstack.CloudStackLBDriver(key, secret=None, secure=True, host=None, path=None, port=None, *args, **kwargs)[source]

Bases: libcloud.common.cloudstack.CloudStackDriverMixIn, libcloud.loadbalancer.base.Driver

Driver for CloudStack load balancers.

@inherits: Driver.__init__

LB_STATE_MAP = {'Active': 0}
api_name = 'cloudstack_lb'
balancer_attach_member(balancer, member)[source]
balancer_detach_member(balancer, member)[source]
balancer_list_members(balancer)[source]
create_balancer(name, members, protocol='http', port=80, algorithm=1, location=None, private_port=None, network_id=None, vpc_id=None)[source]

@inherits: Driver.create_balancer

Parameters:
  • location (NodeLocation) – Location
  • private_port (int) – Private port
  • network_id (str) – The guest network this rule will be created for.
destroy_balancer(balancer)[source]
get_balancer(balancer_id)[source]
list_balancers()[source]
list_protocols()[source]

We don’t actually have any protocol awareness beyond TCP.

Return type:list of str
name = 'CloudStack'
type = 'cloudstack'
website = 'http://cloudstack.org/'

libcloud.loadbalancer.drivers.dimensiondata module

class libcloud.loadbalancer.drivers.dimensiondata.DimensionDataLBDriver(key, secret=None, secure=True, host=None, port=None, api_version=None, region='dd-na', **kwargs)[source]

Bases: libcloud.loadbalancer.base.Driver

DimensionData node driver.

api_version = 1.0
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.

In Dimension Data terminology these are the members of the pools within a virtual listener.

Parameters:balancer (LoadBalancer) – LoadBalancer which should be used
Return type:list of Member
connectionCls

alias of DimensionDataConnection

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

Create a new load balancer instance

Parameters:
  • name (str) – Name of the new load balancer (required)
  • port (int) – An integer in the range of 1-65535. If not supplied, it will be taken to mean ‘Any Port’
  • protocol (str) – Loadbalancer protocol, defaults to http.
  • members (list of Member) – list of Members to attach to balancer (optional)
  • algorithm (Algorithm) – Load balancing algorithm, defaults to ROUND_ROBIN.
  • ex_listener_ip_address (str) – Must be a valid IPv4 in dot-decimal notation (x.x.x.x).
Return type:

LoadBalancer

destroy_balancer(balancer)[source]

Destroy a load balancer (virtual listener)

Parameters:balancer (LoadBalancer) – LoadBalancer which should be used
Returns:True if the destroy was successful, otherwise False.
Return type:bool
ex_create_node(network_domain_id, name, ip, ex_description, connection_limit=25000, connection_rate_limit=2000)[source]

Create a new node

Parameters:
  • network_domain_id – Network Domain ID (required)
  • name (str) – name of the node (required)
  • ip (str) – IPv4 address of the node (required)
  • ex_description (str) – Description of the node (required)
  • connection_limit (int) – Maximum number of concurrent connections per sec
  • connection_rate_limit (int) – Maximum number of concurrent sessions
Returns:

Instance of DimensionDataVIPNode

Return type:

DimensionDataVIPNode

ex_create_pool(network_domain_id, name, balancer_method, ex_description, health_monitors=None, service_down_action='NONE', slow_ramp_time=30)[source]

Create a new pool

Parameters:
  • network_domain_id – Network Domain ID (required)
  • name (str) – name of the node (required)
  • balancer_method (str) – The load balancer algorithm (required)
  • ex_description (str) – Description of the node (required)
  • health_monitors (list of DimensionDataDefaultHealthMonitor) – A list of health monitors to use for the pool.
  • service_down_action (str) – What to do when node is unavailable NONE, DROP or RESELECT
  • slow_ramp_time (int) – Number of seconds to stagger ramp up of nodes
Returns:

Instance of DimensionDataPool

Return type:

DimensionDataPool

ex_create_pool_member(pool, node, port=None)[source]

Create a new member in an existing pool from an existing node

Parameters:
  • pool (DimensionDataPool) – Instance of DimensionDataPool (required)
  • node (DimensionDataVIPNode) – Instance of DimensionDataVIPNode (required)
  • port (str) – Port the the service will listen on
Returns:

The node member, instance of DimensionDataPoolMember

Return type:

DimensionDataPoolMember

ex_create_virtual_listener(network_domain_id, name, ex_description, port=None, pool=None, listener_ip_address=None, persistence_profile=None, fallback_persistence_profile=None, irule=None, protocol='TCP', connection_limit=25000, connection_rate_limit=2000, source_port_preservation='PRESERVE')[source]

Create a new virtual listener (load balancer)

Parameters:
  • network_domain_id – Network Domain ID (required)
  • name (str) – name of the listener (required)
  • ex_description (str) – Description of the node (required)
  • port (int) – An integer in the range of 1-65535. If not supplied, it will be taken to mean ‘Any Port’
  • pool (DimensionDataPool) – The pool to use for the listener
  • listener_ip_address (str) – The IPv4 Address of the virtual listener
  • persistence_profile (DimensionDataPersistenceProfile) – Persistence profile
  • fallback_persistence_profile (DimensionDataPersistenceProfile) – Fallback persistence profile
  • irule (DimensionDataDefaultiRule) – The iRule to apply
  • protocol – For STANDARD type, ANY, TCP or UDP for PERFORMANCE_LAYER_4 choice of ANY, TCP, UDP, HTTP
  • connection_limit (int) – Maximum number of concurrent connections per sec
  • connection_rate_limit (int) – Maximum number of concurrent sessions
  • source_port_preservation (str) – Choice of PRESERVE, PRESERVE_STRICT or CHANGE
Returns:

Instance of the listener

Return type:

DimensionDataVirtualListener

ex_destroy_node(node_id)[source]

Destroy a specific node

Parameters:node_id (str) – The ID of of a DimensionDataVIPNode
Returns:True for success, False for failure
Return type:bool
ex_destroy_pool(pool)[source]

Destroy an existing pool

Parameters:pool (DimensionDataPool) – The instance of DimensionDataPool to destroy
Returns:True for success, False for failure
Return type:bool
ex_destroy_pool_member(member, destroy_node=False)[source]

Destroy a specific member of a pool

Parameters:
  • pool (DimensionDataPoolMember) – The instance of a pool member
  • destroy_node (bool) – Also destroy the associated node
Returns:

True for success, False for failure

Return type:

bool

ex_get_current_network_domain()[source]

Get the current network domain ID of the driver.

Returns:ID of the network domain
Return type:str
ex_get_default_health_monitors(network_domain_id)[source]

Get the default health monitors available for a network domain

Parameters:network_domain_id (str) – The ID of of a DimensionDataNetworkDomain
Return type:list of DimensionDataDefaultHealthMonitor
ex_get_default_irules(network_domain_id)[source]

Get the default iRules available for a network domain

Parameters:network_domain_id (str) – The ID of of a DimensionDataNetworkDomain
Return type:list of DimensionDataDefaultiRule
ex_get_default_persistence_profiles(network_domain_id)[source]

Get the default persistence profiles available for a network domain

Parameters:network_domain_id (str) – The ID of of a DimensionDataNetworkDomain
Return type:list of DimensionDataPersistenceProfile
ex_get_node(node_id)[source]

Get the node specified by node_id

Returns:Returns an instance of DimensionDataVIPNode
Return type:Instance of DimensionDataVIPNode
ex_get_nodes(ex_network_domain_id=None)[source]

Get the nodes within this geography or in given network.

Parameters:ex_network_domain_id (str) – UUID of Network Domain if not None returns only balancers in the given network if None then returns all pools for the organization
Returns:Returns an list of DimensionDataVIPNode
Return type:list of DimensionDataVIPNode
ex_get_pool(pool_id)[source]

Get a specific pool inside the current geography

Parameters:pool_id (str) – The identifier of the pool
Returns:Returns an instance of DimensionDataPool
Return type:DimensionDataPool
ex_get_pool_member(pool_member_id)[source]

Get a specific member of a pool

Parameters:pool (str) – The id of a pool member
Returns:Returns an instance of DimensionDataPoolMember
Return type:DimensionDataPoolMember
ex_get_pool_members(pool_id)[source]

Get the members of a pool

Parameters:pool (DimensionDataPool) – The instance of a pool
Returns:Returns an list of DimensionDataPoolMember
Return type:list of DimensionDataPoolMember
ex_get_pools(ex_network_domain_id=None)[source]

Get all of the pools inside the current geography or in given network.

Parameters:ex_network_domain_id (str) – UUID of Network Domain if not None returns only balancers in the given network if None then returns all pools for the organization
Returns:Returns a list of type DimensionDataPool
Return type:list of DimensionDataPool
ex_set_current_network_domain(network_domain_id)[source]

Set the network domain (part of the network) of the driver

Parameters:network_domain_id (str) – ID of the pool (required)
ex_set_node_state(node, enabled)[source]

Change the state of a node (enable/disable)

Parameters:
  • pool (DimensionDataNode) – The instance of DimensionDataNode to update
  • enabled (bool) – The target state of the node
Returns:

The instance of DimensionDataNode

Return type:

DimensionDataNode

ex_set_pool_member_state(member, enabled=True)[source]
ex_update_node(node)[source]

Update the properties of a node

Parameters:pool (DimensionDataNode) – The instance of DimensionDataNode to update
Returns:The instance of DimensionDataNode
Return type:DimensionDataNode
ex_update_pool(pool)[source]

Update the properties of an existing pool only method, serviceDownAction and slowRampTime are updated

Parameters:pool (DimensionDataPool) – The instance of DimensionDataPool to update
Returns:True for success, False for failure
Return type:bool
ex_wait_for_state(state, func, poll_interval=2, timeout=60, *args, **kwargs)[source]

Wait for the function which returns a instance with field status to match

Keep polling func until one of the desired states is matched

Parameters:
  • state (str or list) – Either the desired state (str) or a list of states
  • func (function) – The function to call, e.g. ex_get_vlan
  • poll_interval (int) – The number of seconds to wait between checks
  • timeout (int) – The total number of seconds to wait to reach a state
  • args (Positional arguments) – The arguments for func
  • kwargs (Keyword arguments) – The arguments for func
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(ex_network_domain_id=None)[source]

List all loadbalancers inside a geography or in given network.

In Dimension Data terminology these are known as virtual listeners

Parameters:ex_network_domain_id (str) – UUID of Network Domain if not None returns only balancers in the given network if None then returns all pools for the organization
Return type:list of LoadBalancer
list_protocols()[source]

Return a list of supported protocols.

Since all protocols are support by Dimension Data, this is a list of common protocols.

Return type:list of str
name = 'Dimension Data Load Balancer'
network_domain_id = None
selected_region = None
type = 'dimensiondata'
website = 'https://cloud.dimensiondata.com/'

libcloud.loadbalancer.drivers.elb module

class libcloud.loadbalancer.drivers.elb.ElasticLBDriver(access_id, secret, region, token=None)[source]

Bases: libcloud.loadbalancer.base.Driver

balancer_attach_compute_node(balancer, node)[source]
balancer_detach_member(balancer, member)[source]
balancer_list_members(balancer)[source]
connectionCls

alias of ELBConnection

create_balancer(name, port, protocol, algorithm, members, ex_members_availability_zones=None)[source]
destroy_balancer(balancer)[source]
ex_create_balancer_listeners(name, listeners=None)[source]

Creates one or more listeners on a load balancer for the specified port

Parameters:
  • name (str) – The mnemonic name associated with the load balancer
  • listeners (``list of tuple`) – Each tuple contain values, (LoadBalancerPortNumber, InstancePortNumber, Protocol,[SSLCertificateId])
ex_create_balancer_policy(name, policy_name, policy_type, policy_attributes=None)[source]

Create a new load balancer policy

Parameters:
  • name (str) – Balancer name to create the policy for
  • policy_name (str) – policy to be created
  • policy_type (str) – policy type being used to create policy.
  • policy_attributes (PolicyAttribute list) – Each list contain values, [‘AttributeName’, ‘value’]
ex_delete_balancer_policy(name, policy_name)[source]

Delete a load balancer policy

Parameters:
  • name (str) – balancer name for which policy will be deleted
  • policy_name (str) – The Mnemonic name for the policy being deleted
ex_list_balancer_policies(balancer)[source]

Return a list of policy description string.

Return type:list of str
ex_list_balancer_policy_types()[source]

Return a list of policy type description string.

Return type:list of str
ex_set_balancer_policies_backend_server(name, instance_port, policies)[source]

Replaces the current set of policies associated with a port on which the back-end server is listening with a new set of policies

Parameters:
  • name (str) – balancer name to set policies of backend server
  • instance_port (int) – Instance Port
  • policies (``string list`) – List of policies to be associated with the balancer
ex_set_balancer_policies_listener(name, port, policies)[source]

Associates, updates, or disables a policy with a listener on the load balancer

Parameters:
  • name (str) – balancer name to set policies for listerner
  • port (str) – port to use
  • policies (string list) – List of policies to be associated with the balancer
get_balancer(balancer_id, ex_fetch_tags=False)[source]
list_balancers(ex_fetch_tags=False)[source]
list_protocols()[source]
name = 'Amazon Elastic Load Balancing'
signature_version = '4'
website = 'http://aws.amazon.com/elasticloadbalancing/'

libcloud.loadbalancer.drivers.gce module

class libcloud.loadbalancer.drivers.gce.GCELBDriver(*args, **kwargs)[source]

Bases: libcloud.loadbalancer.base.Driver

apiname = 'googleapis'
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 GCEConnection

create_balancer(name, port, protocol, algorithm, members, ex_region=None, ex_healthchecks=None, ex_address=None, ex_session_affinity=None)[source]

Create a new load balancer instance.

For GCE, this means creating a forwarding rule and a matching target pool, then adding the members to the target pool.

Parameters:
  • name (str) – Name of the new load balancer (required)
  • port (str) – Port or range of ports the load balancer should listen on, defaults to all ports. Examples: ‘80’, ‘5000-5999’
  • protocol (str) – Load balancer protocol. Should be ‘tcp’ or ‘udp’, defaults to ‘tcp’.
  • members (list of Member or Node) – List of Members to attach to balancer. Can be Member objects or Node objects. Node objects are preferred for GCE, but Member objects are accepted to comply with the established libcloud API. Note that the ‘port’ attribute of the members is ignored.
  • algorithm (Algorithm or None) – Load balancing algorithm. Ignored for GCE which uses a hashing-based algorithm.
  • ex_region (C{GCERegion} or str) – Optional region to create the load balancer in. Defaults to the default region of the GCE Node Driver.
  • ex_healthchecks (list of GCEHealthCheck or list of str) – Optional list of healthcheck objects or names to add to the load balancer.
  • ex_address (C{GCEAddress}) – Optional static address object to be assigned to the load balancer.
  • ex_session_affinity (str) – Optional algorithm to use for session affinity. This will modify the hashing algorithm such that a client will tend to stick to a particular Member.
Returns:

LoadBalancer object

Return type:

LoadBalancer

destroy_balancer(balancer)[source]

Destroy a load balancer.

For GCE, this means destroying the associated forwarding rule, then destroying the target pool that was attached to the forwarding rule.

Parameters:balancer (LoadBalancer) – LoadBalancer which should be used
Returns:True if successful
Return type:bool
ex_balancer_attach_healthcheck(balancer, healthcheck)[source]

Attach a healthcheck to balancer

Parameters:
  • balancer (LoadBalancer) – LoadBalancer which should be used
  • healthcheck (GCEHealthCheck) – Healthcheck to add
Returns:

True if successful

Return type:

bool

ex_balancer_detach_healthcheck(balancer, healthcheck)[source]

Detach healtcheck from balancer

Parameters:
  • balancer (LoadBalancer) – LoadBalancer which should be used
  • healthcheck (GCEHealthCheck) – Healthcheck to remove
Returns:

True if successful

Return type:

bool

ex_balancer_list_healthchecks(balancer)[source]

Return list of healthchecks attached to balancer

Parameters:balancer (LoadBalancer) – LoadBalancer which should be used
Return type:list of HealthChecks
ex_create_healthcheck(*args, **kwargs)[source]
ex_list_healthchecks()[source]
get_balancer(balancer_id)[source]

Return a LoadBalancer object.

Parameters:
  • balancer_id – Name of load balancer you wish to fetch. For GCE, this is the name of the associated forwarding rule.
  • balancer_idstr
Return type:

LoadBalancer

list_balancers(ex_region=None)[source]

List all loadbalancers

Parameters:ex_region (str or GCERegion or None) – The region to return balancers from. If None, will default to self.region. If ‘all’, will return all balancers.
Return type:list of LoadBalancer
list_protocols()[source]

Return a list of supported protocols.

For GCE, this is simply a hardcoded list.

Return type:list of str
name = 'Google Compute Engine Load Balancer'
website = 'https://cloud.google.com/'

libcloud.loadbalancer.drivers.gogrid module

class libcloud.loadbalancer.drivers.gogrid.GoGridLBConnection(user_id, key, secure=True, host=None, port=None, url=None, timeout=None, proxy_url=None, backoff=None, retry_delay=None)[source]

Bases: libcloud.common.gogrid.GoGridConnection

Connection class for the GoGrid load-balancer driver.

responseCls

alias of GoGridLBResponse

class libcloud.loadbalancer.drivers.gogrid.GoGridLBDriver(*args, **kwargs)[source]

Bases: libcloud.common.gogrid.BaseGoGridDriver, libcloud.loadbalancer.base.Driver

@inherits: Driver.__init__

LB_STATE_MAP = {'On': 0, 'Unknown': 2}
api_name = 'gogrid_lb'
balancer_attach_member(balancer, member)[source]
balancer_detach_member(balancer, member)[source]
balancer_list_members(balancer)[source]
connectionCls

alias of GoGridLBConnection

create_balancer(name, members, protocol='http', port=80, algorithm=1)[source]
destroy_balancer(balancer)[source]
ex_create_balancer_nowait(name, members, protocol='http', port=80, algorithm=1)[source]

@inherits: Driver.create_balancer

get_balancer(**kwargs)[source]
list_balancers()[source]
list_protocols()[source]
name = 'GoGrid LB'
website = 'http://www.gogrid.com/'
class libcloud.loadbalancer.drivers.gogrid.GoGridLBResponse(*args, **kwargs)[source]

Bases: libcloud.common.gogrid.GoGridResponse

success()[source]

libcloud.loadbalancer.drivers.ninefold module

class libcloud.loadbalancer.drivers.ninefold.NinefoldLBDriver(key, secret=None, secure=True, host=None, path=None, port=None, *args, **kwargs)[source]

Bases: libcloud.loadbalancer.drivers.cloudstack.CloudStackLBDriver

Driver for load balancers on Ninefold’s Compute platform.

@inherits: Driver.__init__

host = 'api.ninefold.com'
name = 'Ninefold LB'
path = '/compute/v1.0/'
type = 'ninefold'
website = 'http://ninefold.com/'

libcloud.loadbalancer.drivers.rackspace module

class libcloud.loadbalancer.drivers.rackspace.RackspaceAccessRule(id=None, rule_type=None, address=None)[source]

Bases: object

An access rule allows or denies traffic to a Load Balancer based on the incoming IPs.

Parameters:
  • id (int) – Unique identifier to refer to this rule by.
  • rule_type – RackspaceAccessRuleType.ALLOW or RackspaceAccessRuleType.DENY.
  • address (str) – IP address or cidr (can be IPv4 or IPv6).
class libcloud.loadbalancer.drivers.rackspace.RackspaceAccessRuleType[source]

Bases: object

ALLOW = 0
DENY = 1
class libcloud.loadbalancer.drivers.rackspace.RackspaceConnection(*args, **kwargs)[source]

Bases: libcloud.compute.drivers.rackspace.RackspaceConnection, libcloud.common.base.PollingConnection

auth_url = 'https://identity.api.rackspacecloud.com'
cache_busting = True
encode_data(data)[source]
get_poll_request_kwargs(response, context, request_kwargs)[source]
has_completed(response)[source]
poll_interval = 2
request(action, params=None, data='', headers=None, method='GET')[source]
responseCls

alias of RackspaceResponse

timeout = 80
class libcloud.loadbalancer.drivers.rackspace.RackspaceConnectionThrottle(min_connections, max_connections, max_connection_rate, rate_interval_seconds)[source]

Bases: object

Parameters:
  • min_connections (int) – Minimum number of connections per IP address before applying throttling.
  • max_connections (int) – Maximum number of connections per IP address. (Must be between 0 and 100000, 0 allows an unlimited number of connections.)
  • max_connection_rate (int) – Maximum number of connections allowed from a single IP address within the given rate_interval_seconds. (Must be between 0 and 100000, 0 allows an unlimited number of connections.)
  • rate_interval_seconds (int) – Interval at which the max_connection_rate is enforced. (Must be between 1 and 3600.)
class libcloud.loadbalancer.drivers.rackspace.RackspaceHTTPHealthMonitor(type, delay, timeout, attempts_before_deactivation, path, body_regex, status_regex)[source]

Bases: libcloud.loadbalancer.drivers.rackspace.RackspaceHealthMonitor

A HTTP health monitor adds extra features to a Rackspace health monitor.

Parameters:
  • path (str) – the HTTP path to monitor.
  • body_regex (str) – Regular expression used to evaluate the body of the HTTP response.
  • status_regex (str) – Regular expression used to evaluate the HTTP status code of the response.
class libcloud.loadbalancer.drivers.rackspace.RackspaceHealthMonitor(type, delay, timeout, attempts_before_deactivation)[source]

Bases: object

Parameters:
  • type (str) – type of load balancer. currently CONNECT (connection monitoring), HTTP, HTTPS (connection and HTTP monitoring) are supported.
  • delay (int) – minimum seconds to wait before executing the health monitor. (Must be between 1 and 3600)
  • timeout (int) – maximum seconds to wait when establishing a connection before timing out. (Must be between 1 and 3600)
  • attempts_before_deactivation (int) – Number of monitor failures before removing a node from rotation. (Must be between 1 and 10)
class libcloud.loadbalancer.drivers.rackspace.RackspaceLBDriver(key, secret=None, secure=True, host=None, port=None, region='ord', **kwargs)[source]

Bases: libcloud.loadbalancer.base.Driver, libcloud.common.openstack.OpenStackDriverMixin

CONDITION_LB_MEMBER_MAP = {0: 'ENABLED', 1: 'DISABLED', 2: 'DRAINING'}
LB_MEMBER_CONDITION_MAP = {'DISABLED': 1, 'DRAINING': 2, 'ENABLED': 0}
LB_STATE_MAP = {'PENDING_DELETE': 1, 'DELETED': 4, 'PENDING_UPDATE': 1, 'BUILD': 1, 'ERROR': 3, 'ACTIVE': 0}
api_name = 'rackspace_lb'
balancer_attach_member(balancer, member)[source]
balancer_detach_member(balancer, member)[source]
balancer_list_members(balancer)[source]
connectionCls

alias of RackspaceConnection

create_balancer(name, members, protocol='http', port=80, algorithm=1)[source]
destroy_balancer(balancer)[source]
ex_balancer_access_list(balancer)[source]

List the access list.

Parameters:balancer (LoadBalancer) – Balancer which should be used
Return type:list of RackspaceAccessRule
ex_balancer_attach_members(balancer, members)[source]

Attaches a list of members to a load balancer.

Parameters:
  • balancer (LoadBalancer) – The Balancer to which members will be attached.
  • members (list of Member) – A list of Members to attach.
Return type:

list of Member

ex_balancer_detach_members(balancer, members)[source]

Detaches a list of members from a balancer (the API supports up to 10). This method blocks until the detach request has been processed and the balancer is in a RUNNING state again.

Parameters:
  • balancer (LoadBalancer) – The Balancer to detach members from.
  • members (list of Member) – A list of Members to detach.
Returns:

Updated Balancer.

Return type:

LoadBalancer

ex_balancer_detach_members_no_poll(balancer, members)[source]

Detaches a list of members from a balancer (the API supports up to 10). This method returns immediately.

Parameters:
  • balancer (LoadBalancer) – The Balancer to detach members from.
  • members (list of Member) – A list of Members to detach.
Returns:

Returns whether the detach request was accepted.

Return type:

bool

ex_balancer_update_member(balancer, member, **kwargs)[source]

Updates a Member’s extra attributes for a Balancer. The attributes can include ‘weight’ or ‘condition’. This method blocks until the update request has been processed and the balancer is in a RUNNING state again.

Parameters:
  • balancer (LoadBalancer) – Balancer to update the member on.
  • member (Member) – Member which should be used
  • **kwargs

    New attributes. Should contain either ‘weight’

or ‘condition’. ‘condition’ can be set to ‘ENABLED’, ‘DISABLED’. or ‘DRAINING’. ‘weight’ can be set to a positive integer between 1 and 100, with a higher weight indicating that the node will receive more traffic (assuming the Balancer is using a weighted algorithm). :type **kwargs: dict

Returns:Updated Member.
Return type:Member
ex_balancer_update_member_no_poll(balancer, member, **kwargs)[source]

Updates a Member’s extra attributes for a Balancer. The attribute can include ‘weight’ or ‘condition’. This method returns immediately.

Parameters:
  • balancer (LoadBalancer) – Balancer to update the member on.
  • member (Member) – Member which should be used
  • **kwargs

    New attributes. Should contain either ‘weight’

or ‘condition’. ‘condition’ can be set to ‘ENABLED’, ‘DISABLED’. or ‘DRAINING’. ‘weight’ can be set to a positive integer between 1 and 100, with a higher weight indicating that the node will receive more traffic (assuming the Balancer is using a weighted algorithm). :type **kwargs: dict

Returns:Returns whether the update request was accepted.
Return type:bool
ex_create_balancer(name, members, protocol='http', port=80, algorithm=1, vip='PUBLIC')[source]

Creates a new load balancer instance

Parameters:
  • name (str) – Name of the new load balancer (required)
  • members (list of Member) – list of:class:`Member`s to attach to balancer
  • protocol (str) – Loadbalancer protocol, defaults to http.
  • port (str) – Port the load balancer should listen on, defaults to 80
  • algorithm (Algorithm) – Load balancing algorithm, defaults to LBAlgorithm.ROUND_ROBIN
  • vip (str) – Virtual ip type of PUBLIC, SERVICENET, or ID of a virtual ip
Return type:

LoadBalancer

ex_create_balancer_access_rule(balancer, rule)[source]

Adds an access rule to a Balancer’s access list. This method blocks until the update request has been processed and the balancer is in a RUNNING state again.

Parameters:
  • balancer (LoadBalancer) – Balancer to create the access rule for.
  • rule (RackspaceAccessRule) – Access Rule to add to the balancer.
Returns:

The created access rule.

Return type:

RackspaceAccessRule

ex_create_balancer_access_rule_no_poll(balancer, rule)[source]

Adds an access rule to a Balancer’s access list. This method returns immediately.

Parameters:
  • balancer (LoadBalancer) – Balancer to create the access rule for.
  • rule (RackspaceAccessRule) – Access Rule to add to the balancer.
Returns:

Returns whether the create request was accepted.

Return type:

bool

ex_create_balancer_access_rules(balancer, rules)[source]

Adds a list of access rules to a Balancer’s access list. This method blocks until the update request has been processed and the balancer is in a RUNNING state again.

Parameters:
Returns:

The created access rules.

Return type:

RackspaceAccessRule

ex_create_balancer_access_rules_no_poll(balancer, rules)[source]

Adds a list of access rules to a Balancer’s access list. This method returns immediately.

Parameters:
Returns:

Returns whether the create request was accepted.

Return type:

bool

ex_destroy_balancer_access_rule(balancer, rule)[source]

Removes an access rule from a Balancer’s access list. This method blocks until the update request has been processed and the balancer is in a RUNNING state again.

Parameters:
  • balancer (LoadBalancer) – Balancer to remove the access rule from.
  • rule (RackspaceAccessRule) – Access Rule to remove from the balancer.
Returns:

Updated Balancer.

Return type:

LoadBalancer

ex_destroy_balancer_access_rule_no_poll(balancer, rule)[source]

Removes an access rule from a Balancer’s access list. This method returns immediately.

Parameters:
  • balancer (LoadBalancer) – Balancer to remove the access rule from.
  • rule (RackspaceAccessRule) – Access Rule to remove from the balancer.
Returns:

Returns whether the destroy request was accepted.

Return type:

bool

ex_destroy_balancer_access_rules(balancer, rules)[source]

Removes a list of access rules from a Balancer’s access list. This method blocks until the update request has been processed and the balancer is in a RUNNING state again.

Parameters:
Returns:

Updated Balancer.

Return type:

LoadBalancer

ex_destroy_balancer_access_rules_no_poll(balancer, rules)[source]

Removes a list of access rules from a Balancer’s access list. This method returns immediately.

Parameters:
Returns:

Returns whether the destroy request was accepted.

Return type:

bool

ex_destroy_balancers(balancers)[source]

Destroys a list of Balancers (the API supports up to 10).

Parameters:balancers (list of LoadBalancer) – A list of Balancers to destroy.
Returns:Returns whether the destroy request was accepted.
Return type:bool
ex_disable_balancer_connection_logging(balancer)[source]

Disables connection logging for a Balancer. This method blocks until the enable request has been processed and the balancer is in a RUNNING state again.

Parameters:balancer (LoadBalancer) – Balancer to disable connection logging on.
Returns:Updated Balancer.
Return type:LoadBalancer
ex_disable_balancer_connection_logging_no_poll(balancer)[source]

Disables connection logging for a Balancer. This method returns immediately.

Parameters:balancer (LoadBalancer) – Balancer to disable connection logging on.
Returns:Returns whether the disable request was accepted.
Return type:bool
ex_disable_balancer_connection_throttle(balancer)[source]

Disables a Balancer’s connection throttle. This method blocks until the disable request has been processed and the balancer is in a RUNNING state again.

Parameters:balancer (LoadBalancer) – Balancer to disable connection throttle on.
Returns:Updated Balancer.
Return type:LoadBalancer
ex_disable_balancer_connection_throttle_no_poll(balancer)[source]

Disables a Balancer’s connection throttle. This method returns immediately.

Parameters:balancer (LoadBalancer) – Balancer to disable connection throttle on.
Returns:Returns whether the disable request was accepted.
Return type:bool
ex_disable_balancer_custom_error_page(balancer)[source]

Disables a Balancer’s custom error page, returning its error page to the Rackspace-provided default. This method blocks until the disable request has been processed and the balancer is in a RUNNING state again.

Parameters:balancer (LoadBalancer) – Balancer to disable the custom error page for.
Returns:Updated Balancer.
Return type:LoadBalancer
ex_disable_balancer_custom_error_page_no_poll(balancer)[source]

Disables a Balancer’s custom error page, returning its error page to the Rackspace-provided default. This method returns immediately.

Parameters:balancer (LoadBalancer) – Balancer to disable the custom error page for.
Returns:Returns whether the disable request was accepted.
Return type:bool
ex_disable_balancer_health_monitor(balancer)[source]

Disables a Balancer’s health monitor. This method blocks until the disable request has been processed and the balancer is in a RUNNING state again.

Parameters:balancer (LoadBalancer) – Balancer to disable health monitor on.
Returns:Updated Balancer.
Return type:LoadBalancer
ex_disable_balancer_health_monitor_no_poll(balancer)[source]

Disables a Balancer’s health monitor. This method returns immediately.

Parameters:balancer (LoadBalancer) – Balancer to disable health monitor on.
Returns:Returns whether the disable request was accepted.
Return type:bool
ex_disable_balancer_session_persistence(balancer)[source]

Disables session persistence for a Balancer. This method blocks until the disable request has been processed and the balancer is in a RUNNING state again.

Parameters:balancer (LoadBalancer) – Balancer to disable session persistence on.
Returns:Updated Balancer.
Return type:LoadBalancer
ex_disable_balancer_session_persistence_no_poll(balancer)[source]

Disables session persistence for a Balancer. This method returns immediately.

Parameters:balancer (LoadBalancer) – Balancer to disable session persistence for.
Returns:Returns whether the disable request was accepted.
Return type:bool
ex_enable_balancer_connection_logging(balancer)[source]

Enables connection logging for a Balancer. This method blocks until the enable request has been processed and the balancer is in a RUNNING state again.

Parameters:balancer (LoadBalancer) – Balancer to enable connection logging on.
Returns:Updated Balancer.
Return type:LoadBalancer
ex_enable_balancer_connection_logging_no_poll(balancer)[source]

Enables connection logging for a Balancer. This method returns immediately.

Parameters:balancer (LoadBalancer) – Balancer to enable connection logging on.
Returns:Returns whether the enable request was accepted.
Return type:bool
ex_enable_balancer_session_persistence(balancer)[source]

Enables session persistence for a Balancer by setting the persistence type to ‘HTTP_COOKIE’. This method blocks until the enable request has been processed and the balancer is in a RUNNING state again.

Parameters:balancer (LoadBalancer) – Balancer to enable session persistence on.
Returns:Updated Balancer.
Return type:LoadBalancer
ex_enable_balancer_session_persistence_no_poll(balancer)[source]

Enables session persistence for a Balancer by setting the persistence type to ‘HTTP_COOKIE’. This method returns immediately.

Parameters:balancer (LoadBalancer) – Balancer to enable session persistence on.
Returns:Returns whether the enable request was accepted.
Return type:bool
ex_get_balancer_error_page(balancer)[source]

List error page configured for the specified load balancer.

Parameters:balancer (LoadBalancer) – Balancer which should be used
Return type:str
ex_list_algorithm_names()[source]

Lists algorithms supported by the API. Returned as strings because this list may change in the future.

Return type:list of str
ex_list_current_usage(balancer)[source]

Return current load balancer usage report.

Parameters:balancer (LoadBalancer) – Balancer to remove the access rules from.
Returns:Raw load balancer usage object.
Return type:dict
ex_list_protocols_with_default_ports()[source]

List protocols with default ports.

Return type:list of tuple
Returns:A list of protocols with default ports included.
ex_update_balancer_connection_throttle(balancer, connection_throttle)[source]

Updates a Balancer’s connection throttle. This method blocks until the update request has been processed and the balancer is in a RUNNING state again.

Parameters:
  • balancer (LoadBalancer) – Balancer to update connection throttle on.
  • connection_throttle (RackspaceConnectionThrottle) – Connection Throttle for the balancer.
Returns:

Updated Balancer.

Return type:

LoadBalancer

ex_update_balancer_connection_throttle_no_poll(balancer, connection_throttle)[source]

Sets a Balancer’s connection throttle. This method returns immediately.

Parameters:
  • balancer (LoadBalancer) – Balancer to update connection throttle on.
  • connection_throttle (RackspaceConnectionThrottle) – Connection Throttle for the balancer.
Returns:

Returns whether the update request was accepted.

Return type:

bool

ex_update_balancer_error_page(balancer, page_content)[source]

Updates a Balancer’s custom error page. This method blocks until the update request has been processed and the balancer is in a RUNNING state again.

Parameters:
  • balancer (LoadBalancer) – Balancer to update the custom error page for.
  • page_content (str) – HTML content for the custom error page.
Returns:

Updated Balancer.

Return type:

LoadBalancer

ex_update_balancer_error_page_no_poll(balancer, page_content)[source]

Updates a Balancer’s custom error page. This method returns immediately.

Parameters:
  • balancer (LoadBalancer) – Balancer to update the custom error page for.
  • page_content (str) – HTML content for the custom error page.
Returns:

Returns whether the update request was accepted.

Return type:

bool

ex_update_balancer_health_monitor(balancer, health_monitor)[source]

Sets a Balancer’s health monitor. This method blocks until the update request has been processed and the balancer is in a RUNNING state again.

Parameters:
  • balancer (LoadBalancer) – Balancer to update.
  • health_monitor (RackspaceHealthMonitor) – Health Monitor for the balancer.
Returns:

Updated Balancer.

Return type:

LoadBalancer

ex_update_balancer_health_monitor_no_poll(balancer, health_monitor)[source]

Sets a Balancer’s health monitor. This method returns immediately.

Parameters:
  • balancer (LoadBalancer) – Balancer to update health monitor on.
  • health_monitor (RackspaceHealthMonitor) – Health Monitor for the balancer.
Returns:

Returns whether the update request was accepted.

Return type:

bool

ex_update_balancer_no_poll(balancer, **kwargs)[source]

Update balancer no poll.

@inherits: Driver.update_balancer

get_balancer(balancer_id)[source]
list_balancers(ex_member_address=None, ex_status=None, ex_changes_since=None, ex_params={})[source]

@inherits: Driver.list_balancers

Parameters:
  • ex_member_address (str) – Optional IP address of the attachment member. If provided, only the load balancers which have this member attached will be returned.
  • ex_status (str) – Optional. Filter balancers by status
  • ex_changes_since (str) – Optional. List all load balancers that have changed since the specified date/time
  • ex_params (dict) – Optional. Set parameters to be submitted to the API in the query string
list_protocols()[source]
classmethod list_regions()[source]
name = 'Rackspace LB'
update_balancer(balancer, **kwargs)[source]
website = 'http://www.rackspace.com/'
class libcloud.loadbalancer.drivers.rackspace.RackspaceResponse(response, connection)[source]

Bases: libcloud.common.base.JsonResponse

Parameters:
parse_body()[source]
success()[source]

libcloud.loadbalancer.drivers.slb module

class libcloud.loadbalancer.drivers.slb.SLBDriver(access_id, secret, region)[source]

Bases: libcloud.loadbalancer.base.Driver

Aliyun SLB load balancer driver.

balancer_attach_compute_node(balancer, node)[source]
balancer_attach_member(balancer, member)[source]
balancer_detach_member(balancer, member)[source]
balancer_list_members(balancer)[source]
connectionCls

alias of SLBConnection

create_balancer(name, port, protocol, algorithm, members, ex_bandwidth=None, ex_internet_charge_type=None, ex_address_type=None, ex_vswitch_id=None, ex_master_zone_id=None, ex_slave_zone_id=None, ex_client_token=None, **kwargs)[source]

Create a new load balancer instance

@inherits: Driver.create_balancer

Parameters:
  • ex_bandwidth (int in range [1, 1000]) – The max bandwidth limit for paybybandwidth internet charge type, in Mbps unit
  • ex_internet_charge_type (a str of paybybandwidth or paybytraffic) – The internet charge type
  • ex_address_type (a str of internet or intranet) – The listening IP address type
  • ex_vswitch_id (str) – The vswitch id in a VPC network
  • ex_master_zone_id (str) – The id of the master availability zone
  • ex_slave_zone_id (str) – The id of the slave availability zone
  • ex_client_token (str) – The token generated by client to identify requests
destroy_balancer(balancer)[source]
ex_create_listener(balancer, backend_port, protocol, algorithm, bandwidth, **kwargs)[source]

Create load balancer listening rule.

Parameters:
  • balancer (LoadBalancer) – the balancer which the rule belongs to. The listener created will listen on the port of the the balancer as default. ‘ListenerPort’ in kwargs will OVERRIDE it.
  • backend_port (int) – the backend server port
  • protocol (str) – the balancer protocol, default to http
  • algorithm (Algorithm) – the balancer routing algorithm
  • bandwidth (str) – the listener bandwidth limits
Returns:

the created listener

Return type:

SLBLoadBalancerListener

ex_delete_certificate(certificate_id)[source]

Delete the given server certificate

Parameters:certificate_id (str) – the id of the certificate to delete
Returns:whether process is success
Return type:bool
ex_get_balancer_attribute(balancer)[source]

Get balancer attribute

Parameters:balancer (LoadBalancer) – the balancer to get attribute
Returns:the balancer attribute
Return type:SLBLoadBalancerAttribute
ex_list_certificates(certificate_ids=[])[source]

List all server certificates

Parameters:certificate_ids (str) – certificate ids to filter results
Returns:certificates
Return type:SLBServerCertificate
ex_list_listeners(balancer)[source]

Get all listener related to the given balancer

Parameters:balancer (LoadBalancer) – the balancer to list listeners
Returns:a list of listeners
Return type:list of SLBLoadBalancerListener
ex_set_certificate_name(certificate_id, name)[source]

Set server certificate name.

Parameters:
  • certificate_id (str) – the id of the server certificate to update
  • name (str) – the new name
Returns:

whether updating is success

Return type:

bool

ex_start_listener(balancer, port)[source]

Start balancer’s listener listening the given port.

Parameters:
  • balancer (LoadBalancer) – a load balancer
  • port (int) – listening port
Returns:

whether operation is success

Return type:

bool

ex_stop_listener(balancer, port)[source]

Stop balancer’s listener listening the given port.

Parameters:
  • balancer (LoadBalancer) – a load balancer
  • port (int) – listening port
Returns:

whether operation is success

Return type:

bool

ex_upload_certificate(name, server_certificate, private_key)[source]

Upload certificate and private key for https load balancer listener

Parameters:
  • name (str) – the certificate name
  • server_certificate (str) – the content of the certificate to upload in PEM format
  • private_key (str) – the content of the private key to upload in PEM format
Returns:

new created certificate info

Return type:

SLBServerCertificate

get_balancer(balancer_id)[source]
list_balancers(ex_balancer_ids=None, ex_filters=None)[source]

List all loadbalancers

@inherits Driver.list_balancers

Parameters:
  • ex_balancer_ids (list of str) – a list of balancer ids to filter results Only balancers which’s id in this list will be returned
  • ex_filters (dict) – attributes to filter results. Only balancers which have all the desired attributes and values will be returned
list_protocols()[source]
name = 'Aliyun Server Load Balancer'
namespace = None
path = '/'
website = 'https://www.aliyun.com/product/slb'

libcloud.loadbalancer.drivers.softlayer module

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

Bases: libcloud.loadbalancer.base.Driver

balancer_attach_member(balancer, member)[source]
balancer_detach_member(balancer, member)[source]
balancer_list_members(balancer)[source]
connectionCls

alias of SoftLayerConnection

destroy_balancer(balancer)[source]
ex_configure_load_balancer(balancer, port=80, protocol='http', algorithm=1, ex_allocation=100)[source]

Configure the loadbalancer by adding it with a front-end port (aka a service group in the Softlayer loadbalancer model).

Softlayer loadbalancer may be defined with multiple service groups (front-end ports) each defined with a unique port number.

Parameters:
  • balancer (LoadBalancer) – The loadbalancer.
  • port (int) – Port of the service group, defaults to 80.
  • protocol (str) – Loadbalancer protocol, defaults to http.
  • algorithm (Algorithm) – Load balancing algorithm, defaults to Algorithm.ROUND_ROBIN
  • ex_allocation (int) – The percentage of the total connection allocations to allocate for this group.
Returns:

True if ex_add_service_group was successful.

Return type:

bool

ex_list_balancer_packages()[source]

Retrieves the available local load balancer packages.

Return type:list of LBPackage
ex_place_balancer_order(package, location)[source]

Places an order for a local loadbalancer in the specified location.

Parameters:
  • package (LBPackage) – The package to create the loadbalancer from.
  • location (NodeLocation) – The location (datacenter) to create the loadbalancer.
Returns:

True if ex_place_balancer_order was successful.

Return type:

bool

get_balancer(balancer_id)[source]
list_balancers()[source]
list_protocols()[source]

Return a list of supported protocols.

Return type:list of str
name = 'Softlayer Load Balancing'
website = 'http://www.softlayer.com/'

Module contents