summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJanis Gengeris <janis.gengeris@gmail.com>2013-01-01 17:14:18 +0200
committerJanis Gengeris <janis.gengeris@gmail.com>2013-01-01 17:14:18 +0200
commit86008a67aade0d8830bf353395729fa55e54b8d8 (patch)
tree0470125a3a3f7073853e7a2f457c6cd5468960ad
parentb8b8f2032483e5f3d6c09b7b6fddd07301805230 (diff)
downloadnova-86008a67aade0d8830bf353395729fa55e54b8d8.tar.gz
nova-86008a67aade0d8830bf353395729fa55e54b8d8.tar.xz
nova-86008a67aade0d8830bf353395729fa55e54b8d8.zip
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
-rw-r--r--nova/api/openstack/compute/servers.py4
-rw-r--r--nova/tests/api/openstack/compute/test_servers.py14
2 files changed, 18 insertions, 0 deletions
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)