def set_listener_attribute()

in footmark/slb/connection.py [0:0]


    def set_listener_attribute(self, load_balancer_id,\
                                    listener_port,\
                                    bandwidth,\
                                    protocol,\
                                    sticky_session='',\
                                    health_check='',\
                                    scheduler='',\
                                    sticky_session_type='',\
                                    cookie_timeout=None,\
                                    cookie='',\
                                    health_check_domain='',\
                                    health_check_uri='',\
                                    health_check_connect_port=None,\
                                    healthy_threshold=None,\
                                    unhealthy_threshold=None,\
                                    health_check_timeout=None,\
                                    health_check_interval=None,\
                                    health_check_http_code='',\
                                    vserver_group_id='',\
                                    gzip='',\
                                    server_certificate_id='',\
                                    master_slave_server_group_id='',\
                                    persistence_timeout=None,\
                                    health_check_connect_timeout=None,\
                                    ca_certificate_id='',\
                                    syn_proxy='',\
                                    health_check_type='',\
                                    vserver_group='',\
                                    master_slave_server_group='',
                                    xforwarded_for='on'):
        """
        set listener attribute
        :type load_balancer_id: string
        :param load_balancer_id: load balance id
        :type listener_port: int
        :param listener_port: Server Load Balancer instance frontend port. Value: 1-65535
        :type bandwidth: int
        :param bandwidth: Listener bandwidth. Value: -1 / 1-1000 Mbps
        :type sticky_session: string
        :param sticky_session: Whether to open the Gzip compression
        :type protocol: string
        :param protocol: type of listener to create
        :type health_check: string
        :param health_check: Whether to enable health check
        :type: scheduler: string
        :param: scheduler: Scheduling algorithm. Value: wrr / wlc / rr Default value: wrr
        :type: sticky_session_type: string
        :param: sticky_session_type: Mode for handling the cookie.
        :type: cookie_timeout: int
        :param: cookie_timeout: Cookie timeout.
        :type: cookie: string
        :param: cookie: The cookie configured on the server
        :type: health_check_domain: string
        :param: health_check_domain: Domain name used for health check.
        :type: health_check_uri: string
        :param: health_check_uri: URI used for health check
        :type: health_check_connect_port: int
        :param: health_check_connect_port: Port used for health check.
        :type: healthy_threshold: int
        :param: healthy_threshold: Threshold determining the result of the health check is success.
        :type: unhealthy_threshold: int
        :param: unhealthy_threshold: Threshold determining the result of the health check is fail.
        :type: health_check_timeout: int
        :param: health_check_timeout: Maximum timeout of each health check response.
        :type: health_check_http_code: string
        :param: health_check_http_code: Regular health check HTTP status code. Multiple codes are segmented by ",".
        :type: health_check_interval: int
        :param: health_check_interval: Time interval of health checks.
        :type: vserver_group_id: string
        :param: vserver_group_id: Virtual server group ID.
        :type: gzip: string
        :param: gzip: whether open Gzip compression
        :type: server_certificate_id: string
        :param: server_certificate_id: Server certificate ID.
        :type: master_slave_server_group_id: string
        :param: master_slave_server_group_id: Master standby server group ID
        :type: persistence_timeout: string
        :param: persistence_timeout: Timeout time for connection persistence.
        :type: health_check_connect_timeout: int
        :param: health_check_connect_timeout: Health check connection timeout.
        :type: xforwarded_for: int
        :param: xforwarded_for: Whether open access to the actual IP of visitors through X-Forwarded-For
        :type: ca_certificate_id: string
        :param: ca_certificate_id: CA certificate ID
        :type: syn_proxy: string
        :param: syn_proxy: CA certificate ID
        :type: health_check_type: string
        :param: health_check_type: health check type
        :type: vserver_group: string
        :param: vserver_group: Whether to use a virtual server group
        :type: master_slave_server_group: string
        :param: master_slave_server_group: Whether to use the primary and secondary server groups
        :return: returns request status
        """
        params = {}
        listener_type_dic = dict(http="SetLoadBalancerHTTPListenerAttribute",\
                                 https= "SetLoadBalancerHTTPSListenerAttribute",\
                                 tcp="SetLoadBalancerTCPListenerAttribute",\
                                 udp="SetLoadBalancerUDPListenerAttribute")
        key = listener_type_dic.get(protocol, '')

        self.build_list_params(params, load_balancer_id, 'LoadBalancerId')
        self.build_list_params(params, listener_port, 'ListenerPort')
        self.build_list_params(params, bandwidth, 'Bandwidth')
        if listener_port:
            self.build_list_params(params, listener_port, 'ListenerPort')
        if health_check:
            self.build_list_params(params, health_check, 'HealthCheck')
        if sticky_session:
            self.build_list_params(params, sticky_session, 'StickySession')
        if server_certificate_id:
            self.build_list_params(params, server_certificate_id, 'ServerCertificateId')
        if scheduler:
            self.build_list_params(params, scheduler, 'Scheduler')
        if xforwarded_for:
            self.build_list_params(params, 'on', 'XForwardedFor')
        if sticky_session_type:
            self.build_list_params(params, sticky_session_type, 'StickySessionType')
        if cookie_timeout:
            self.build_list_params(params, cookie_timeout, 'CookieTimeout')
        if cookie:
            self.build_list_params(params, cookie, 'Cookie')
        if health_check_domain:
            self.build_list_params(params, health_check_domain, 'HealthCheckDomain')
        if health_check_uri:
            self.build_list_params(params, health_check_uri, 'HealthCheckURI')
        if health_check_connect_port:
            self.build_list_params(params, health_check_connect_port, 'HealthCheckConnectPort')
        if healthy_threshold:
            self.build_list_params(params, healthy_threshold, 'HealthyThreshold')
        if unhealthy_threshold:
            self.build_list_params(params, unhealthy_threshold, 'UnhealthyThreshold')
        if health_check_timeout:
            self.build_list_params(params, health_check_timeout, 'HealthCheckTimeout')
        if health_check_interval:
            self.build_list_params(params, health_check_interval, 'HealthCheckInterval')
        if health_check_http_code:
            self.build_list_params(params, health_check_http_code, 'HealthCheckHttpCode')
        if vserver_group:
            self.build_list_params(params, vserver_group, 'VServerGroup')
        if vserver_group_id:
            self.build_list_params(params, vserver_group_id, 'VServerGroupId')
        if master_slave_server_group_id:
            self.build_list_params(params, master_slave_server_group_id, 'MasterSlaveServerGroupId')
        if master_slave_server_group:
            self.build_list_params(params, master_slave_server_group, 'MasterSlaveServerGroup')
        if ca_certificate_id:
            self.build_list_params(params, ca_certificate_id, 'CACertificateId')
        if syn_proxy:
            self.build_list_params(params, syn_proxy, 'SynProxy')
        if health_check_type:
            self.build_list_params(params, health_check_type, 'HealthCheckType')
        if gzip:
            self.build_list_params(params, gzip, 'Gzip')
        if persistence_timeout:
            self.build_list_params(params, persistence_timeout, 'PersistenceTimeout')
        if health_check_connect_timeout:
            self.build_list_params(params, health_check_connect_timeout, 'HealthCheckConnectTimeout')

        return self.get_status(key, params)