fix: fix error for interfaces without ip addresses (#200)

This commit is contained in:
Jan Tomsa 2022-04-06 10:10:29 +02:00 committed by GitHub
parent 9968fdc9c4
commit fb1f93b19c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -68,7 +68,7 @@ class Discovery():
if type(networks) is list: if type(networks) is list:
for network in networks: for network in networks:
for ip_address in network["ip-addresses"]: for ip_address in network.get("ip-addresses", []):
if ip_address["ip-address-type"] == "ipv4" and not ipv4_address: if ip_address["ip-address-type"] == "ipv4" and not ipv4_address:
ipv4_address = self._validate_ip(ip_address["ip-address"]) ipv4_address = self._validate_ip(ip_address["ip-address"])
elif ip_address["ip-address-type"] == "ipv6" and not ipv6_address: elif ip_address["ip-address-type"] == "ipv6" and not ipv6_address:

View File

@ -350,6 +350,10 @@ def networks():
"tx-packets": 14423878 "tx-packets": 14423878
} }
}, },
{
"hardware-address": "ba:97:85:bd:9a:a5",
"name": "eth1"
},
] ]