Merge "Add expected_errors for extension console_output v3"
This commit is contained in:
@@ -34,8 +34,8 @@ class ConsoleOutputController(wsgi.Controller):
|
||||
super(ConsoleOutputController, self).__init__(*args, **kwargs)
|
||||
self.compute_api = compute.API()
|
||||
|
||||
@extensions.expected_errors((400, 404, 409))
|
||||
@wsgi.action('get_console_output')
|
||||
@wsgi.response(200)
|
||||
def get_console_output(self, req, id, body):
|
||||
"""Get text console output."""
|
||||
context = req.environ['nova.context']
|
||||
@@ -43,8 +43,8 @@ class ConsoleOutputController(wsgi.Controller):
|
||||
|
||||
try:
|
||||
instance = self.compute_api.get(context, id)
|
||||
except exception.NotFound:
|
||||
raise webob.exc.HTTPNotFound(_('Instance not found'))
|
||||
except exception.InstanceNotFound as e:
|
||||
raise webob.exc.HTTPNotFound(explanation=e.format_message())
|
||||
|
||||
try:
|
||||
length = body['get_console_output'].get('length')
|
||||
@@ -67,8 +67,6 @@ class ConsoleOutputController(wsgi.Controller):
|
||||
output = self.compute_api.get_console_output(context,
|
||||
instance,
|
||||
length)
|
||||
except exception.NotFound:
|
||||
raise webob.exc.HTTPNotFound(_('Unable to get console'))
|
||||
except exception.InstanceNotReady as e:
|
||||
raise webob.exc.HTTPConflict(explanation=e.format_message())
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ def fake_get(self, context, instance_uuid):
|
||||
|
||||
|
||||
def fake_get_not_found(*args, **kwargs):
|
||||
raise exception.NotFound()
|
||||
raise exception.InstanceNotFound(instance_id='')
|
||||
|
||||
|
||||
class ConsoleOutputExtensionTest(test.TestCase):
|
||||
@@ -117,14 +117,6 @@ class ConsoleOutputExtensionTest(test.TestCase):
|
||||
res = req.get_response(self.app)
|
||||
self.assertEqual(res.status_int, 404)
|
||||
|
||||
def test_get_text_console_no_instance_on_get_output(self):
|
||||
self.stubs.Set(compute_api.API,
|
||||
'get_console_output',
|
||||
fake_get_not_found)
|
||||
req = self._create_request(length_dict={})
|
||||
res = req.get_response(self.app)
|
||||
self.assertEqual(res.status_int, 404)
|
||||
|
||||
def test_get_text_console_bad_body(self):
|
||||
body = {}
|
||||
req = fakes.HTTPRequestV3.blank('/v3/servers/1/action')
|
||||
|
||||
Reference in New Issue
Block a user