From 8bf5d0927660ccf9e01450e6298c946721acfefa Mon Sep 17 00:00:00 2001 From: Eoghan Glynn Date: Tue, 17 Jul 2012 15:20:30 +0100 Subject: Reject EC2 CreateImage for instance-store For fidelity with AWS, we explicitly do not support the EC2 CreateImage API for the analogue of instance-store-backed instances. Change-Id: I266a021ce53dbb1f521201f1cdc614b08c31bf8d --- nova/api/ec2/cloud.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'nova/api') diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index 3807ff323..e0fb434d0 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -1457,6 +1457,17 @@ class CloudController(object): instance_id = ec2utils.ec2_id_to_id(ec2_instance_id) instance = self.compute_api.get(context, instance_id) + bdms = self.compute_api.get_instance_bdms(context, instance) + + # CreateImage only supported for the analogue of EBS-backed instances + if not self.compute_api.is_volume_backed_instance(context, instance, + bdms): + root = instance['root_device_name'] + msg = _("Invalid value '%(ec2_instance_id)s' for instanceId. " + "Instance does not have a volume attached at root " + "(%(root)s)") % locals() + raise exception.InvalidParameterValue(err=msg) + # stop the instance if necessary restart_instance = False if not no_reboot: @@ -1498,8 +1509,6 @@ class CloudController(object): _('image of %(instance)s at %(now)s') % name_map) mapping = [] - bdms = db.block_device_mapping_get_all_by_instance(context, - instance['uuid']) for bdm in bdms: if bdm.no_device: continue -- cgit