docs: def _check_keypair(self, name, public_key_path, private_key_path):
          """First checks if the keypair is valid, then checks if the keypair
          is registered with on the cloud. If not the keypair is added to the
          users ssh keys.
  
          :param str name: name of the ssh key
          :param str public_key_path: path to the ssh public key file
          :param str private_key_path: path to the ssh private key file
  
          :raises: `KeypairError` if key is not a valid RSA or DSA key,
                   the key could not be uploaded or the fingerprint does not
                   match to the one uploaded to the cloud.
          """
  
          # Read key. We do it as first thing because we need it either
          # way, to check the fingerprint of the remote keypair if it
          # exists already, or to create a new keypair.
          pkey = None
          try:
              pkey = DSSKey.from_private_key_file(private_key_path)
          except PasswordRequiredException:
              warn("Unable to check key file `{0}` because it is encrypted with a "
                   "password. Please, ensure that you added it to the SSH agent "
                   "with `ssh-add {1}`"
                   .format(private_key_path, private_key_path))
          except SSHException:
              try:
                  pkey = RSAKey.from_private_key_file(private_key_path)
              except PasswordRequiredException:
                  warn("Unable to check key file `{0}` because it is encrypted with a "
                       "password. Please, ensure that you added it to the SSH agent "
                       "with `ssh-add {1}`"
                       .format(private_key_path, private_key_path))
              except SSHException:
                  raise KeypairError('File `%s` is neither a valid DSA key '
                                     'or RSA key.' % private_key_path)
  
          try:
              # Check if a keypair `name` exists on the cloud.
              keypair = self.nova_client.keypairs.get(name)
  
              # Check if it has the correct keypair, but only if we can read the local key
              if pkey:
                  fingerprint = str.join(
                      ':', (i.encode('hex') for i in pkey.get_fingerprint()))
                  if fingerprint != keypair.fingerprint:
                      raise KeypairError(
                          "Keypair `%s` is present but has "
                          "different fingerprint. Aborting!" % name)
              else:
                  warn("Unable to check if the keypair is using the correct key.")
          except NotFound:
              log.warning(
                  "Keypair `%s` not found on resource `%s`, Creating a new one",
                  name, self._os_auth_url)
  
              # Create a new keypair
              with open(os.path.expanduser(public_key_path)) as f:
                  key_material = f.read()
                  try:
                      self.nova_client.keypairs.create(name, key_material)
                  except Exception as ex:
                      log.error(
                          "Could not import key `%s` with name `%s` to `%s`",
                          name, public_key_path, self._os_auth_url)
                      raise KeypairError(
                          "could not create keypair `%s`: %s" % (name, ex))