libcloud.loadbalancer.drivers.slb module

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

Bases: Driver

Aliyun SLB load balancer 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 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]

Destroy a load balancer

Parameters:

balancer (LoadBalancer) – LoadBalancer which should be used

Returns:

True if the destroy was successful, otherwise False.

Return type:

bool

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]

Return a LoadBalancer object.

Parameters:

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

Return type:

LoadBalancer

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]

Return a list of supported protocols.

Return type:

list of str

name = 'Aliyun Server Load Balancer'
namespace = None
path = '/'
website = 'https://www.aliyun.com/product/slb'