diff --git a/launch/src/opendev_launch/dns.py b/launch/src/opendev_launch/dns.py index 4befe8357a..a2276e4cc6 100755 --- a/launch/src/opendev_launch/dns.py +++ b/launch/src/opendev_launch/dns.py @@ -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) diff --git a/launch/src/opendev_launch/launch_node.py b/launch/src/opendev_launch/launch_node.py index 5d90a69c8d..cd297f6d5d 100755 --- a/launch/src/opendev_launch/launch_node.py +++ b/launch/src/opendev_launch/launch_node.py @@ -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()