ec2_vpc_subnet - Use dict constructor instead of comprehension.

This commit is contained in:
Robert Estelle 2014-12-03 13:24:54 -05:00 committed by whiter
parent e33de8bd88
commit 3b38209afd

View file

@ -162,8 +162,8 @@ def create_subnet(vpc_conn, vpc_id, cidr, az):
def get_resource_tags(vpc_conn, resource_id): def get_resource_tags(vpc_conn, resource_id):
return {t.name: t.value for t in return dict((t.name, t.value) for t in
vpc_conn.get_all_tags(filters={'resource-id': resource_id})} vpc_conn.get_all_tags(filters={'resource-id': resource_id}))
def ensure_tags(vpc_conn, resource_id, tags, add_only, check_mode): def ensure_tags(vpc_conn, resource_id, tags, add_only, check_mode):
@ -172,11 +172,11 @@ def ensure_tags(vpc_conn, resource_id, tags, add_only, check_mode):
if cur_tags == tags: if cur_tags == tags:
return {'changed': False, 'tags': cur_tags} return {'changed': False, 'tags': cur_tags}
to_delete = {k: cur_tags[k] for k in cur_tags if k not in tags} to_delete = dict((k, cur_tags[k]) for k in cur_tags if k not in tags)
if to_delete and not add_only: if to_delete and not add_only:
vpc_conn.delete_tags(resource_id, to_delete, dry_run=check_mode) vpc_conn.delete_tags(resource_id, to_delete, dry_run=check_mode)
to_add = {k: tags[k] for k in tags if k not in cur_tags} to_add = dict((k, tags[k]) for k in tags if k not in cur_tags)
if to_add: if to_add:
vpc_conn.create_tags(resource_id, to_add, dry_run=check_mode) vpc_conn.create_tags(resource_id, to_add, dry_run=check_mode)