1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Fix bug in counting subnets by Name tag (#1643)

Fixes #1551
This commit is contained in:
George Christou 2016-08-15 08:02:21 +01:00 committed by Matt Clay
parent e863dcc92a
commit d6f62694e2

View file

@ -186,11 +186,11 @@ def find_subnets(vpc_conn, vpc_id, identified_subnets):
filters={'vpc_id': vpc_id, 'tag:Name': subnet_names}) filters={'vpc_id': vpc_id, 'tag:Name': subnet_names})
for name in subnet_names: for name in subnet_names:
matching = [s.tags.get('Name') == name for s in subnets_by_name] matching_count = len([1 for s in subnets_by_name if s.tags.get('Name') == name])
if len(matching) == 0: if matching_count == 0:
raise AnsibleSubnetSearchException( raise AnsibleSubnetSearchException(
'Subnet named "{0}" does not exist'.format(name)) 'Subnet named "{0}" does not exist'.format(name))
elif len(matching) > 1: elif matching_count > 1:
raise AnsibleSubnetSearchException( raise AnsibleSubnetSearchException(
'Multiple subnets named "{0}"'.format(name)) 'Multiple subnets named "{0}"'.format(name))