summaryrefslogtreecommitdiffstats
path: root/nova/compute
diff options
context:
space:
mode:
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 012217584..3b4cfdeaf 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)