Merge "launch: further DNS cleanups"

This commit is contained in:
Zuul 2023-04-17 00:40:51 +00:00 committed by Gerrit Code Review
commit 0f997fc004
2 changed files with 7 additions and 9 deletions

View File

@ -22,9 +22,9 @@
import argparse
import subprocess
def print_sshfp_records(hostname, ip):
def print_sshfp_records(host, ip):
'''Given a hostname and and IP address, scan the IP address (hostname
not in dns yet) and return a bind string with sshfp records'''
not in dns yet) and print the sshfp records in standard bind format'''
p = ['ssh-keyscan', '-D', ip]
s = subprocess.run(p,
stdout=subprocess.PIPE,
@ -45,12 +45,10 @@ def print_sshfp_records(hostname, ip):
# sort by algo and key_type to keep it consistent
fingerprints = sorted(fingerprints,
key=lambda x: (x[0], x[1]))
dns_hostname = hostname.split('.')[0]
for f in fingerprints:
print(f"{dns_hostname}\t\t\tIN\tSSHFP\t{f[0]} {f[1]} {f[2]}")
print(f"{host}\t\t\tIN\tSSHFP\t{f[0]} {f[1]} {f[2]}")
def print_dns(cloud, server):
def print_dns(server):
ip4 = server.public_v4
ip6 = server.public_v6
# note handle things like mirror.iad.rax.opendev.org
@ -66,7 +64,7 @@ def print_dns(cloud, server):
print(f"{host} IN A {ip4}")
if ip6:
print(f"{host} IN AAAA {ip6}")
print_sshfp_records(server.name, ip4)
print_sshfp_records(host, ip4)
def main():
parser = argparse.ArgumentParser()
@ -84,4 +82,4 @@ def main():
" openstacksdk >= 0.12 is required")
raise
print_dns(cloud, server)
print_dns(server)

View File

@ -456,7 +456,7 @@ def main():
print()
print("-------- CONFIGURATION --------\n")
dns.print_dns(cloud, server)
dns.print_dns(server)
print()
print_inventory_yaml(server)
print()