diff options
| author | Naveed Massjouni <naveedm9@gmail.com> | 2012-01-18 19:31:01 +0000 |
|---|---|---|
| committer | Naveed Massjouni <naveedm9@gmail.com> | 2012-01-19 19:49:29 +0000 |
| commit | 942f0404a3d7052830cdc52c17c85de7cd3bc0da (patch) | |
| tree | f412e624e42d0bcf307c74116563b151bd1425b0 /nova/compute | |
| parent | 4672ec7c95845ddd1df29ffa88848c22df512a42 (diff) | |
Validating image id for rebuild.
bug: 886701
Change-Id: I20ad03edca390af9203569e02ae0c1af5bb7beaf
Diffstat (limited to 'nova/compute')
| -rw-r--r-- | nova/compute/api.py | 8 |
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) |
