From 26b1523eba3805a497c23e3b6707a85670ee11be Mon Sep 17 00:00:00 2001 From: Johannes Erdfelt Date: Tue, 7 Aug 2012 19:53:24 +0000 Subject: Return 409 error if get_vnc_console is called before VM is created Fixes bug 1034117 In the xenapi driver, the URL returned for a VNC console will include information to locate the particular VM on the dom0, however the VM isn't create until part way through the build process. This leaves a window where a 404 error could be returned by the os-getVNCConsole action. Change this to return a 409 meaning it's not ready yet. Change-Id: Icc3b288d1aae12eb264b2be7fc8f9465d568af74 --- .../api/openstack/compute/contrib/test_consoles.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'nova/tests') diff --git a/nova/tests/api/openstack/compute/contrib/test_consoles.py b/nova/tests/api/openstack/compute/contrib/test_consoles.py index 8d727a556..887092806 100644 --- a/nova/tests/api/openstack/compute/contrib/test_consoles.py +++ b/nova/tests/api/openstack/compute/contrib/test_consoles.py @@ -31,6 +31,10 @@ def fake_get_vnc_console_invalid_type(self, _context, raise exception.ConsoleTypeInvalid(console_type=_console_type) +def fake_get_vnc_console_not_ready(self, _context, instance, _console_type): + raise exception.InstanceNotReady(instance_id=instance["uuid"]) + + def fake_get_vnc_console_not_found(self, _context, instance, _console_type): raise exception.InstanceNotFound(instance_id=instance["uuid"]) @@ -64,6 +68,19 @@ class ConsolesExtensionTest(test.TestCase): self.assertEqual(output, {u'console': {u'url': u'http://fake', u'type': u'novnc'}}) + def test_get_vnc_console_not_ready(self): + self.stubs.Set(compute.API, 'get_vnc_console', + fake_get_vnc_console_not_ready) + body = {'os-getVNCConsole': {'type': 'novnc'}} + req = webob.Request.blank('/v2/fake/servers/1/action') + req.method = "POST" + req.body = jsonutils.dumps(body) + req.headers["content-type"] = "application/json" + + res = req.get_response(fakes.wsgi_app()) + output = jsonutils.loads(res.body) + self.assertEqual(res.status_int, 409) + def test_get_vnc_console_no_type(self): self.stubs.Set(compute.API, 'get', fake_get) self.stubs.Set(compute.API, 'get_vnc_console', -- cgit