Fix python 3 compatibility for network id lookup (#45467)

Due to a change in python 3 filters return filter instead of list. This breaks the network name to id lookup for the docker_swarm_module. By wrapping it in list it ensures it is a list when returned and the id is extracted.
This commit is contained in:
William 2018-09-11 12:45:42 -07:00 committed by ansibot
parent e5269c047c
commit 2ea9cfcd52

View file

@ -838,7 +838,7 @@ class DockerService(DockerBaseClass):
for network_name in self.networks:
network_id = None
try:
network_id = filter(lambda n: n['name'] == network_name, docker_networks)[0]['id']
network_id = list(filter(lambda n: n['name'] == network_name, docker_networks))[0]['id']
except:
pass
if network_id: