From 906b63b12345da89592684cc23403d71d9041193 Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Tue, 4 Jan 2022 11:41:31 +0100 Subject: [PATCH] move hostname stuff to libs.tools.resolve_identifier --- bundles/powerdns/metadata.py | 12 ------------ libs/tools.py | 5 +++++ 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/bundles/powerdns/metadata.py b/bundles/powerdns/metadata.py index 234a3b7..57f46f5 100644 --- a/bundles/powerdns/metadata.py +++ b/bundles/powerdns/metadata.py @@ -159,18 +159,6 @@ def generate_dns_entries_for_nodes(metadata): if not ip4 and isinstance(addr, IPv4Address): 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: results.add('{} IN A {}'.format(dns_name, ip4)) diff --git a/libs/tools.py b/libs/tools.py index eacbc9d..8e225a5 100644 --- a/libs/tools.py +++ b/libs/tools.py @@ -42,6 +42,11 @@ def resolve_identifier(repo, identifier): if node.metadata.get('external_ipv4', None): found_ips.add(ip_address(node.metadata.get('external_ipv4'))) + try: + found_ips.add(ip_address(node.hostname)) + except ValueError: + pass + ip_dict = { 'ipv4': set(), 'ipv6': set(),