From 86bf2276d9adf2365e46a880d7ec4a276780d3ed Mon Sep 17 00:00:00 2001 From: Mark Washenberger Date: Mon, 5 Mar 2012 16:48:18 -0500 Subject: Only pass image uuids to compute api rebuild Addresses bug 881641 Change-Id: I9c0270d5ceb126387a0052c83937ae778d1f49cb --- nova/api/openstack/compute/servers.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'nova/api') diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py index 5dc5cff49..2bfbfb745 100644 --- a/nova/api/openstack/compute/servers.py +++ b/nova/api/openstack/compute/servers.py @@ -633,14 +633,7 @@ class Controller(wsgi.Controller): name = name.strip() image_href = self._image_ref_from_req_data(body) - - # If the image href was generated by nova api, strip image_href - # down to an id and use the default glance connection params - image_href = image_href.split('/').pop() - - if not utils.is_uuid_like(str(image_href)): - msg = _("Invalid imageRef provided.") - raise exc.HTTPBadRequest(explanation=msg) + image_href = self._image_uuid_from_href(image_href) personality = server_dict.get('personality') config_drive = server_dict.get('config_drive') @@ -933,6 +926,17 @@ class Controller(wsgi.Controller): msg = _("Missing imageRef attribute") raise exc.HTTPBadRequest(explanation=msg) + def _image_uuid_from_href(self, image_href): + # If the image href was generated by nova api, strip image_href + # down to an id and use the default glance connection params + image_uuid = image_href.split('/').pop() + + if not utils.is_uuid_like(image_uuid): + msg = _("Invalid imageRef provided.") + raise exc.HTTPBadRequest(explanation=msg) + + return image_uuid + def _flavor_id_from_req_data(self, data): try: flavor_ref = data['server']['flavorRef'] @@ -1010,6 +1014,8 @@ class Controller(wsgi.Controller): msg = _("Could not parse imageRef from request.") raise exc.HTTPBadRequest(explanation=msg) + image_href = self._image_uuid_from_href(image_href) + try: password = body['adminPass'] except (KeyError, TypeError): -- cgit