bundles/powerdns: also try to use node.hostname for dns generation

This commit is contained in:
Franzi 2022-01-04 11:36:40 +01:00
parent 226fac0d78
commit 36a4ebcdd6
Signed by: kunsi
GPG key ID: 12E3D2136B818350

View file

@ -1,4 +1,4 @@
from ipaddress import ip_address, IPv4Address from ipaddress import ip_address, IPv4Address, IPv6Address
from bundlewrap.metadata import atomic from bundlewrap.metadata import atomic
@ -159,6 +159,18 @@ def generate_dns_entries_for_nodes(metadata):
if not ip4 and isinstance(addr, IPv4Address): if not ip4 and isinstance(addr, IPv4Address):
ip4 = addr ip4 = addr
if not ip4:
try:
ip4 = IPv4Address(rnode.hostname)
except ValueError:
pass
if not ip6:
try:
ip6 = IPv6Address(rnode.hostname)
except ValueError:
pass
if ip4: if ip4:
results.add('{} IN A {}'.format(dns_name, ip4)) results.add('{} IN A {}'.format(dns_name, ip4))