“Aliyun Python SDK”的版本间的差异
跳到导航
跳到搜索
第9行: | 第9行: | ||
pip install aliyun-python-sdk-core | pip install aliyun-python-sdk-core | ||
pip install aliyun-python-sdk-slb | pip install aliyun-python-sdk-slb | ||
− | |||
− | |||
− | |||
#!/bin/python | #!/bin/python | ||
第20行: | 第17行: | ||
from aliyunsdkcore.acs_exception.exceptions import ServerException | from aliyunsdkcore.acs_exception.exceptions import ServerException | ||
from aliyunsdkslb.request.v20140515.SetBackendServersRequest import SetBackendServersRequest | from aliyunsdkslb.request.v20140515.SetBackendServersRequest import SetBackendServersRequest | ||
− | |||
client = AcsClient('LTAI4GAVWqFbxsGun2hPGWm', 'YYnSOcvleOHYdwi5PbIHrWthZEohc', 'cn-hangzhou') | client = AcsClient('LTAI4GAVWqFbxsGun2hPGWm', 'YYnSOcvleOHYdwi5PbIHrWthZEohc', 'cn-hangzhou') | ||
− | |||
request = SetBackendServersRequest() | request = SetBackendServersRequest() | ||
第30行: | 第25行: | ||
request.set_LoadBalancerId("lb-bp1u3m2q37rl5fqrurjv9") | request.set_LoadBalancerId("lb-bp1u3m2q37rl5fqrurjv9") | ||
− | # | + | #-web01 i-bp1 |
− | # | + | #-web02 i-bp15 |
#ha1 ha2 还原 | #ha1 ha2 还原 |
2020年9月21日 (一) 02:22的版本
slb
利用python开启关闭slb
jenkins上先安装 apt-get install python-pip pip install aliyun-python-sdk-core pip install aliyun-python-sdk-slb #!/bin/python #coding=utf-8 # https://slb.console.aliyun.com/slb/cn-hangzhou/slbs/lb-bp1u3m2q37rl5fqrurjv9?redirect=%2Fslb%2Fcn-hangzhou%2Fslbs from aliyunsdkcore.client import AcsClient from aliyunsdkcore.acs_exception.exceptions import ClientException from aliyunsdkcore.acs_exception.exceptions import ServerException from aliyunsdkslb.request.v20140515.SetBackendServersRequest import SetBackendServersRequest client = AcsClient('LTAI4GAVWqFbxsGun2hPGWm', 'YYnSOcvleOHYdwi5PbIHrWthZEohc', 'cn-hangzhou') request = SetBackendServersRequest() request.set_accept_format('json') request.set_LoadBalancerId("lb-bp1u3m2q37rl5fqrurjv9") #-web01 i-bp1 #-web02 i-bp15 #ha1 ha2 还原 request.set_BackendServers("[{\"ServerId\":\"i-bp15axh2ymtzzdtwyq0\",\"Weight\":\"100\"},{\"ServerId\":\"i-bp15axh2ymtzzdtwypy\",\"Weight\":\"100\"}]") response = client.do_action_with_exception(request) # python2: print(response) #print(str(response, encoding='utf-8')) print(response)
Python SDK调用SLB的CreateLoadBalancer接口创建一个SLB实例
ecs
https://help.aliyun.com/document_detail/62197.html?spm=a2c4g.11186623.6.553.35a4323awkWHsg