code: def ssh_compute_add_host_and_key(public_key, hostname, private_address,
                                   application_name, user=None):
      
      # If remote compute node hands us a hostname, ensure we have a
      # known hosts entry for its IP, hostname and FQDN.
      hosts = [private_address]
  
      if not is_ipv6(private_address):
          if hostname:
              hosts.append(hostname)
  
          if is_ip(private_address):
              hn = get_hostname(private_address)
              if hn:
                  hosts.append(hn)
                  short = hn.split('.')[0]
                  if ns_query(short):
                      hosts.append(short)
          else:
              hosts.append(get_host_ip(private_address))
              short = private_address.split('.')[0]
              if ns_query(short):
                  hosts.append(short)
  
      for host in list(set(hosts)):
          add_known_host(host, application_name, user)
  
      if not ssh_authorized_key_exists(public_key, application_name, user):
          log('Saving SSH authorized key for compute host at %s.' %
              private_address)
          add_authorized_key(public_key, application_name, user)
docs: Add a compute nodes ssh details to local cache.
  
      Collect various hostname variations and add the corresponding host keys to
      the local known hosts file. Finally, add the supplied public key to the
      authorized_key file.
  
      :param public_key: Public key.
      :type public_key: str
      :param hostname: Hostname to collect host keys from.
      :type hostname: str
      :param private_address:aCorresponding private address for hostname
      :type private_address: str
      :param application_name: Name of application eg nova-compute-something
      :type application_name: str
      :param user: The user that the ssh asserts are for.
      :type user: str