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 usednode (
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 usedmember (
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 usedmember (
Member
) – Member which should be used
- Returns:
True
if member detach was successful, otherwiseFalse
.- 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
ofMember
- 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 unitex_internet_charge_type (a
str
of paybybandwidth or paybytraffic) – The internet charge typeex_address_type (a
str
of internet or intranet) – The listening IP address typeex_vswitch_id (
str
) – The vswitch id in a VPC networkex_master_zone_id (
str
) – The id of the master availability zoneex_slave_zone_id (
str
) – The id of the slave availability zoneex_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, otherwiseFalse
.- 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 portprotocol (
str
) – the balancer protocol, default to httpalgorithm (
Algorithm
) – the balancer routing algorithmbandwidth (
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
ofSLBLoadBalancerListener
- ex_set_certificate_name(certificate_id, name)[source]
Set server certificate name.
- Parameters:
certificate_id (
str
) – the id of the server certificate to updatename (
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 balancerport (
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 balancerport (
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 nameserver_certificate (
str
) – the content of the certificate to upload in PEM formatprivate_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
ofstr
) – a list of balancer ids to filter results Only balancers which’s id in this list will be returnedex_filters (
dict
) – attributes to filter results. Only balancers which have all the desired attributes and values will be returned
- name = 'Aliyun Server Load Balancer'
- namespace = None
- path = '/'
- website = 'https://www.aliyun.com/product/slb'