diff --git a/lib/docker_interface.py b/lib/docker_interface.py index 287b47c..8dd858b 100644 --- a/lib/docker_interface.py +++ b/lib/docker_interface.py @@ -137,22 +137,26 @@ def get_docker_networks(): # Iterate through each network to gather details for network in networks: - network_details = { - 'Name': network.name, - 'ID': network.id, - 'Driver': network.attrs["Driver"], - 'Scope': network.attrs["Scope"], - 'IPAM': [] - } - - # IPAM Config might have multiple configurations. Gather them. - ipam_configs = network.attrs.get('IPAM', {}).get('Config', []) - for config in ipam_configs: - subnet = config.get('Subnet', 'Not specified') - gateway = config.get('Gateway', 'Not specified') - network_details['IPAM'].append({'Subnet': subnet, 'Gateway': gateway}) - - networks_list.append(network_details) + try: + network_details = { + 'Name': network.name, + 'ID': network.id, + 'Driver': network.attrs["Driver"], + 'Scope': network.attrs["Scope"], + 'IPAM': [] + } + + # IPAM Config might have multiple configurations. Gather them. + ipam_configs = network.attrs.get('IPAM', {}).get('Config', []) + if type(ipam_configs) == list: + for config in ipam_configs: + subnet = config.get('Subnet', 'Not specified') + gateway = config.get('Gateway', 'Not specified') + network_details['IPAM'].append({'Subnet': subnet, 'Gateway': gateway}) + + networks_list.append(network_details) + except Exception as e: + pass return networks_list except Exception as e: