From d1ee82af65fae2467544b4c3a5062dae544badd7 Mon Sep 17 00:00:00 2001 From: Michael Still Date: Thu, 14 Jun 2012 21:31:20 +1000 Subject: 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 --- nova/api/ec2/ec2utils.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'nova/api') 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' -- cgit