bundles/powerdns: user resolve_identifier() for node-dns-entries
This commit is contained in:
parent
5ffaa9b1c8
commit
607da9d39b
1 changed files with 21 additions and 9 deletions
|
@ -75,17 +75,29 @@ def generate_dns_entries_for_nodes(metadata):
|
||||||
ip4 = None
|
ip4 = None
|
||||||
ip6 = None
|
ip6 = None
|
||||||
|
|
||||||
# We only need this for GCE, because machines over there don't
|
ips = repo.libs.tools.resolve_identifier(repo, rnode.name)
|
||||||
# have a public ipv4 address.
|
for ip in ips:
|
||||||
if rnode.metadata.get('external_ipv4', None):
|
if (
|
||||||
ip4 = rnode.metadata.get('external_ipv4')
|
not ip4 and
|
||||||
|
not ip.is_private and
|
||||||
|
'.' in str(ip) # poor-mans 'is this ipv4' detection
|
||||||
|
):
|
||||||
|
ip4 = ip
|
||||||
|
|
||||||
for iface, config in sorted(rnode.metadata.get('interfaces', {}).items()):
|
if (
|
||||||
if not ip4 and 'ipv4' in config:
|
not ip6 and
|
||||||
ip4 = sorted(config['ipv4'])[0]
|
not ip.is_private and
|
||||||
|
':' in str(ip)
|
||||||
|
):
|
||||||
|
ip6 = ip
|
||||||
|
|
||||||
if not ip6 and 'ipv6' in config:
|
# We're doing this once again to get the nodes which only have
|
||||||
ip6 = sorted(config['ipv6'])[0]
|
# private ips.
|
||||||
|
if not ip4:
|
||||||
|
for ip in ips:
|
||||||
|
if '.' in str(ip):
|
||||||
|
ip4 = ip
|
||||||
|
break
|
||||||
|
|
||||||
if ip4:
|
if ip4:
|
||||||
results.add('{} IN A {}'.format(dns_name, ip4))
|
results.add('{} IN A {}'.format(dns_name, ip4))
|
||||||
|
|
Loading…
Reference in a new issue