ec2_group: prioritise current VPC group names over others

This commit is contained in:
zimbatm 2015-04-28 10:19:20 +01:00 committed by Matt Clay
parent c3e720a393
commit 933256fc63

View file

@ -223,6 +223,11 @@ def main():
groups = {} groups = {}
for curGroup in ec2.get_all_security_groups(): for curGroup in ec2.get_all_security_groups():
groups[curGroup.id] = curGroup groups[curGroup.id] = curGroup
if curGroup.name in groups:
# Prioritise groups from the current VPC
if vpc_id is None or curGroup.vpc_id == vpc_id:
groups[curGroup.name] = curGroup
else:
groups[curGroup.name] = curGroup groups[curGroup.name] = curGroup
if curGroup.name == name and (vpc_id is None or curGroup.vpc_id == vpc_id): if curGroup.name == name and (vpc_id is None or curGroup.vpc_id == vpc_id):