Small code cleanup

This commit is contained in:
Toshio Kuratomi 2015-03-03 12:07:42 -08:00
parent d80b7d3356
commit 9f38f6e6a2

View file

@ -793,17 +793,13 @@ def create_instances(module, ec2, vpc, override_count=None):
grp_details = ec2.get_all_security_groups(filters={'vpc_id': vpc_id}) grp_details = ec2.get_all_security_groups(filters={'vpc_id': vpc_id})
else: else:
grp_details = ec2.get_all_security_groups() grp_details = ec2.get_all_security_groups()
if type(group_name) == list: if isinstance(group_name, basestring):
group_id = [ str(grp.id) for grp in grp_details if str(grp.name) in group_name ]
elif type(group_name) == str:
for grp in grp_details:
if str(group_name) in str(grp):
group_id = [str(grp.id)]
group_name = [group_name] group_name = [group_name]
group_id = [ str(grp.id) for grp in grp_details if str(grp.name) in group_name ]
# Now we try to lookup the group id testing if group exists. # Now we try to lookup the group id testing if group exists.
elif group_id: elif group_id:
#wrap the group_id in a list if it's not one already #wrap the group_id in a list if it's not one already
if type(group_id) == str: if isinstance(group_id, basestring):
group_id = [group_id] group_id = [group_id]
grp_details = ec2.get_all_security_groups(group_ids=group_id) grp_details = ec2.get_all_security_groups(group_ids=group_id)
group_name = [grp_item.name for grp_item in grp_details] group_name = [grp_item.name for grp_item in grp_details]