예제 #1
0
    def get_tcp_listener(self, load_balancer_id, listener_port):
        """Get the TCP Listener from an SLB ID and port

        Args:
            load_balancer_id (str): SLB ID
            listener_port (int): SLB Listener port. Between 1 and 65535.

        Returns:
            TCPListener
        """
        params = {
            'Action': 'DescribeLoadBalancerTCPListenerAttribute',
            'LoadBalancerId': load_balancer_id,
            'ListenerPort': listener_port
        }
        resp = self.get(params)

        if 'ConnectPort' not in resp:
            resp['ConnectPort'] = resp['BackendServerPort']

        return TCPListener(load_balancer_id,
                           int(resp['ListenerPort']),
                           int(resp['BackendServerPort']),
                           listener_status=resp['Status'],
                           scheduler=resp['Scheduler'] or None,
                           health_check=resp['HealthCheck'] == 'on',
                           connect_port=int(resp['ConnectPort']) or None,
                           persistence_timeout=int(resp['PersistenceTimeout']))
예제 #2
0
 def testRepr(self):
     listener = TCPListener('id', 1, 1)
     self.assertTrue(repr(listener).startswith(u'<TCPListener on 1 for id'))
예제 #3
0
 def testNotEqual(self):
     l1 = TCPListener('id', 1, 1)
     l2 = TCPListener('id', 1, 2)
     self.assertNotEqual(l1, l2)