launch: further DNS cleanups
As pointed out by clarkb in review of prior change I06995027a4b80133bdac91c263d7a92fd495493b the hostname handling here is a bit wonky. Use "host" instead of "hostname" since we use that in the rest of the file. The print_dns() function doesn't need a cloud argument, remove it. The print_sshfp_records was incorrectly splitting the host/domain for nodes like "mirror.rax.iad.openstack.org" -- simply pass only the host for the bind record from the print_dns() function. Change-Id: I3d851902ef52588a69294b02e22f4b4667454629
This commit is contained in:
parent
03de935048
commit
ff45b12412
@ -22,9 +22,9 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import subprocess
|
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
|
'''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]
|
p = ['ssh-keyscan', '-D', ip]
|
||||||
s = subprocess.run(p,
|
s = subprocess.run(p,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
@ -45,12 +45,10 @@ def print_sshfp_records(hostname, ip):
|
|||||||
# sort by algo and key_type to keep it consistent
|
# sort by algo and key_type to keep it consistent
|
||||||
fingerprints = sorted(fingerprints,
|
fingerprints = sorted(fingerprints,
|
||||||
key=lambda x: (x[0], x[1]))
|
key=lambda x: (x[0], x[1]))
|
||||||
|
|
||||||
dns_hostname = hostname.split('.')[0]
|
|
||||||
for f in fingerprints:
|
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
|
ip4 = server.public_v4
|
||||||
ip6 = server.public_v6
|
ip6 = server.public_v6
|
||||||
# note handle things like mirror.iad.rax.opendev.org
|
# note handle things like mirror.iad.rax.opendev.org
|
||||||
@ -66,7 +64,7 @@ def print_dns(cloud, server):
|
|||||||
print(f"{host} IN A {ip4}")
|
print(f"{host} IN A {ip4}")
|
||||||
if ip6:
|
if ip6:
|
||||||
print(f"{host} IN AAAA {ip6}")
|
print(f"{host} IN AAAA {ip6}")
|
||||||
print_sshfp_records(server.name, ip4)
|
print_sshfp_records(host, ip4)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
@ -84,4 +82,4 @@ def main():
|
|||||||
" openstacksdk >= 0.12 is required")
|
" openstacksdk >= 0.12 is required")
|
||||||
raise
|
raise
|
||||||
|
|
||||||
print_dns(cloud, server)
|
print_dns(server)
|
||||||
|
@ -456,7 +456,7 @@ def main():
|
|||||||
|
|
||||||
print()
|
print()
|
||||||
print("-------- CONFIGURATION --------\n")
|
print("-------- CONFIGURATION --------\n")
|
||||||
dns.print_dns(cloud, server)
|
dns.print_dns(server)
|
||||||
print()
|
print()
|
||||||
print_inventory_yaml(server)
|
print_inventory_yaml(server)
|
||||||
print()
|
print()
|
||||||
|
Loading…
Reference in New Issue
Block a user