Fixing Issue #27270 - EFS TypeError (#27318)

* Fixing Issue #27270 regarding a TypeError invoked by the addition of a Filter type and List type.

* Fix SecurityGroup from always being reported as changed on PY3

On Python3, filter returns a generator.  This causes us to report that
security groups are always defined on Python3 even when there are none.

Also change filter() calls into list comprehensions.
This commit is contained in:
Patrick Murray 2017-08-23 14:43:09 -04:00 committed by Toshio Kuratomi
parent 5ea8a5e34b
commit b828b5d33b

View file

@ -403,10 +403,9 @@ class EFSConnection(object):
targets_to_create, intersection, targets_to_delete = dict_diff(current_targets,
targets, True)
""" To modify mount target it should be deleted and created again """
changed = filter(
lambda sid: not targets_equal(['SubnetId', 'IpAddress', 'NetworkInterfaceId'],
current_targets[sid], targets[sid]), intersection)
# To modify mount target it should be deleted and created again
changed = [sid for sid in intersection if not targets_equal(['SubnetId', 'IpAddress', 'NetworkInterfaceId'],
current_targets[sid], targets[sid])]
targets_to_delete = list(targets_to_delete) + changed
targets_to_create = list(targets_to_create) + changed
@ -434,17 +433,16 @@ class EFSConnection(object):
)
result = True
security_groups_to_update = filter(
lambda sid: 'SecurityGroups' in targets[sid] and
current_targets[sid]['SecurityGroups'] != targets[sid]['SecurityGroups'],
intersection
)
# If no security groups were passed into the module, then do not change it.
security_groups_to_update = [sid for sid in intersection if
'SecurityGroups' in targets[sid] and
current_targets[sid]['SecurityGroups'] != targets[sid]['SecurityGroups']]
if security_groups_to_update:
for sid in security_groups_to_update:
self.connection.modify_mount_target_security_groups(
MountTargetId=current_targets[sid]['MountTargetId'],
SecurityGroups=targets[sid]['SecurityGroups']
SecurityGroups=targets[sid].get('SecurityGroups', None)
)
result = True