mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 19:31:26 -07:00
[docker_network_facts] Creating docker_network_facts module (#49644)
Part of #49267
This commit is contained in:
parent
c9325ca247
commit
f545763296
6 changed files with 247 additions and 6 deletions
|
@ -457,6 +457,45 @@ class AnsibleDockerClient(Client):
|
|||
|
||||
return result
|
||||
|
||||
def get_network(self, name=None, id=None):
|
||||
'''
|
||||
Lookup a network and return the inspection results.
|
||||
'''
|
||||
if name is None and id is None:
|
||||
return None
|
||||
|
||||
result = None
|
||||
|
||||
if id is None:
|
||||
try:
|
||||
for network in self.networks():
|
||||
self.log("testing network: %s" % (network['Name']))
|
||||
if name == network['Name']:
|
||||
result = network
|
||||
break
|
||||
if network['Id'].startswith(name):
|
||||
result = network
|
||||
break
|
||||
except SSLError as exc:
|
||||
self._handle_ssl_error(exc)
|
||||
except Exception as exc:
|
||||
self.fail("Error retrieving network list: %s" % exc)
|
||||
|
||||
if result is not None:
|
||||
id = result['Id']
|
||||
|
||||
if id is not None:
|
||||
try:
|
||||
self.log("Inspecting network Id %s" % id)
|
||||
result = self.inspect_network(id)
|
||||
self.log("Completed network inspection")
|
||||
except NotFound as exc:
|
||||
return None
|
||||
except Exception as exc:
|
||||
self.fail("Error inspecting network: %s" % exc)
|
||||
|
||||
return result
|
||||
|
||||
def find_image(self, name, tag):
|
||||
'''
|
||||
Lookup an image (by name and tag) and return the inspection results.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue