[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:47 UTC 2013
The following commit has been merged in the master branch:
commit 55eb472bb011f424d24a4f7c95a120d462f1ea71
Author: Garrett Holmstrom <gholms at fedoraproject.org>
Date: Mon Apr 23 23:38:53 2012 -0700
Show resource types in euca-describe-tags
diff --git a/euca2ools/commands/euca/__init__.py b/euca2ools/commands/euca/__init__.py
index 0022597..d722722 100644
--- a/euca2ools/commands/euca/__init__.py
+++ b/euca2ools/commands/euca/__init__.py
@@ -244,6 +244,42 @@ class EucalyptusRequest(Euca2oolsRequest, TabifyingCommand):
task.get('state')])
+class _ResourceTypeMap(object):
+ _prefix_type_map = {
+ 'cgw': 'customer-gateway',
+ 'dopt': 'dhcp-options',
+ 'aki': 'image',
+ 'ami': 'image',
+ 'ari': 'image',
+ 'eki': 'image',
+ 'emi': 'image',
+ 'eri': 'image',
+ 'i': 'instance',
+ 'igw': 'internet-gateway',
+ 'acl': 'network-acl',
+ 'XXX': 'reserved-instances', # reserved instance IDs are UUIDs
+ 'rtb': 'route-table',
+ 'sg': 'security-group',
+ 'snap': 'snapshot',
+ 'sir': 'spot-instances-request',
+ 'subnet': 'subnet',
+ 'vol': 'volume',
+ 'vpc': 'vpc',
+ 'vpn': 'vpn-connection',
+ 'vgw': 'vpn-gateway'}
+
+ def lookup(self, item):
+ if not isinstance(item, str):
+ raise TypeError('argument type must be str')
+ for prefix in self._prefix_type_map:
+ if item.startswith(prefix + '-'):
+ return self._prefix_type_map[prefix]
+
+ def __iter__(self):
+ return iter(set(self._prefix_type_map.values()))
+
+RESOURCE_TYPE_MAP = _ResourceTypeMap()
+
def _find_args_by_parg(arglike, parg):
if isinstance(arglike, Arg):
if parg in arglike.pargs:
diff --git a/euca2ools/commands/euca/createtags.py b/euca2ools/commands/euca/createtags.py
index ce692b2..50f8ad0 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
+from . import EucalyptusRequest, RESOURCE_TYPE_MAP
from .argtypes import binary_tag_def
class CreateTags(EucalyptusRequest):
@@ -46,6 +46,5 @@ class CreateTags(EucalyptusRequest):
def print_result(self, result):
for resource in self.args['ResourceId']:
for tag in self.args['Tag']:
- ## FIXME: The second field should name a resource type
- print self.tabify(['TAG', None, resource, tag['Key'],
- tag['Value']])
+ print self.tabify(['TAG', RESOURCE_TYPE_MAP.lookup(resource),
+ resource, tag['Key'], tag['Value']])
--
managing cloud instances for Eucalyptus
More information about the pkg-eucalyptus-commits
mailing list