From 10aaa1137c410108f38d6314fe97e6f5578881bb Mon Sep 17 00:00:00 2001 From: Doug Ellwanger Date: Mon, 29 Sep 2014 13:02:48 -0700 Subject: [PATCH] Pull SSL certificate IDs from existing ELBs --- cloud/amazon/ec2_elb_lb.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/cloud/amazon/ec2_elb_lb.py b/cloud/amazon/ec2_elb_lb.py index d83db113963..51e135dc7ec 100644 --- a/cloud/amazon/ec2_elb_lb.py +++ b/cloud/amazon/ec2_elb_lb.py @@ -341,7 +341,7 @@ class ElbManager(object): } if check_elb.listeners: - info['listeners'] = [l.get_complex_tuple() + info['listeners'] = [self._api_listener_as_tuple(l) for l in check_elb.listeners] elif self.status == 'created': # 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 # single match on the incomping port is all we're looking for 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 if existing_listener_found: @@ -451,7 +451,7 @@ class ElbManager(object): # Check for any extraneous listeners we need to remove, if desired if self.purge_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: # Already queued for removal continue @@ -468,6 +468,13 @@ class ElbManager(object): if 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): """Formats listener as a 4- or 5-tuples, in the order specified by the ELB API"""