summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorMichael Still <mikal@stillhq.com>2012-06-14 21:31:20 +1000
committerMichael Still <mikal@stillhq.com>2012-06-15 07:11:50 +1000
commitd1ee82af65fae2467544b4c3a5062dae544badd7 (patch)
treecc6c049c6c17d04f56ca8074a2c265b49b2cb514 /nova/api
parentaa1e71d1b313f80f5581b1422e3f3e5719569e50 (diff)
downloadnova-d1ee82af65fae2467544b4c3a5062dae544badd7.tar.gz
nova-d1ee82af65fae2467544b4c3a5062dae544badd7.tar.xz
nova-d1ee82af65fae2467544b4c3a5062dae544badd7.zip
Cleanup instance_update so it only takes a UUID.
You know when you try to do something simple like tweak instance_update and instance_update_and_get_original and it turns out to have all these knock on effects? Yeah, that. I still think this is a good idea though. I'd like to live in a future where we don't have instance ids at all at the DB API level. We need to do this to get there. Change-Id: Ia51d06beaec068a8544642a6a4bf489247ff61a0
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/ec2/ec2utils.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/nova/api/ec2/ec2utils.py b/nova/api/ec2/ec2utils.py
index ceb695a5e..7ad2033ce 100644
--- a/nova/api/ec2/ec2utils.py
+++ b/nova/api/ec2/ec2utils.py
@@ -81,6 +81,13 @@ def ec2_id_to_id(ec2_id):
raise exception.InvalidEc2Id(ec2_id=ec2_id)
+def ec2_id_to_uuid(context, ec2_id):
+ """Convert an ec2 ID into an instance UUID"""
+ instance_id = ec2_id_to_id(ec2_id)
+ instance = db.instance_get(context, instance_id)
+ return instance['uuid']
+
+
def image_ec2_id(image_id, image_type='ami'):
"""Returns image ec2_id using id and three letter type."""
template = image_type + '-%08x'