summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorEoghan Glynn <eglynn@redhat.com>2012-07-17 15:20:30 +0100
committerEoghan Glynn <eglynn@redhat.com>2012-07-17 18:29:22 +0100
commit8bf5d0927660ccf9e01450e6298c946721acfefa (patch)
tree9c3d565eb969788fe2edac736797b8b9e81fa628 /nova/api
parentb898badbbc237cceb8ced9d89f4c53e2df98ee4d (diff)
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
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/ec2/cloud.py13
1 files changed, 11 insertions, 2 deletions
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