[pkg-eucalyptus-commits] [SCM] managing cloud instances for Eucalyptus branch, master, updated. 3.0.0-alpha3-257-g1da8e3a

Garrett Holmstrom gholms at fedoraproject.org
Sun Jun 16 02:29:48 UTC 2013


The following commit has been merged in the master branch:
commit ad433026767ce9629395b73819f85a98707b1c8a
Author: Garrett Holmstrom <gholms at fedoraproject.org>
Date:   Mon Apr 23 23:57:21 2012 -0700

    Centralize resource tag printing

diff --git a/euca2ools/commands/euca/__init__.py b/euca2ools/commands/euca/__init__.py
index d722722..b3d905f 100644
--- a/euca2ools/commands/euca/__init__.py
+++ b/euca2ools/commands/euca/__init__.py
@@ -152,6 +152,11 @@ class EucalyptusRequest(Euca2oolsRequest, TabifyingCommand):
         else:
             return response
 
+    def print_resource_tag(self, resource_tag, resource_id):
+        resource_type = RESOURCE_TYPE_MAP.lookup(resource_id)
+        print self.tabify(['TAG', resource_type, resource_id,
+                           resource_tag.get('key'), resource_tag.get('value')])
+
     def print_reservation(self, reservation):
         res_line = ['RESERVATION', reservation['reservationId'],
                     reservation.get('ownerId')]
@@ -207,8 +212,7 @@ class EucalyptusRequest(Euca2oolsRequest, TabifyingCommand):
             self.print_blockdevice(blockdev)
 
         for tag in instance.get('tagSet', []):
-            print self.tabify(['TAG', 'instance', instance.get('instanceId'),
-                               tag.get('key'), tag.get('value')])
+            self.print_resource_tag(tag, instance.get('instanceId'))
 
     def print_blockdevice(self, blockdev):
         print self.tabify(['BLOCKDEVICE', blockdev.get('deviceName'),
@@ -224,6 +228,8 @@ class EucalyptusRequest(Euca2oolsRequest, TabifyingCommand):
             print self.tabify(['ATTACHMENT', volume.get('volumeId')] +
                     [attachment.get(attr) for attr in
                      ('instanceId', 'device', 'status', 'attachTime')])
+        for tag in volume.get('tagSet', []):
+            self.print_resource_tag(tag, volume.get('volumeId'))
 
     def print_snapshot(self, snap):
         print self.tabify(['SNAPSHOT', snap.get('snapshotId'),
@@ -232,8 +238,7 @@ class EucalyptusRequest(Euca2oolsRequest, TabifyingCommand):
                            snap.get('ownerId'),   snap.get('volumeSize'),
                            snap.get('description')])
         for tag in snap.get('tagSet', []):
-            print self.tabify(['TAG', 'snapshot', snap.get('snapshotId'),
-                               tag.get('key'), tag.get('value')])
+            self.print_resource_tag(tag, snap.get('snapshotId'))
 
     def print_bundle_task(self, task):
         print self.tabify(['BUNDLE', task.get('bundleId'),
@@ -269,7 +274,7 @@ class _ResourceTypeMap(object):
             'vgw':    'vpn-gateway'}
 
     def lookup(self, item):
-        if not isinstance(item, str):
+        if not isinstance(item, basestring):
             raise TypeError('argument type must be str')
         for prefix in self._prefix_type_map:
             if item.startswith(prefix + '-'):
diff --git a/euca2ools/commands/euca/createtags.py b/euca2ools/commands/euca/createtags.py
index 50f8ad0..a255a27 100644
--- a/euca2ools/commands/euca/createtags.py
+++ b/euca2ools/commands/euca/createtags.py
@@ -29,7 +29,7 @@
 # POSSIBILITY OF SUCH DAMAGE.
 
 from requestbuilder import Arg
-from . import EucalyptusRequest, RESOURCE_TYPE_MAP
+from . import EucalyptusRequest
 from .argtypes import binary_tag_def
 
 class CreateTags(EucalyptusRequest):
@@ -44,7 +44,7 @@ class CreateTags(EucalyptusRequest):
                         value is set to an empty string.''')]
 
     def print_result(self, result):
-        for resource in self.args['ResourceId']:
+        for resource_id in self.args['ResourceId']:
             for tag in self.args['Tag']:
-                print self.tabify(['TAG', RESOURCE_TYPE_MAP.lookup(resource),
-                                   resource, tag['Key'], tag['Value']])
+                lc_resource_tag = {'key': tag['Key'], 'value': tag['Value']}
+                self.print_resource_tag(lc_resource_tag, resource_id)
diff --git a/euca2ools/commands/euca/describevolumes.py b/euca2ools/commands/euca/describevolumes.py
index db00fd9..ae138a7 100644
--- a/euca2ools/commands/euca/describevolumes.py
+++ b/euca2ools/commands/euca/describevolumes.py
@@ -59,7 +59,7 @@ class DescribeVolumes(EucalyptusRequest):
                GenericTagFilter('tag:KEY',
                                 help='specific tag/value combination'),
                Filter(name='volume-id')]
-    ListMarkers = ['volumeSet', 'attachmentSet']
+    ListMarkers = ['volumeSet', 'attachmentSet', 'tagSet']
     ItemMarkers = ['item']
 
     def print_result(self, result):

-- 
managing cloud instances for Eucalyptus



More information about the pkg-eucalyptus-commits mailing list