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.
          """
          connection = self._connect()
          keypairs = connection.get_all_key_pairs()
          keypairs = dict((k.name, k) for k in keypairs)
  
          # decide if dsa or rsa key is provided
          pkey = None
          is_dsa_key = False
          try:
              pkey = DSSKey.from_private_key_file(private_key_path)
              is_dsa_key = True
          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)
  
          # create keys that don't exist yet
          if name not in keypairs:
              log.warning(
                  "Keypair `%s` not found on resource `%s`, Creating a new one",
                  name, self._url)
              with open(os.path.expanduser(public_key_path)) as f:
                  key_material = f.read()
                  try:
                      # check for DSA on amazon
                      if "amazon" in self._ec2host and is_dsa_key:
                          log.error(
                              "Apparently, amazon does not support DSA keys. "
                              "Please specify a valid RSA key.")
                          raise KeypairError(
                              "Apparently, amazon does not support DSA keys."
                              "Please specify a valid RSA key.")
  
                      connection.import_key_pair(name, key_material)
                  except Exception as ex:
                      log.error(
                          "Could not import key `%s` with name `%s` to `%s`",
                          name, public_key_path, self._url)
                      raise KeypairError(
                          "could not create keypair `%s`: %s" % (name, ex))
          else:
              # check fingerprint
              cloud_keypair = keypairs[name]
  
              if pkey:
                  fingerprint = str.join(
                      ':', (i.encode('hex') for i in pkey.get_fingerprint()))
  
                  if fingerprint != cloud_keypair.fingerprint:
                      if "amazon" in self._ec2host:
                          log.error(
                              "Apparently, Amazon does not compute the RSA key "
                              "fingerprint as we do! We cannot check if the "
                              "uploaded keypair is correct!")
                      else:
                          raise KeypairError(
                              "Keypair `%s` is present but has "
                              "different fingerprint. Aborting!" % name)