fix: stop ip address gathering after first found (#156)

This commit is contained in:
Robert Kaussow 2022-02-27 16:04:01 +01:00 committed by GitHub
parent fae8aaafbb
commit 573384e6dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -109,14 +109,13 @@ class Discovery():
except Exception: # noqa # nosec except Exception: # noqa # nosec
pass pass
if networks: 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["ip-addresses"]: if ip_address["ip-address-type"] == "ipv4" and not ipv4_address:
if ip_address["ip-address-type"] == "ipv4": ipv4_address = self._validate_ip(ip_address["ip-address"])
ipv4_address = validate_ip(ip_address["ip-address"]) elif ip_address["ip-address-type"] == "ipv6" and not ipv6_address:
elif ip_address["ip-address-type"] == "ipv6": ipv6_address = self._validate_ip(ip_address["ip-address"])
ipv6_address = validate_ip(ip_address["ip-address"])
if not ipv4_address: if not ipv4_address:
try: try:
@ -218,7 +217,7 @@ class Discovery():
except ValueError: except ValueError:
metadata = {"notes": description} metadata = {"notes": description}
ipv4_address, ipv6_address = self._get_ip_addresses(pve_type, node, vmid) or host ipv4_address, ipv6_address = self._get_ip_addresses(pve_type, node, vmid)
prom_host = Host(vmid, host, ipv4_address, ipv6_address, pve_type) prom_host = Host(vmid, host, ipv4_address, ipv6_address, pve_type)