mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
This commit is contained in:
parent
bc741eb2a0
commit
2939f68897
1 changed files with 4 additions and 7 deletions
|
@ -161,6 +161,7 @@ from ansible.module_utils.docker_common import AnsibleDockerClient, DockerBaseCl
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from docker import utils
|
from docker import utils
|
||||||
|
from docker.errors import NotFound
|
||||||
if HAS_DOCKER_PY_2 or HAS_DOCKER_PY_3:
|
if HAS_DOCKER_PY_2 or HAS_DOCKER_PY_3:
|
||||||
from docker.types import IPAMPool, IPAMConfig
|
from docker.types import IPAMPool, IPAMConfig
|
||||||
except Exception as dummy:
|
except Exception as dummy:
|
||||||
|
@ -215,14 +216,10 @@ class DockerNetworkManager(object):
|
||||||
self.absent()
|
self.absent()
|
||||||
|
|
||||||
def get_existing_network(self):
|
def get_existing_network(self):
|
||||||
networks = self.client.networks(names=[self.parameters.network_name])
|
try:
|
||||||
# check if a user is trying to find network by its Id
|
return self.client.inspect_network(self.parameters.network_name)
|
||||||
if not networks:
|
except NotFound:
|
||||||
networks = self.client.networks(ids=[self.parameters.network_name])
|
|
||||||
if not networks:
|
|
||||||
return None
|
return None
|
||||||
else:
|
|
||||||
return networks[0]
|
|
||||||
|
|
||||||
def has_different_config(self, net):
|
def has_different_config(self, net):
|
||||||
'''
|
'''
|
||||||
|
|
Loading…
Add table
Reference in a new issue