diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-03-02 23:54:37 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-03-02 23:54:37 +0000 |
| commit | 49f60715e682d8ef6139d1d2b30f744bf43bb2f5 (patch) | |
| tree | a15809ba9bc0978c2c27a61e02ae0052754be29d | |
| parent | 665c453ec2c1c8cc7ccdd5870fbbf0c01e2cf2db (diff) | |
| parent | d7acf13525aaac43a08fa4763bc149e708ab7d39 (diff) | |
| download | nova-49f60715e682d8ef6139d1d2b30f744bf43bb2f5.tar.gz nova-49f60715e682d8ef6139d1d2b30f744bf43bb2f5.tar.xz nova-49f60715e682d8ef6139d1d2b30f744bf43bb2f5.zip | |
Merge "Handle InstanceNotFound during server update"
| -rw-r--r-- | nova/api/openstack/compute/servers.py | 3 | ||||
| -rw-r--r-- | nova/tests/api/openstack/compute/test_servers.py | 26 |
2 files changed, 27 insertions, 2 deletions
diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py index b27f1802c..5dc5cff49 100644 --- a/nova/api/openstack/compute/servers.py +++ b/nova/api/openstack/compute/servers.py @@ -807,9 +807,8 @@ class Controller(wsgi.Controller): body['server']['auto_disk_config']) update_dict['auto_disk_config'] = auto_disk_config - instance = self.compute_api.get(ctxt, id) - try: + instance = self.compute_api.get(ctxt, id) self.compute_api.update(ctxt, instance, **update_dict) except exception.NotFound: raise exc.HTTPNotFound() diff --git a/nova/tests/api/openstack/compute/test_servers.py b/nova/tests/api/openstack/compute/test_servers.py index b2ad07027..c758f4749 100644 --- a/nova/tests/api/openstack/compute/test_servers.py +++ b/nova/tests/api/openstack/compute/test_servers.py @@ -951,6 +951,32 @@ class ServersControllerTest(test.TestCase): self.assertEqual(res_dict['server']['id'], FAKE_UUID) self.assertEqual(res_dict['server']['name'], 'server_test') + def test_update_server_not_found(self): + def fake_get(*args, **kwargs): + raise nova.exception.InstanceNotFound() + + self.stubs.Set(nova.compute.API, 'get', fake_get) + req = fakes.HTTPRequest.blank('/v2/fake/servers/%s' % FAKE_UUID) + req.method = 'PUT' + req.content_type = 'application/json' + body = {'server': {'name': 'server_test'}} + req.body = json.dumps(body) + self.assertRaises(webob.exc.HTTPNotFound, self.controller.update, + req, FAKE_UUID, body) + + def test_update_server_not_found_on_update(self): + def fake_update(*args, **kwargs): + raise nova.exception.InstanceNotFound() + + self.stubs.Set(nova.compute.API, 'update', fake_update) + req = fakes.HTTPRequest.blank('/v2/fake/servers/%s' % FAKE_UUID) + req.method = 'PUT' + req.content_type = 'application/json' + body = {'server': {'name': 'server_test'}} + req.body = json.dumps(body) + self.assertRaises(webob.exc.HTTPNotFound, self.controller.update, + req, FAKE_UUID, body) + def test_rebuild_instance_with_access_ipv4_bad_format(self): self.stubs.Set(nova.db, 'instance_get', fakes.fake_instance_get(vm_state=vm_states.ACTIVE)) |
