def create_load_balancer_clone(params):
    '''
    create_load_balancer:创建slb实例
    官网API参考链接:https://help.aliyun.com/document_detail/27577.html
    '''
    counter = 0
    while counter < TRY_TIME:
        try:
            request = CreateLoadBalancerRequest.CreateLoadBalancerRequest()
            # 主可用区
            request.set_MasterZoneId(params["master_zone_id"])
            # 备可用区
            request.set_SlaveZoneId(params["slave_zone_id"])
            # 付费类型
            request.set_PayType(params["pay_balancer_type"])
            # 资源组id
            request.set_ResourceGroupId(params["resource_group_id"])
            # 负载均衡实例的ip版本
            request.set_AddressIPVersion(params["address_ip_version"])
            # 负载均衡实例的网络类型
            request.set_AddressType(params["address_type"])
            # 实例名称
            request.set_LoadBalancerName(params["load_balancer_name"])
            response = ACS_CLIENT.do_action_with_exception(request)
            response_json = json.loads(response)
            return response_json
        except ServerException as e:
            ExceptionHandler.server_exception(e)
        except ClientException as e:
            ExceptionHandler.client_exception(e)
        finally:
            counter += 1
Beispiel #2
0
    def create_load_balancer_private(self, pay_type, name, vpc_id, vswitch_id):
        try:
            request = CreateLoadBalancerRequest.CreateLoadBalancerRequest()
            request.set_PayType(pay_type)
            request.set_LoadBalancerName(name)
            request.set_VpcId(vpc_id)
            request.set_VSwitchId(vswitch_id)
            response = self.client.do_action_with_exception(request)

            response_json = json.loads(response)
            return response_json
        except ServerException as e:
            ExceptionHandler.server_exception(e)
        except ClientException as e:
            ExceptionHandler.client_exception(e)
Beispiel #3
0
def create_slb(LoadBalancerName, AddressType, VSwitchId):
    '''
    LoadBalancerName='test-slb-01'
    AddressType='intranet'
    VSwitchId='vsw-2ze130t0mdnzmtvx7uyck'
    create_slb(LoadBalancerName, AddressType,  VSwitchId)
    '''
    from aliyunsdkslb.request.v20140515 import CreateLoadBalancerRequest
    request = CreateLoadBalancerRequest.CreateLoadBalancerRequest()
    request.set_accept_format('json')
    request.set_LoadBalancerName(LoadBalancerName)
    request.set_AddressType(AddressType)
    request.set_VSwitchId(VSwitchId)
    response = client.do_action_with_exception(request)
    print response
def create_load_balancer(params):
    '''
    create_load_balancer:创建slb实例
    官网API参考链接:https://help.aliyun.com/document_detail/27577.html
    '''
    counter = 0
    while counter < TRY_TIME:
        try:
            request = CreateLoadBalancerRequest.CreateLoadBalancerRequest()
            #公网类型实例的付费方式
            request.set_LoadBalancerName(params["LoadBalancerName"])
            response = client.do_action_with_exception(request)
            response_json = json.loads(response)
            return response_json
        except ServerException as e:
            ExceptionHandler.server_exception(e)
        except ClientException as e:
            ExceptionHandler.client_exception(e)
        finally:
            counter += 1
Beispiel #5
0
def create_load_balancer(params):
    '''
    create_load_balancer:创建slb实例
    官网API参考链接:https://help.aliyun.com/document_detail/27577.html
    '''
    try:
        # 设置创建SLB实例的调用参数
        request = CreateLoadBalancerRequest.CreateLoadBalancerRequest()
        request.set_MasterZoneId(params["master_zone_id"])
        request.set_SlaveZoneId(params["slave_zone_id"])
        request.set_LoadBalancerName(params["load_balancer_name"])
        request.set_PayType(params["pay_balancer_type"])
        # 发送调用请求并接收返回数据
        response = ACS_CLIENT.do_action_with_exception(request)
        response_json = json.loads(response)
        # 返回结果
        return response_json
    except ServerException as e:
        ExceptionHandler.server_exception(e)
    except ClientException as e:
        ExceptionHandler.client_exception(e)
Beispiel #6
0
 def create_slb(self, **kwargs):
     request = CreateLoadBalancerRequest.CreateLoadBalancerRequest()
     for k, v in kwargs.items():
         request.add_query_param(k, v)
     result = self.client.do_action(request)
     return result