From 272c0ce68c714836da03c7962c68b4dd99dce1e3 Mon Sep 17 00:00:00 2001 From: Abdul Anshad A Date: Thu, 31 Aug 2017 03:02:45 +0530 Subject: [PATCH] fixes #5732 - Add support for using network ID (#22503) --- lib/ansible/modules/cloud/docker/docker_network.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/ansible/modules/cloud/docker/docker_network.py b/lib/ansible/modules/cloud/docker/docker_network.py index 3c0f581ba1..1cf2c52108 100644 --- a/lib/ansible/modules/cloud/docker/docker_network.py +++ b/lib/ansible/modules/cloud/docker/docker_network.py @@ -208,12 +208,14 @@ class DockerNetworkManager(object): self.absent() def get_existing_network(self): - networks = self.client.networks() - network = None - for n in networks: - if n['Name'] == self.parameters.network_name: - network = n - return network + networks = self.client.networks(names=[self.parameters.network_name]) + # check if a user is trying to find network by its Id + if not networks: + networks = self.client.networks(ids=[self.parameters.network_name]) + if not networks: + return None + else: + return networks[0] def has_different_config(self, net): '''