You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by pq...@apache.org on 2010/10/05 03:32:59 UTC

svn commit: r1004499 - /incubator/libcloud/trunk/libcloud/drivers/ec2.py

Author: pquerna
Date: Tue Oct  5 01:32:59 2010
New Revision: 1004499

URL: http://svn.apache.org/viewvc?rev=1004499&view=rev
Log:
Add ex_create_keypair method to EC2NodeDriver class. LIBCLOUD-57.

Submitted by: Grig Gheorghiu <grig.gheorghiu gmail.com>

Modified:
    incubator/libcloud/trunk/libcloud/drivers/ec2.py

Modified: incubator/libcloud/trunk/libcloud/drivers/ec2.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/libcloud/drivers/ec2.py?rev=1004499&r1=1004498&r2=1004499&view=diff
==============================================================================
--- incubator/libcloud/trunk/libcloud/drivers/ec2.py (original)
+++ incubator/libcloud/trunk/libcloud/drivers/ec2.py Tue Oct  5 01:32:59 2010
@@ -358,6 +358,26 @@ class EC2NodeDriver(NodeDriver):
         )
         return images
 
+    def ex_create_keypair(self, name):
+        """Creates a new keypair
+
+        @note: This is a non-standard extension API, and only works for EC2.
+
+        @type name: C{str}
+        @param name: The name of the keypair to Create. This must be unique, 
+                     otherwise an InvalidKeyPair.Duplicate exception is raised.
+        """
+        params = {'Action': 'CreateKeyPair',
+                  'KeyName': name,
+        }
+        response = self.connection.request(self.path, params=params).object
+        key_material = self._findtext(response, 'keyMaterial')
+        key_fingerprint = self._findtext(response, 'keyFingerprint')
+        return {
+                'keyMaterial': key_material,
+                'keyFingerprint': key_fingerprint,
+        }
+
     def ex_create_security_group(self, name, description):
         """Creates a new Security Group