apache/libcloud — pull request #133 by Jc2k (2013-08-02 16:30:38+00:00)
Title: Allow ec2 drivers to support the ssh-key feature [WIP]

This still needs actual testing, unittests and PEP8 checking, but is ready for some feedback on approach, factoring and function names.

The goal is that if I pass a NodeAuthSSHKey to ec2 (via ``auth`` argument of ``create_node``), that public key will be automatically imported into the KeyPair system, if it hasn't been already.

This commit adds new utility functions for extracting fingerprints
from public keys. There are 2 versions of this. It is quite easy
to make an OpenSSH style fingerprint, but EC2 uses an SSH2 style
fingerprint (which has extra DER encoding applied to it before
hashing).

This commit allows you to import a public ssh key that you
have as a string (previously the key had to exist on disk).

You can now use ex_list_keypairs rather than ex_describe_all_keypairs.
The latter gives you a list of key names, you then need to do a
HTTP request for each keyname if you want to check their fingerprint.
The former returns a list of dictionaries with more info.
Therefore, ex_list_keypairs is much more efficient.

ex_describe_all_keypairs was reimplemented on top of
ex_list_keypairs, but I think it should be marked as deprecated.

A new ex_ method is now available to find or import a public key.
Given a public key it will find it on ec2 by its fingerprint. If
it is not available it is automatically imported.

The create_node method uses this method to lookup or import an
SSH key that is provided to it by a NodeAuthSSHKey (via auth arg).
This means ec2 now properly supports the ssh-key feature.