From 64736d1e12b9754562d2980234a96f6eeb18e704 Mon Sep 17 00:00:00 2001 From: Alex Meade Date: Thu, 15 Sep 2011 14:46:19 -0400 Subject: Add minDisk and minRam to OSAPI image details Change-Id: I4bf1920a245de85c88c38ec3ad82dc0e93cc671c --- nova/api/openstack/create_instance_helper.py | 4 ++++ nova/api/openstack/images.py | 6 ++++++ nova/api/openstack/schemas/v1.1/image.rng | 6 ++++++ nova/api/openstack/views/images.py | 5 +++++ 4 files changed, 21 insertions(+) (limited to 'nova/api') diff --git a/nova/api/openstack/create_instance_helper.py b/nova/api/openstack/create_instance_helper.py index 79f17e27f..dde9187cd 100644 --- a/nova/api/openstack/create_instance_helper.py +++ b/nova/api/openstack/create_instance_helper.py @@ -187,6 +187,10 @@ class CreateInstanceHelper(object): config_drive=config_drive,)) except quota.QuotaError as error: self._handle_quota_error(error) + except exception.InstanceTypeMemoryTooSmall as error: + raise exc.HTTPBadRequest(explanation=unicode(error)) + except exception.InstanceTypeDiskTooSmall as error: + raise exc.HTTPBadRequest(explanation=unicode(error)) except exception.ImageNotFound as error: msg = _("Can not find requested image") raise exc.HTTPBadRequest(explanation=msg) diff --git a/nova/api/openstack/images.py b/nova/api/openstack/images.py index d579ae716..7795a3fc4 100644 --- a/nova/api/openstack/images.py +++ b/nova/api/openstack/images.py @@ -41,6 +41,8 @@ SUPPORTED_FILTERS = { 'changes-since': 'changes-since', 'server': 'property-instance_ref', 'type': 'property-image_type', + 'minRam': 'min_ram', + 'minDisk': 'min_disk', } @@ -239,6 +241,10 @@ class ImageXMLSerializer(wsgi.XMLDictSerializer): image_elem.set('status', str(image_dict['status'])) if 'progress' in image_dict: image_elem.set('progress', str(image_dict['progress'])) + if 'minRam' in image_dict: + image_elem.set('minRam', str(image_dict['minRam'])) + if 'minDisk' in image_dict: + image_elem.set('minDisk', str(image_dict['minDisk'])) if 'server' in image_dict: server_elem = self._create_server_node(image_dict['server']) image_elem.append(server_elem) diff --git a/nova/api/openstack/schemas/v1.1/image.rng b/nova/api/openstack/schemas/v1.1/image.rng index 887f76751..505081fba 100644 --- a/nova/api/openstack/schemas/v1.1/image.rng +++ b/nova/api/openstack/schemas/v1.1/image.rng @@ -8,6 +8,12 @@ + + + + + + diff --git a/nova/api/openstack/views/images.py b/nova/api/openstack/views/images.py index 659bfd463..e366661c3 100644 --- a/nova/api/openstack/views/images.py +++ b/nova/api/openstack/views/images.py @@ -161,6 +161,11 @@ class ViewBuilderV11(ViewBuilder): if detail: image["metadata"] = image_obj.get("properties", {}) + if 'min_ram' in image_obj: + image["minRam"] = image_obj.get("min_ram") or 0 + + if 'min_disk' in image_obj: + image["minDisk"] = image_obj.get("min_disk") or 0 return image -- cgit