summaryrefslogtreecommitdiffstats
path: root/nova/compute
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-04-25 15:12:48 +0000
committerGerrit Code Review <review@openstack.org>2012-04-25 15:12:48 +0000
commita936ab93a86604421c63d52b221f90b3f77d2d58 (patch)
treeba611bbff4fe546b8f9193e371827f44ccce558b /nova/compute
parentd813d20c3b996f90974a3c02aa658b97df9f7607 (diff)
parent148dba871ef76841e93b1a278155340c395b4a64 (diff)
downloadnova-a936ab93a86604421c63d52b221f90b3f77d2d58.tar.gz
nova-a936ab93a86604421c63d52b221f90b3f77d2d58.tar.xz
nova-a936ab93a86604421c63d52b221f90b3f77d2d58.zip
Merge "Validate min_ram/min_disk on rebuild."
Diffstat (limited to 'nova/compute')
-rw-r--r--nova/compute/api.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py
index 70f8f6967..307b5e456 100644
--- a/nova/compute/api.py
+++ b/nova/compute/api.py
@@ -1315,11 +1315,11 @@ class API(BaseAPI):
self._cast_compute_message('reboot_instance', context, instance,
params={'reboot_type': reboot_type})
- def _validate_image_href(self, context, image_href):
+ def _get_image(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)
+ return image_service.show(context, image_id)
@wrap_check_policy
@check_instance_state(vm_state=[vm_states.ACTIVE, vm_states.SHUTOFF],
@@ -1327,7 +1327,7 @@ class API(BaseAPI):
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)
+ image = self._get_image(context, image_href)
files_to_inject = kwargs.pop('files_to_inject', [])
self._check_injected_file_quota(context, files_to_inject)
@@ -1335,6 +1335,12 @@ class API(BaseAPI):
metadata = kwargs.get('metadata', {})
self._check_metadata_properties_quota(context, metadata)
+ instance_type = instance['instance_type']
+ if instance_type['memory_mb'] < int(image.get('min_ram') or 0):
+ raise exception.InstanceTypeMemoryTooSmall()
+ if instance_type['root_gb'] < int(image.get('min_disk') or 0):
+ raise exception.InstanceTypeDiskTooSmall()
+
self.update(context,
instance,
image_ref=image_href,