ignore docker networks without 'IPAM' attr
This commit is contained in:
parent
90eae3ed7f
commit
be211eefea
|
@ -137,6 +137,7 @@ def get_docker_networks():
|
||||||
|
|
||||||
# Iterate through each network to gather details
|
# Iterate through each network to gather details
|
||||||
for network in networks:
|
for network in networks:
|
||||||
|
try:
|
||||||
network_details = {
|
network_details = {
|
||||||
'Name': network.name,
|
'Name': network.name,
|
||||||
'ID': network.id,
|
'ID': network.id,
|
||||||
|
@ -147,12 +148,15 @@ def get_docker_networks():
|
||||||
|
|
||||||
# IPAM Config might have multiple configurations. Gather them.
|
# IPAM Config might have multiple configurations. Gather them.
|
||||||
ipam_configs = network.attrs.get('IPAM', {}).get('Config', [])
|
ipam_configs = network.attrs.get('IPAM', {}).get('Config', [])
|
||||||
|
if type(ipam_configs) == list:
|
||||||
for config in ipam_configs:
|
for config in ipam_configs:
|
||||||
subnet = config.get('Subnet', 'Not specified')
|
subnet = config.get('Subnet', 'Not specified')
|
||||||
gateway = config.get('Gateway', 'Not specified')
|
gateway = config.get('Gateway', 'Not specified')
|
||||||
network_details['IPAM'].append({'Subnet': subnet, 'Gateway': gateway})
|
network_details['IPAM'].append({'Subnet': subnet, 'Gateway': gateway})
|
||||||
|
|
||||||
networks_list.append(network_details)
|
networks_list.append(network_details)
|
||||||
|
except Exception as e:
|
||||||
|
pass
|
||||||
|
|
||||||
return networks_list
|
return networks_list
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
Loading…
Reference in New Issue