libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From je...@apache.org
Subject svn commit: r1072101 - /incubator/libcloud/trunk/libcloud/drivers/ec2.py
Date Fri, 18 Feb 2011 18:42:03 GMT
Author: jerry
Date: Fri Feb 18 18:42:02 2011
New Revision: 1072101

URL: http://svn.apache.org/viewvc?rev=1072101&view=rev
Log:
ex_create_tags and ex_delete_tags functionality to the EC2 driver.

Submitted By: Brandon Rhodes

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=1072101&r1=1072100&r2=1072101&view=diff
==============================================================================
--- incubator/libcloud/trunk/libcloud/drivers/ec2.py (original)
+++ incubator/libcloud/trunk/libcloud/drivers/ec2.py Fri Feb 18 18:42:02 2011
@@ -636,6 +636,48 @@ class EC2NodeDriver(NodeDriver):
             tags[key] = value
         return tags
 
+    def ex_create_tags(self, node, tags):
+        """
+        Create tags for an instance.
+
+        @type node: C{Node}
+        @param node: Node instance
+        @param tags: A dictionary or other mapping of strings to strings,
+                     associating tag names with tag values.
+        """
+        if not tags:
+            return
+
+        params = { 'Action': 'CreateTags',
+                   'ResourceId.0': node.id }
+        for i, key in enumerate(tags):
+            params['Tag.%d.Key' % i] = key
+            params['Tag.%d.Value' % i] = tags[key]
+
+        self.connection.request(self.path,
+                                params=params.copy()).object
+
+    def ex_delete_tags(self, node, tags):
+        """
+        Delete tags from an instance.
+
+        @type node: C{Node}
+        @param node: Node instance
+        @param tags: A dictionary or other mapping of strings to strings,
+                     specifying the tag names and tag values to be deleted.
+        """
+        if not tags:
+            return
+
+        params = { 'Action': 'DeleteTags',
+                   'ResourceId.0': node.id }
+        for i, key in enumerate(tags):
+            params['Tag.%d.Key' % i] = key
+            params['Tag.%d.Value' % i] = tags[key]
+
+        self.connection.request(self.path,
+                                params=params.copy()).object
+
     def ex_describe_addresses(self, nodes):
         """
         Return Elastic IP addresses for all the nodes in the provided list.



Mime
View raw message