From a766d817218edcbb35c477382d5839f53c1f9570 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Wed, 5 Sep 2012 14:07:16 -0400 Subject: Fix EC2 cinder volume creation as an admin user. Updates the EC2 API _format_volume function so that it only tries to add project_id and host to responses if those keys are present. This resolves a KeyError that would occur when using Cinder because volumes from it don't contain this information. Fixes LP Bug #1046464. Change-Id: I56b977cfd1ae482f2559a3f1fda8d1543d3ea227 --- nova/api/ec2/cloud.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index 45c22b45d..14aa39438 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -722,10 +722,11 @@ class CloudController(object): v['availabilityZone'] = volume['availability_zone'] v['createTime'] = volume['created_at'] if context.is_admin: + # NOTE(dprince): project_id and host_id are unset w/ Cinder v['status'] = '%s (%s, %s, %s, %s)' % ( volume['status'], - volume['project_id'], - volume['host'], + volume.get('project_id', ''), + volume.get('host', ''), instance_data, volume['mountpoint']) if volume['attach_status'] == 'attached': -- cgit