This topic describes how to use SLB SDK for Python to clone a Server Load Balancer (SLB) instance.
Prerequisites
Before you run the following code in script mode, make sure that the following requirements
are met:
- Your account has a balance of at least CNY 100 so that you can be charged the instance fee when you use SLB SDK for Python to create an SLB instance.
- An AccessKey pair is obtained.
An AccessKey ID and an AccessKey secret that are used to verify your identity are obtained. For more information about how to obtain an AccessKey pair, see Obtain an AccessKey pair.
- The SLB Python example library for implementing SLB features with Alibaba Cloud SLB SDK for Python is downloaded.
- Go to the directory where setup.py is stored and run the following command to initialize the environment:
python setup.py install
Background information
- Create an SLB instance in the China (Zhangjiakou) region. Set the name of the SLB instance to SLB1, set the primary zone to cn-zhangjiakou-a, and set the secondary zone to cn-zhangjiakou-b. Then, set the billing method of the SLB instance to pay-as-you-go and set the type of the SLB instance to slb.s1.small. For other parameters, use the default settings.
- Add the ECS instances that are created in the China (Zhangjiakou) region to the default server group. Network traffic is then forwarded by the SLB instance to the ECS instances. Then, set the weights of both ECS instances to 100.
- Create a TCP listener. Set the frontend port that is used by the SLB instance to port 80 and set the backend port that receives requests to port 80. Then, set the health check protocol to TCP. The maximum bandwidth of the listener is not limited. For other parameters, use the default settings.
- Query information about SLB1. The information is passed to the request as parameters for cloning an SLB instance.
- Clone an SLB instance.
- Delete SLB1.
- Query information about the cloned SLB instance.
- Delete the cloned SLB instance.