'Convenience method to retrieve a specific keypair (KeyPair).
:type keyname: string
:param keyname: The name of the keypair to retrieve
:type dry_run: bool
:param dry_run: Set to True if the operation should not actually run.
:rtype: :class:`boto.ec2.keypair.KeyPair`
:return: The KeyPair specified or None if it is not found'

def get_key_pair(self, keyname, dry_run=False):

    try:
        return self.get_all_key_pairs(keynames=[keyname], dry_run=dry_run)[0]
    except self.ResponseError as e:
        if (e.code == 'InvalidKeyPair.NotFound'):
            return None
        else:
            raise
