Exemplo n.º 1
0
 def startElement(self, name, attrs, connection):
     if name == 'HealthCheck':
         self.health_check = HealthCheck(self)
         return self.health_check
     elif name == 'ListenerDescriptions':
         self.listeners = ResultSet([('member', Listener)])
         return self.listeners
     elif name == 'AvailabilityZones':
         return self.availability_zones
     elif name == 'Instances':
         self.instances = ResultSet([('member', InstanceInfo)])
         return self.instances
     elif name == 'Policies':
         self.policies = Policies(self)
         return self.policies
     elif name == 'SourceSecurityGroup':
         self.source_security_group = SecurityGroup()
         return self.source_security_group
     elif name == 'Subnets':
         return self.subnets
     elif name == 'SecurityGroups':
         return self.security_groups
     elif name == 'VPCId':
         pass
     else:
         return None
Exemplo n.º 2
0
    def __init__(self, name, zones, ports, scheme='internet-facing', vpc_id=None, subnets=None):
        self.name = name
        self.health_check = None
        self.instance_ids = []
        self.zones = zones
        self.listeners = []
        self.backends = []
        self.scheme = scheme
        self.attributes = FakeLoadBalancer.get_default_attributes()
        self.policies = Policies()
        self.policies.other_policies = []
        self.policies.app_cookie_stickiness_policies = []
        self.policies.lb_cookie_stickiness_policies = []
        self.subnets = subnets or []
        self.vpc_id = vpc_id or 'vpc-56e10e3d'
        self.tags = {}
        self.dns_name = "tests.us-east-1.elb.amazonaws.com"

        for port in ports:
            listener = FakeListener(
                protocol=(port.get('protocol') or port['Protocol']),
                load_balancer_port=(port.get('load_balancer_port') or port['LoadBalancerPort']),
                instance_port=(port.get('instance_port') or port['InstancePort']),
                ssl_certificate_id=port.get('sslcertificate_id', port.get('SSLCertificateId')),
            )
            self.listeners.append(listener)

            # it is unclear per the AWS documentation as to when or how backend
            # information gets set, so let's guess and set it here *shrug*
            backend = FakeBackend(
                instance_port=(port.get('instance_port') or port['InstancePort']),
            )
            self.backends.append(backend)
Exemplo n.º 3
0
    def __init__(self, name, zones, ports):
        self.name = name
        self.health_check = None
        self.instance_ids = []
        self.zones = zones
        self.listeners = []
        self.backends = []
        self.attributes = FakeLoadBalancer.get_default_attributes()
        self.policies = Policies()
        self.policies.other_policies = []
        self.policies.app_cookie_stickiness_policies = []
        self.policies.lb_cookie_stickiness_policies = []

        for port in ports:
            listener = FakeListener(
                protocol=port['protocol'],
                load_balancer_port=port['load_balancer_port'],
                instance_port=port['instance_port'],
                ssl_certificate_id=port.get('sslcertificate_id'),
            )
            self.listeners.append(listener)

            # it is unclear per the AWS documentation as to when or how backend
            # information gets set, so let's guess and set it here *shrug*
            backend = FakeBackend(instance_port=port['instance_port'], )
            self.backends.append(backend)
Exemplo n.º 4
0
    def __init__(
        self,
        name,
        zones,
        ports,
        scheme="internet-facing",
        vpc_id=None,
        subnets=None,
        security_groups=None,
    ):
        self.name = name
        self.health_check = None
        self.instance_ids = []
        self.zones = zones
        self.listeners = []
        self.backends = []
        self.created_time = datetime.datetime.now()
        self.scheme = scheme
        self.attributes = FakeLoadBalancer.get_default_attributes()
        self.policies = Policies()
        self.policies.other_policies = []
        self.policies.app_cookie_stickiness_policies = []
        self.policies.lb_cookie_stickiness_policies = []
        self.security_groups = security_groups or []
        self.subnets = subnets or []
        self.vpc_id = vpc_id or "vpc-56e10e3d"
        self.tags = {}
        self.dns_name = "%s.us-east-1.elb.amazonaws.com" % (name)

        for port in ports:
            listener = FakeListener(
                protocol=(port.get("protocol") or port["Protocol"]),
                load_balancer_port=(
                    port.get("load_balancer_port") or port["LoadBalancerPort"]
                ),
                instance_port=(port.get("instance_port") or port["InstancePort"]),
                ssl_certificate_id=port.get(
                    "ssl_certificate_id", port.get("SSLCertificateId")
                ),
            )
            self.listeners.append(listener)

            # it is unclear per the AWS documentation as to when or how backend
            # information gets set, so let's guess and set it here *shrug*
            backend = FakeBackend(
                instance_port=(port.get("instance_port") or port["InstancePort"])
            )
            self.backends.append(backend)
Exemplo n.º 5
0
 def startElement(self, name, attrs, connection):
     if name == 'HealthCheck':
         self.health_check = HealthCheck(self)
         return self.health_check
     elif name == 'ListenerDescriptions':
         self.listeners = ResultSet([('member', Listener)])
         return self.listeners
     elif name == 'AvailabilityZones':
         return self.availability_zones
     elif name == 'Instances':
         self.instances = ResultSet([('member', InstanceInfo)])
         return self.instances
     elif name == 'Policies':
         self.policies = Policies(self)
         return self.policies
     else:
         return None