Guard return value from get_hostname
It's possible that the get_hostname call use when resolving the full hostname of a IP address may return None in the event that a hostname cannot be resolved via DNS. Ensure that None values are not added to the list of hostnames to validated for SSH key configuration. Change-Id: I910224f9c22b7e0b8e53faddc64e3715389cc691 Closes-Bug: 1641614
This commit is contained in:
@@ -769,10 +769,11 @@ def ssh_compute_add(public_key, rid=None, unit=None, user=None):
|
||||
hosts.append(short)
|
||||
else:
|
||||
hn = get_hostname(private_address)
|
||||
hosts.append(hn)
|
||||
short = hn.split('.')[0]
|
||||
if ns_query(short):
|
||||
hosts.append(short)
|
||||
if hn:
|
||||
hosts.append(hn)
|
||||
short = hn.split('.')[0]
|
||||
if ns_query(short):
|
||||
hosts.append(short)
|
||||
|
||||
for host in list(set(hosts)):
|
||||
add_known_host(host, unit, user)
|
||||
|
Reference in New Issue
Block a user