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

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