This commit is contained in:
Franzi 2023-12-16 10:23:44 +01:00
parent 24373d0ac9
commit b11fece803
Signed by: kunsi
GPG key ID: 12E3D2136B818350
7 changed files with 8 additions and 198 deletions

View file

@ -335,19 +335,14 @@ for rnode in sorted(repo.nodes):
host_ips = repo.libs.tools.resolve_identifier(repo, rnode.name, only_physical=True)
icinga_ips = {}
# XXX for the love of god, PLEASE remove this once DNS is no longer
# hosted at GCE
if rnode.in_group('gce'):
icinga_ips['ipv4'] = rnode.metadata.get('external_ipv4')
else:
for ip_type in ('ipv4', 'ipv6'):
for ip in sorted(host_ips[ip_type]):
if ip.is_private and not ip.is_link_local:
icinga_ips[ip_type] = str(ip)
break
else:
if host_ips[ip_type]:
icinga_ips[ip_type] = sorted(host_ips[ip_type])[0]
for ip_type in ('ipv4', 'ipv6'):
for ip in sorted(host_ips[ip_type]):
if ip.is_private and not ip.is_link_local:
icinga_ips[ip_type] = str(ip)
break
else:
if host_ips[ip_type]:
icinga_ips[ip_type] = sorted(host_ips[ip_type])[0]
if not icinga_ips:
raise ValueError(f'{rnode.name} requests monitoring, but has neither IPv4 nor IPv6 addresses!')