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

Fixed #21464 - docker_network: TypeError with existing network (#24266)

Fixed #22530 - docker_network Failed but Overlay network created successfully on Docker swarm mode
This commit is contained in:
Nikolay Murga 2017-05-25 00:21:24 +03:00 committed by Toshio Kuratomi
parent cb3026f769
commit 3610a2457f

View file

@ -194,8 +194,7 @@ class TaskParameters(DockerBaseClass):
def container_names_in_network(network):
return [c['Name'] for c in network['Containers'].values()]
return [c['Name'] for c in network['Containers'].values()] if network['Containers'] else []
class DockerNetworkManager(object):
@ -247,7 +246,7 @@ class DockerNetworkManager(object):
differences.append('driver_options')
else:
for key, value in self.parameters.driver_options.items():
if not net['Options'].get(key) or value != net['Options'][key]:
if not (key in net['Options']) or value != net['Options'][key]:
different = True
differences.append('driver_options.%s' % key)
if self.parameters.ipam_driver:
@ -321,13 +320,18 @@ class DockerNetworkManager(object):
self.results['changed'] = True
def disconnect_missing(self):
for c in self.existing_network['Containers'].values():
containers = self.existing_network['Containers']
if not containers:
return
for c in containers.values():
name = c['Name']
if name not in self.parameters.connected:
self.disconnect_container(name)
def disconnect_all_containers(self):
containers = self.client.inspect_network(self.parameters.network_name)['Containers']
if not containers:
return
for cont in containers.values():
self.disconnect_container(cont['Name'])