libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r1030128 - in /incubator/libcloud/trunk: libcloud/drivers/ test/fixtures/ec2/
Date Tue, 02 Nov 2010 17:16:52 GMT
Author: jed
Date: Tue Nov  2 17:16:43 2010
New Revision: 1030128

URL: http://svn.apache.org/viewvc?rev=1030128&view=rev
Log:
Add Import/DescribeKeyPair and update API version [LIBCLOUD-62]

 * Add ImportKeyPair and DescribeKeyPair to the EC2 driver.
 * Update EC2 API version in driver and tests.

The ec2 functions ImportKeyPair and DescribeKeyPair are not implemented and will
be needed for deploy_node functionality for EC2.

Signed-off-by: Jed Smith <jed@linode.com>

Modified:
    incubator/libcloud/trunk/libcloud/drivers/ec2.py
    incubator/libcloud/trunk/test/fixtures/ec2/describe_images.xml
    incubator/libcloud/trunk/test/fixtures/ec2/describe_instances.xml
    incubator/libcloud/trunk/test/fixtures/ec2/reboot_instances.xml
    incubator/libcloud/trunk/test/fixtures/ec2/run_instances.xml
    incubator/libcloud/trunk/test/fixtures/ec2/terminate_instances.xml

Modified: incubator/libcloud/trunk/libcloud/drivers/ec2.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/libcloud/drivers/ec2.py?rev=1030128&r1=1030127&r2=1030128&view=diff
==============================================================================
--- incubator/libcloud/trunk/libcloud/drivers/ec2.py (original)
+++ incubator/libcloud/trunk/libcloud/drivers/ec2.py Tue Nov  2 17:16:43 2010
@@ -22,6 +22,7 @@ from libcloud.base import Node, Response
 from libcloud.base import NodeDriver, NodeSize, NodeImage, NodeLocation
 import base64
 import hmac
+import os
 from hashlib import sha256
 import time
 import urllib
@@ -32,7 +33,7 @@ EC2_US_WEST_HOST = 'ec2.us-west-1.amazon
 EC2_EU_WEST_HOST = 'ec2.eu-west-1.amazonaws.com'
 EC2_AP_SOUTHEAST_HOST = 'ec2.ap-southeast-1.amazonaws.com'
 
-API_VERSION = '2009-11-30'
+API_VERSION = '2010-08-31'
 
 NAMESPACE = "http://ec2.amazonaws.com/doc/%s/" % (API_VERSION)
 
@@ -364,7 +365,7 @@ class EC2NodeDriver(NodeDriver):
         @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, 
+        @param name: The name of the keypair to Create. This must be unique,
                      otherwise an InvalidKeyPair.Duplicate exception is raised.
         """
         params = {'Action': 'CreateKeyPair',
@@ -378,6 +379,55 @@ class EC2NodeDriver(NodeDriver):
                 'keyFingerprint': key_fingerprint,
         }
 
+    def ex_import_keypair(self, name, keyfile):
+        """imports a new public key
+
+        @note: This is a non-standard extension API, and only works for EC2.
+
+        @type name: C{str}
+        @param name: The name of the public key to import. This must be unique,
+                     otherwise an InvalidKeyPair.Duplicate exception is raised.
+
+        @type keyfile: C{str}
+        @param keyfile: The filename with path of the public key to import.
+
+        """
+
+        base64key = base64.b64encode(open(os.path.expanduser(keyfile)).read())
+
+        params = {'Action': 'ImportKeyPair',
+                  'KeyName': name,
+                  'PublicKeyMaterial': base64key
+        }
+
+        response = self.connection.request(self.path, params=params).object
+        key_name = self._findtext(response, 'keyName')
+        key_fingerprint = self._findtext(response, 'keyFingerprint')
+        return {
+                'keyName': key_name,
+                'keyFingerprint': key_fingerprint,
+        }
+
+    def ex_describe_keypairs(self, name):
+        """Describes a keypiar by name
+
+        @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 describe.
+
+        """
+
+        params = {'Action': 'DescribeKeyPairs',
+                  'KeyName.1': name
+        }
+
+        response = self.connection.request(self.path, params=params).object
+        key_name = self._findattr(response, 'keySet/item/keyName')
+        return {
+                'keyName': key_name
+        }
+
     def ex_create_security_group(self, name, description):
         """Creates a new Security Group
 

Modified: incubator/libcloud/trunk/test/fixtures/ec2/describe_images.xml
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/fixtures/ec2/describe_images.xml?rev=1030128&r1=1030127&r2=1030128&view=diff
==============================================================================
--- incubator/libcloud/trunk/test/fixtures/ec2/describe_images.xml (original)
+++ incubator/libcloud/trunk/test/fixtures/ec2/describe_images.xml Tue Nov  2 17:16:43 2010
@@ -1,4 +1,4 @@
-<DescribeImagesResponse xmlns="http://ec2.amazonaws.com/doc/2009-11-30/">
+<DescribeImagesResponse xmlns="http://ec2.amazonaws.com/doc/2010-08-31/">
   <imagesSet>
     <item>
       <imageId>ami-be3adfd7</imageId>

Modified: incubator/libcloud/trunk/test/fixtures/ec2/describe_instances.xml
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/fixtures/ec2/describe_instances.xml?rev=1030128&r1=1030127&r2=1030128&view=diff
==============================================================================
--- incubator/libcloud/trunk/test/fixtures/ec2/describe_instances.xml (original)
+++ incubator/libcloud/trunk/test/fixtures/ec2/describe_instances.xml Tue Nov  2 17:16:43
2010
@@ -1,4 +1,4 @@
-<DescribeInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2009-11-30/">
+<DescribeInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2010-08-31/">
   <requestId>56d0fffa-8819-4658-bdd7-548f143a86d2</requestId>
   <reservationSet>
     <item>

Modified: incubator/libcloud/trunk/test/fixtures/ec2/reboot_instances.xml
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/fixtures/ec2/reboot_instances.xml?rev=1030128&r1=1030127&r2=1030128&view=diff
==============================================================================
--- incubator/libcloud/trunk/test/fixtures/ec2/reboot_instances.xml (original)
+++ incubator/libcloud/trunk/test/fixtures/ec2/reboot_instances.xml Tue Nov  2 17:16:43 2010
@@ -1,4 +1,4 @@
-<RebootInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2009-11-30/">
+<RebootInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2010-08-31/">
   <requestId>76dabb7a-fb39-4ed1-b5e0-31a4a0fdf5c0</requestId>
   <return>true</return>
 </RebootInstancesResponse>

Modified: incubator/libcloud/trunk/test/fixtures/ec2/run_instances.xml
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/fixtures/ec2/run_instances.xml?rev=1030128&r1=1030127&r2=1030128&view=diff
==============================================================================
--- incubator/libcloud/trunk/test/fixtures/ec2/run_instances.xml (original)
+++ incubator/libcloud/trunk/test/fixtures/ec2/run_instances.xml Tue Nov  2 17:16:43 2010
@@ -1,4 +1,4 @@
-<RunInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2009-11-30/">
+<RunInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2010-08-31/">
   <reservationId>r-47a5402e</reservationId>
   <ownerId>AIDADH4IGTRXXKCD</ownerId>
   <groupSet>

Modified: incubator/libcloud/trunk/test/fixtures/ec2/terminate_instances.xml
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/fixtures/ec2/terminate_instances.xml?rev=1030128&r1=1030127&r2=1030128&view=diff
==============================================================================
--- incubator/libcloud/trunk/test/fixtures/ec2/terminate_instances.xml (original)
+++ incubator/libcloud/trunk/test/fixtures/ec2/terminate_instances.xml Tue Nov  2 17:16:43
2010
@@ -1,4 +1,4 @@
-<TerminateInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2009-11-30/">
+<TerminateInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2010-08-31/">
   <requestId>fa63083d-e0f7-4933-b31a-f266643bdee8</requestId>
   <instancesSet>
     <item>



Mime
View raw message