Ensures we can get multiple endpoints with the same name but different ports. (#1011)

This commit is contained in:
kevgliss 2017-12-04 13:13:02 -08:00 committed by GitHub
parent c311c0a221
commit a756a74b49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 4 deletions

View File

@ -60,6 +60,16 @@ def get_by_dnsname(dnsname):
return database.get(Endpoint, dnsname, field='dnsname') return database.get(Endpoint, dnsname, field='dnsname')
def get_by_dnsname_and_port(dnsname, port):
"""
Retrieves and endpoint by it's dnsname and port.
:param dnsname:
:param port:
:return:
"""
return Endpoint.query.filter(Endpoint.dnsname == dnsname).filter(Endpoint.port == port).scalar()
def get_by_source(source_label): def get_by_source(source_label):
""" """
Retrieves all endpoints for a given source. Retrieves all endpoints for a given source.

View File

@ -109,6 +109,8 @@ def get_elb_endpoints(account_number, region, elb_dict):
account_number=account_number, region=region) account_number=account_number, region=region)
endpoint['policy'] = format_elb_cipher_policy(policy) endpoint['policy'] = format_elb_cipher_policy(policy)
current_app.logger.debug("Found new endpoint. Endpoint: {}".format(endpoint))
endpoints.append(endpoint) endpoints.append(endpoint)
return endpoints return endpoints

View File

@ -22,8 +22,6 @@ def sts_client(service, service_type='client'):
current_app.config.get('LEMUR_INSTANCE_PROFILE', 'Lemur') current_app.config.get('LEMUR_INSTANCE_PROFILE', 'Lemur')
) )
current_app.logger.debug('Assuming Role. Role: {0}'.format(arn))
# TODO add user specific information to RoleSessionName # TODO add user specific information to RoleSessionName
role = sts.assume_role(RoleArn=arn, RoleSessionName='lemur') role = sts.assume_role(RoleArn=arn, RoleSessionName='lemur')

View File

@ -72,7 +72,7 @@ def sync_endpoints(source):
return new, updated return new, updated
for endpoint in endpoints: for endpoint in endpoints:
exists = endpoint_service.get_by_dnsname(endpoint['dnsname']) exists = endpoint_service.get_by_dnsname_and_port(endpoint['dnsname'], endpoint['port'])
certificate_name = endpoint.pop('certificate_name') certificate_name = endpoint.pop('certificate_name')
@ -99,7 +99,7 @@ def sync_endpoints(source):
new += 1 new += 1
else: else:
current_app.logger.debug("Endpoint Updated: Name: {name}".format(name=endpoint['name'])) current_app.logger.debug("Endpoint Updated: {}".format(endpoint))
endpoint_service.update(exists.id, **endpoint) endpoint_service.update(exists.id, **endpoint)
updated += 1 updated += 1