Browse Source

Merge "Raise HTTPNotFound in V2 console extension"

tags/2015.1.0b1
Jenkins Gerrit Code Review 5 years ago
parent
commit
4c45902548
2 changed files with 13 additions and 1 deletions
  1. +4
    -1
      nova/api/openstack/compute/consoles.py
  2. +9
    -0
      nova/tests/unit/api/openstack/compute/test_consoles.py

+ 4
- 1
nova/api/openstack/compute/consoles.py View File

@@ -95,9 +95,12 @@ class Controller(object):

def create(self, req, server_id, body):
"""Creates a new console."""
self.console_api.create_console(
try:
self.console_api.create_console(
req.environ['nova.context'],
server_id)
except exception.InstanceNotFound as e:
raise exc.HTTPNotFound(explanation=e.format_message())

@wsgi.serializers(xml=ConsoleTemplate)
def show(self, req, server_id, id):


+ 9
- 0
nova/tests/unit/api/openstack/compute/test_consoles.py View File

@@ -144,6 +144,15 @@ class ConsolesControllerTest(test.NoDBTestCase):
req = fakes.HTTPRequest.blank(self.url)
self.controller.create(req, self.uuid, None)

def test_create_console_unknown_instance(self):
def fake_create_console(cons_self, context, instance_id):
raise exception.InstanceNotFound(instance_id=instance_id)
self.stubs.Set(console.api.API, 'create_console', fake_create_console)

req = fakes.HTTPRequest.blank(self.url)
self.assertRaises(webob.exc.HTTPNotFound, self.controller.create,
req, self.uuid, None)

def test_show_console(self):
def fake_get_console(cons_self, context, instance_id, console_id):
self.assertEqual(instance_id, self.uuid)


Loading…
Cancel
Save