diff options
author | Jenkins <jenkins@review.openstack.org> | 2013-04-04 20:48:19 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2013-04-04 20:48:19 +0000 |
commit | 7a65d7ed74a634cbb61d0d555438bf011a4046eb (patch) | |
tree | 802948a3e5ea67645f5691cf583b31fedd671b1f /nova/api/ec2/ec2utils.py | |
parent | d6715e843c422466452c59a6536cf21d5dee026e (diff) | |
parent | 55a04a4bc3228e698bb84a641d50507810ae9a02 (diff) | |
download | nova-7a65d7ed74a634cbb61d0d555438bf011a4046eb.tar.gz |
Merge "Add CRUD methods for tags to the EC2 API."
Diffstat (limited to 'nova/api/ec2/ec2utils.py')
-rw-r--r-- | nova/api/ec2/ec2utils.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/nova/api/ec2/ec2utils.py b/nova/api/ec2/ec2utils.py index 311d0baf10..660c0e8d44 100644 --- a/nova/api/ec2/ec2utils.py +++ b/nova/api/ec2/ec2utils.py @@ -72,6 +72,31 @@ def image_type(image_type): return image_type +def resource_type_from_id(context, resource_id): + """Get resource type by ID + + Returns a string representation of the Amazon resource type, if known. + Returns None on failure. + + :param context: context under which the method is called + :param resource_id: resource_id to evaluate + """ + + known_types = { + 'i': 'instance', + 'r': 'reservation', + 'vol': 'volume', + 'snap': 'snapshot', + 'ami': 'image', + 'aki': 'image', + 'ari': 'image' + } + + type_marker = resource_id.split('-')[0] + + return known_types.get(type_marker) + + @memoize def id_to_glance_id(context, image_id): """Convert an internal (db) id to a glance id.""" |