Common BLB Instance
Common type blb instance provides conventional load balancing feature components featuring light weight, simple configuration, and low price to meet the general needs of users for load balancing.
Self is blb_client; for the meaning of each parameter, please see the bbl official document General bbl Interface under API Reference.
Create Blb Instance
Description:
- Create a LoadBalancer and return the assigned service address and instance ID.
- The payment method is postpaid.
- Identity and access management is required. If it does not pass the identity and access management, you may go to identity and access management under the Security Authentication in Baidu Open Cloud Console for authentication.
You can create a BLB instance using the following code:
@required(vpc_id=(bytes, str),
subnet_id=(bytes, str))
def create_loadbalancer(self, vpc_id, subnet_id, name=None,
desc=None, client_token=None, config=None):
The example is as follows:
blb_client.create_loadbalancer(vpc_id="vpc-jupcnrwxqgvf", subnet_id="sbn-p64udgxpymae")
Modify the Blb Instance
Description:
- Update the specified single LoadBalancer configuration information, including the name and description of the LoadBalancer instance.
You can modify the blb instance using the following code:
@required(blbId=(bytes, str))
def update_loadbalancer(self, blb_id, name=None, desc=None,
client_token=None, config=None):
The example is as follows:
blb_client.update_loadbalancer(blb_id="lb-13223bfa", name="blb_bj")
Query a List of Blb Instances
Description:
- Query all LoadBalancer information under the user account
- Support query by id, name, and address of LoadBalancer. The matching rule supports partial inclusion (regular is not supported)
- Support query by bccId (currently support only single bccId query, and only precise query). The query result is a load balancing instance containing the backend server.
- The returned result is the intersection of multiple query conditions
- If the BLB instance has access to the public network, the return result will carry the public network IP
- The result supports marker paging. The default paging size is 1,000, and can be specified by the maxKeys parameter
You can query the blb list using the following code:
def describe_loadbalancers(self, address=None, name=None, blb_id=None,
bcc_id=None, marker=None, max_keys=None,
config=None):
The example is as follows:
blb_client.describe_loadbalancers()
Query Blb Instance Details
Description:
- Query details of a LoadBalancer under the user account by id
- Contain all listener port information of LoadBalancer
You can query blb details using the following code:
@required(blb_id=(bytes, str))
def describe_loadbalancer_detail(self, blb_id, config=None):
The example is as follows:
blb_client.describe_loadbalancer_detail(blb_id="lb-13223bfa")
Delete Blb Instance
Description:
- Release the specified LoadBalancer which cannot be retrieved
You can delete the blb instance using the following code:
@required(blb_id=(bytes, str))
def delete_loadbalancer(self, blb_id, client_token=None, config=None):
The example is as follows:
blb_client.delete_loadbalancer(blb_id="lb-13223bfa")
Create HttpListener Instance
Description:
- Under the specified LoadBalancer, create a listener based on the HTTP protocol to listen to a frontend port and forward all HTTP requests sent to the port to the backend port monitored by the backend server
You can create an httpListener instance using the following code:
@required(blb_id=(bytes, str), listener_port=int,
backend_port=int, scheduler=(bytes, str))
def create_http_listener(self, blb_id, listener_port,
backend_port, scheduler,
keep_session=None, keep_session_type=None,
keep_session_duration=None,
keep_session_cookie_name=None,
x_forward_for=None,
health_check_type=None, health_check_port=None,
health_check_uri=None,
health_check_timeout_in_second=None,
health_check_interval=None,
unhealthy_threshold=None,
healthy_threshold=None,
health_check_normal_status=None,
server_timeout=None, redirect_port=None,
client_token=None, config=None):
The example is as follows:
blb_client.create_http_listener(blb_id="lb-2f30bc8a", listener_port=80, backend_port=80, scheduler="RoundRobin")
Create HttpsListener Instance
Description:
- Under the specified LoadBalancer, create a listener based on the HTTPS protocol and listen to a frontend port. All HTTPS requests sent to this port will be converted to HTTP requests through SSL offload and then forwarded to the backend port monitored by the backend server.
You can create an httpsListener instance using the following code:
@required(blb_id=(bytes, str), listener_port=int,
backend_port=int, scheduler=(bytes, str), cert_ids=list)
def create_https_listener(self, blb_id, listener_port, backend_port,
scheduler, cert_ids, keep_session=None,
keep_session_type=None,
keep_session_duration=None,
keep_session_cookie_name=None,
x_forward_for=None, health_check_type=None,
health_check_port=None, health_check_uri=None,
health_check_timeout_in_second=None,
health_check_interval=None,
unhealth_threshold=None, health_threshold=None,
health_check_normal_status=None,
server_timeout=None, ie6_compatible=None,
encryption_type=None, encryption_protocols=None,
dual_auth=None, client_certIds=None,
client_token=None, config=None):
The example is as follows:
blb_client.create_https_listener(blb_id="lb-2f30bc8a", listener_port=443, backend_port=80, scheduler="RoundRobin", cert_ids=["cert-gs8bktrm7drp"])
Create TcpListener Instance
Description:
- Under the specified LoadBalancer, create a listener based on the TCP protocol to listen to a frontend port and forward all TCP traffic sent to the port to the backend port monitored by the backend server. The TCP listener only supports the health check of the TCP protocol. The check port is the same as the backend server listening port.
You can create a tcpListener instance using the following code:
@required(blb_id=(bytes, str),
listener_port=int,
backend_port=int,
scheduler=(bytes, str))
def create_tcp_listener(self, blb_id, listener_port,
backend_port, scheduler,
health_check_timeout_in_second=None,
health_check_interval=None,
unhealthy_threshold=None,
healthy_threshold=None,
client_token=None, config=None):
The example is as follows:
blb_client.create_tcp_listener(blb_id="lb-2f30bc8a", listener_port=80, backend_port=80, scheduler="RoundRobin")
Create UdpListener Instance
Description:
- Under the specified LoadBalancer, create a listener based on the UDP protocol to listen to a frontend port and forward all UDP traffic sent to the port to the backend port monitored by the backend server. The UDP listener only supports the health check of the UDP protocol. The check port is the same as the backend server listening port.
You can create an udpListener instance using the following code:
@required(blb_id=(bytes, str),
listener_port=int,
backend_port=int,
scheduler=(bytes, str),
health_check_string=(bytes, str))
def create_udp_listener(self, blb_id, listener_port, backend_port,
scheduler, health_check_string,
health_check_timeout_in_second=None,
health_check_interval=None,
unhealthy_threshold=None,
healthy_threshold=None,
client_token=None, config=None):
The example is as follows:
blb_client.create_udp_listener(blb_id="lb-2f30bc8a", listener_port=53, backend_port=53, scheduler="RoundRobin", health_check_string="\00\01\01\00\01\00\00\00\00\00\00\05baidu\03com\00\00\01\00\01")
Create SslListener Instance
Description:
- Under the specified LoadBalancer, create a listener based on the TCP protocol to listen to a frontend port and forward all TCP traffic sent to the port to the backend port monitored by the backend server. The TCP listener only supports the health check of the TCP protocol. The check port is the same as the backend server listening port.
You can create an sslListener instance using the following code:
@required(blb_id=(bytes, str), listener_port=int,
backend_port=int, scheduler=(bytes, str), cert_ids=list)
def create_ssl_listener(self, blb_id, listener_port, backend_port,
scheduler, cert_ids,
health_check_timeout_in_second=None,
health_check_interval=None,
unhealth_threshold=None, health_threshold=None,
ie6_compatible=None, encryption_type=None,
encryption_protocols=None,
dual_auth=None, client_certIds=None,
client_token=None, config=None):
The example is as follows:
blb_client.create_ssl_listener(blb_id="lb-2f30bc8a", listener_port=443, backend_port=80, scheduler="RoundRobin", cert_ids=["cert-gs8bktrm7drp"])
Update HttpListener Instance
Description:
- Update the HTTP listener parameters under the specified LoadBalancer. All the domains specified in the request parameters will be updated, the unspecified domains will remain unchanged, and the listener will be specified through the port.
You can update a httpListener instance using the following code:
@required(blb_id=(bytes, str),
listener_port=int)
def update_http_listener(self, blb_id, listener_port, backend_port=None,
scheduler=None, keep_session=None,
keep_session_type=None,
keep_session_duration=None,
keep_session_cookie_name=None,
x_forward_for=None,
health_check_type=None, health_check_port=None,
health_check_uri=None,
health_check_timeout_in_second=None,
health_check_interval=None,
unhealth_threshold=None, health_threshold=None,
health_check_normal_status=None,
server_timeout=None,
redirect_port=None, config=None):
The example is as follows:
blb_client.update_http_listener(blb_id="lb-2f30bc8a", listener_port=80, backend_port=90)
Update HttpsListener Instance
Description:
- Update the HTTPS listener parameters under the specified LoadBalancer. All the domains specified in the request parameters will be updated, the unspecified domains will remain unchanged, and the listener will be specified through the port.
You can update a httpsListener instance using the following code:
@required(blb_id=(bytes, str), listener_port=int)
def update_https_listener(self, blb_id, listener_port,
backend_port=None,
scheduler=None, keep_session=None,
keep_session_type=None,
keep_session_duration=None,
keep_session_cookie_name=None,
x_forward_for=None, health_check_type=None,
health_check_port=None, health_check_uri=None,
health_check_timeout_in_second=None,
health_check_interval=None,
unhealth_threshold=None, health_threshold=None,
health_check_normal_status=None,
server_timeout=None,
cert_ids=None, ie6_compatible=None,
config=None):
The example is as follows:
blb_client.update_https_listener(blb_id="lb-2f30bc8a", listener_port=443, backend_port=90)
Update TcpListener Instance
Description:
- Update the TCP listener parameters under the specified LoadBalancer. All the specified fields in the request parameters will be updated. The unspecified fields will remain unchanged. The listener is specified through the port.
You can update a tcpListener instance using the following code:
@required(blb_id=(bytes, str),
listener_port=int)
def update_tcp_listener(self, blb_id, listener_port,
backend_port=None, scheduler=None,
health_check_timeout_in_second=None,
health_check_interval=None,
unhealth_threshold=None,
health_threshold=None,
config=None):
The example is as follows:
blb_client.update_tcp_listener(blb_id="lb-2f30bc8a", listener_port=80, backend_port=90)
Update UdpListener Instance
Description:
- Update the UDP listener parameters under the specified LoadBalancer. All the domains specified in the request parameters will be updated, the unspecified domains will remain unchanged, and the listener will be specified through the port.
You can update a udpListener instance using the following code:
@required(blb_id=(bytes, str),
listener_port=int,
backend_port=int)
def update_udp_listener(self, blb_id, listener_port, backend_port=None,
scheduler=None, health_check_string=None,
health_check_timeout_in_second=None,
health_check_interval=None,
unhealth_threshold=None,
health_threshold=None,
config=None):
The example is as follows:
blb_client.update_udp_listener(blb_id="lb-2f30bc8a", listener_port=53, backend_port=53, scheduler="LeastConnection")
Update SslListener Instance
Description:
- Update the SSL listener parameters under the specified LoadBalancer. All the domains specified in the request parameters will be updated, the unspecified domains will remain unchanged, and the listener will be specified through the port.
You can update an sslListener instance using the following code:
@required(blb_id=(bytes, str), listener_port=int)
def update_ssl_listener(self, blb_id, listener_port,
backend_port=None, scheduler=None,
health_check_timeout_in_second=None,
health_check_interval=None,
unhealth_threshold=None,
health_threshold=None, cert_ids=None,
ie6_compatible=None,
encryption_type=None,
encryption_protocols=None,
dual_auth=None, client_certIds=None,
config=None):
The example is as follows:
blb_client.update_ssl_listener(blb_id="lb-2f30bc8a", listener_port=443, backend_port=90)
Query HttpListener Instance
Description:
- Query information about all HTTP listeners under the specified LoadBalancer
- Support matching query by listener port
- The result supports marker paging. The default paging size is 1,000, and can be specified by the maxKeys parameter
You can query a httpListener instance using the following code:
@required(blb_id=(bytes, str))
def describe_http_listener(self, blb_id, listener_port=None,
marker=None, max_keys=None, config=None):
The example is as follows:
blb_client.describe_http_listener(blb_id="lb-2f30bc8a")
Query HttpsListener Instance
Description:
- Query information about all HTTPS listeners under the specified LoadBalancer
- Support matching query by listener port
- The result supports marker paging. The default paging size is 1,000, and can be specified by the maxKeys parameter
You can query a httpsListener instance using the following code:
@required(blb_id=(bytes, str))
def describe_https_listener(self, blb_id, listener_port=None,
marker=None, max_keys=None, config=None):
The example is as follows:
blb_client.describe_https_listener(blb_id="lb-2f30bc8a")
Query TcpListener Instance
Description:
- Query information about all TCP listeners under the specified LoadBalancer
- Support matching query by listener port
- The result supports marker paging. The default paging size is 1,000, and can be specified by the maxKeys parameter
You can query a tcpListener instance using the following code:
def describe_tcp_listener(self, blb_id, listener_port=None,
marker=None, max_keys=None, config=None):
The example is as follows:
blb_client.describe_tcp_listener(blb_id="lb-2f30bc8a")
Query UdpListener Instance
Description:
- Query information about all UDP listeners under the specified LoadBalancer
- Support matching query by listener port
- The result supports marker paging. The default paging size is 1,000, and can be specified by the maxKeys parameter
You can query a udpListener instance using the following code:
@required(blb_id=(bytes, str))
def describe_udp_listener(self, blb_id, listener_port=None, marker=None,
max_keys=None, config=None):
The example is as follows:
blb_client.describe_udp_listener(blb_id="lb-2f30bc8a")
Query SslListener Instance
Description:
- Query information about all SSL listeners under the specified LoadBalancer
- Support matching query by listener port
- The result supports marker paging. The default paging size is 1,000, and can be specified by the maxKeys parameter
You can query an sslListener instance using the following code:
@required(blb_id=(bytes, str))
def describe_ssl_listener(self, blb_id, listener_port=None,
marker=None, max_keys=None, config=None):
The example is as follows:
blb_client.describe_ssl_listener(blb_id="lb-2f30bc8a")
Delete Listener Instance
Description:
- Releases the listener under the specified LoadBalancer. The listener is specified by the listening port.
- Support batch release
You can delete a Listener instance using the following code:
@required(blb_id=(bytes, str),
portList=list)
def delete_listeners(self, blb_id, portList, client_token=None, config=None):
The example is as follows:
blb_client.delete_listeners(blb_id="lb-2f30bc8a", portList=[443])
Add Backend Server Instance
Description:
- Add backend server for specified LoadBalancer (batch add is supported)
You can add a backend server instance using the following code:
@required(blb_id=(bytes, str),
backend_server_list=list)
def add_backend_servers(self, blb_id, backend_server_list,
client_token=None, config=None):
The example is as follows:
backendServerModel = {
"instanceId": "i-jVRZWSXN"
}
blb_client.add_backend_servers(blb_id="lb-93421df2", backend_server_list=[backendServerModel])
Modify Backend Server Instance
Description:
- Update the weight of the backend server under the specified LoadBalancer (batch modification is supported).
You can modify a backend server instance using the following code:
@required(blb_id=(bytes, str),
backend_server_list=list)
def update_backend_servers(self, blb_id, backend_server_list,
client_token=None, config=None):
The example is as follows:
backendServerModel = {
"instanceId": "i-jVRZWSXN",
"weight": 50
}
blb_client.update_backend_servers(blb_id="lb-93421df2", backend_server_list=[backendServerModel])
Query Backend Server Instance
Description:
- Query the list of backend servers under the specified LoadBalancer
- The result supports marker paging. The default paging size is 1,000, and can be specified by the maxKeys parameter
You can query a backend server instance using the following code:
@required(blb_id=(bytes, str))
def describe_backend_servers(self, blb_id, marker=None,
max_keys=None, config=None):
The example is as follows:
blb_client.describe_backend_servers(blb_id="lb-93421df2")
Remove Backend Server Instance
Description:
- Release the backend server specified by its identifier under the specified LoadBalancer
- Support batch release
You can remove a backend server instance using the following code:
@required(blb_id=(bytes, str),
backend_server_list=list)
def remove_backend_servers(self, blb_id, backend_server_list,
client_token=None, config=None):
The example is as follows:
blb_client.remove_backend_servers(blb_id="lb-93421df2", backend_server_list=["i-jVRZWSXN"])