From 86008a67aade0d8830bf353395729fa55e54b8d8 Mon Sep 17 00:00:00 2001 From: Janis Gengeris Date: Tue, 1 Jan 2013 17:14:18 +0200 Subject: Raise BadRequest when updating 'personality' Updating booted server instance through server PUT API call with 'personality' property set is not returning 'Bad Request', although the property is not allowed to be updated once the instance is booted. This fixes the described problem. Fixes bug #1032546 Change-Id: Ia086f5ea5176640a9916a3ba42c79d4d5944ce76 --- nova/api/openstack/compute/servers.py | 4 ++++ nova/tests/api/openstack/compute/test_servers.py | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py index a62740681..b0531d0e4 100644 --- a/nova/api/openstack/compute/servers.py +++ b/nova/api/openstack/compute/servers.py @@ -981,6 +981,10 @@ class Controller(wsgi.Controller): msg = _("HostId cannot be updated.") raise exc.HTTPBadRequest(explanation=msg) + if 'personality' in body['server']: + msg = _("Personality cannot be updated.") + raise exc.HTTPBadRequest(explanation=msg) + try: instance = self.compute_api.get(ctxt, id) req.cache_db_instance(instance) diff --git a/nova/tests/api/openstack/compute/test_servers.py b/nova/tests/api/openstack/compute/test_servers.py index d32640bf2..dcbd62225 100644 --- a/nova/tests/api/openstack/compute/test_servers.py +++ b/nova/tests/api/openstack/compute/test_servers.py @@ -1184,6 +1184,20 @@ class ServersControllerTest(test.TestCase): self.assertEqual(res_dict['server']['id'], FAKE_UUID) self.assertEqual(res_dict['server']['accessIPv6'], '') + def test_update_server_personality(self): + req = fakes.HTTPRequest.blank('/v2/fake/servers/%s' % FAKE_UUID) + req.method = 'PUT' + req.content_type = 'application/json' + body = { + 'server': { + 'personality': [] + } + } + req.body = jsonutils.dumps(body) + + self.assertRaises(webob.exc.HTTPBadRequest, + self.controller.update, req, FAKE_UUID, body) + def test_update_server_adminPass_ignored(self): inst_dict = dict(name='server_test', adminPass='bacon') body = dict(server=inst_dict) -- cgit