summaryrefslogtreecommitdiffstats
path: root/nova/compute
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-01-20 18:37:20 +0000
committerGerrit Code Review <review@openstack.org>2012-01-20 18:37:20 +0000
commit889a5215842839342fdbe5b2cb2c7d9053ac36b5 (patch)
tree02e5d82cbfd5cce695296b1bbd470f99e902de01 /nova/compute
parentc56630c421867df61875a83adfd99ec931896fe7 (diff)
parent942f0404a3d7052830cdc52c17c85de7cd3bc0da (diff)
Merge "Validating image id for rebuild."
Diffstat (limited to 'nova/compute')
-rw-r--r--nova/compute/api.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py
index d28f0be4b..244930402 100644
--- a/nova/compute/api.py
+++ b/nova/compute/api.py
@@ -1255,6 +1255,12 @@ class API(base.Base):
instance['uuid'],
params={'reboot_type': reboot_type})
+ def _validate_image_href(self, context, image_href):
+ """Throws an ImageNotFound exception if image_href does not exist."""
+ (image_service, image_id) = nova.image.get_image_service(context,
+ image_href)
+ image_service.show(context, image_id)
+
@wrap_check_policy
@check_instance_state(vm_state=[vm_states.ACTIVE, vm_states.SHUTOFF],
task_state=[None, task_states.RESIZE_VERIFY])
@@ -1262,6 +1268,8 @@ class API(base.Base):
def rebuild(self, context, instance, image_href, admin_password, **kwargs):
"""Rebuild the given instance with the provided attributes."""
+ self._validate_image_href(context, image_href)
+
files_to_inject = kwargs.pop('files_to_inject', [])
self._check_injected_file_quota(context, files_to_inject)