Merge pull request #22 from teamdoug/devel

Pull SSL certificate IDs from existing ELBs
This commit is contained in:
Brian Coca 2015-02-16 18:49:37 -05:00
commit 6c4804e413

View file

@ -341,7 +341,7 @@ class ElbManager(object):
} }
if check_elb.listeners: if check_elb.listeners:
info['listeners'] = [l.get_complex_tuple() info['listeners'] = [self._api_listener_as_tuple(l)
for l in check_elb.listeners] for l in check_elb.listeners]
elif self.status == 'created': elif self.status == 'created':
# When creating a new ELB, listeners don't show in the # When creating a new ELB, listeners don't show in the
@ -431,7 +431,7 @@ class ElbManager(object):
# Since ELB allows only one listener on each incoming port, a # Since ELB allows only one listener on each incoming port, a
# single match on the incomping port is all we're looking for # single match on the incomping port is all we're looking for
if existing_listener[0] == listener['load_balancer_port']: if existing_listener[0] == listener['load_balancer_port']:
existing_listener_found = existing_listener.get_complex_tuple() existing_listener_found = self._api_listener_as_tuple(existing_listener)
break break
if existing_listener_found: if existing_listener_found:
@ -451,7 +451,7 @@ class ElbManager(object):
# Check for any extraneous listeners we need to remove, if desired # Check for any extraneous listeners we need to remove, if desired
if self.purge_listeners: if self.purge_listeners:
for existing_listener in self.elb.listeners: for existing_listener in self.elb.listeners:
existing_listener_tuple = existing_listener.get_complex_tuple() existing_listener_tuple = self._api_listener_as_tuple(existing_listener)
if existing_listener_tuple in listeners_to_remove: if existing_listener_tuple in listeners_to_remove:
# Already queued for removal # Already queued for removal
continue continue
@ -468,6 +468,13 @@ class ElbManager(object):
if listeners_to_add: if listeners_to_add:
self._create_elb_listeners(listeners_to_add) self._create_elb_listeners(listeners_to_add)
def _api_listener_as_tuple(self, listener):
"""Adds ssl_certificate_id to ELB API tuple if present"""
base_tuple = listener.get_complex_tuple()
if listener.ssl_certificate_id and len(base_tuple) < 5:
return base_tuple + (listener.ssl_certificate_id,)
return base_tuple
def _listener_as_tuple(self, listener): def _listener_as_tuple(self, listener):
"""Formats listener as a 4- or 5-tuples, in the order specified by the """Formats listener as a 4- or 5-tuples, in the order specified by the
ELB API""" ELB API"""