Permalink
Browse files

Fix one last bug in os-console-output extension

Actually fixes bug 907083

Change-Id: Ia57d316db0c79d7e78ef3225e77cd95589ac68de
  • Loading branch information...
Brian Waldon
Brian Waldon committed Dec 20, 2011
1 parent 47c4c49 commit b1bd80bb087c37846edfd598d20eee5151788ddd
@@ -54,14 +54,16 @@ def get_console_output(self, input_dict, req, server_id):
raise webob.exc.HTTPBadRequest(_('Malformed request body'))
try:
return self.compute_api.get_console_output(context,
instance,
length)
output = self.compute_api.get_console_output(context,
instance,
length)
except exception.ApiError, e:
raise webob.exc.HTTPBadRequest(explanation=e.message)
except exception.NotAuthorized, e:
raise webob.exc.HTTPUnauthorized()
return {'output': output}
def get_actions(self):
"""Return the actions the extension adds, as required by contract."""
actions = [extensions.ActionExtension("servers", "os-getConsoleOutput",
@@ -24,7 +24,7 @@
def fake_get_console_output(self, _context, _instance, tail_length):
fixture = [str(i) for i in range(10)]
fixture = [str(i) for i in range(5)]
if tail_length is None:
pass
@@ -60,7 +60,9 @@ def test_get_text_console_instance_action(self):
req.headers["content-type"] = "application/json"
res = req.get_response(fakes.wsgi_app())
output = json.loads(res.body)
self.assertEqual(res.status_int, 200)
self.assertEqual(output, {'output': '0\n1\n2\n3\n4'})
def test_get_console_output_with_tail(self):
body = {'os-getConsoleOutput': {'length': 3}}
@@ -69,7 +71,9 @@ def test_get_console_output_with_tail(self):
req.body = json.dumps(body)
req.headers["content-type"] = "application/json"
res = req.get_response(fakes.wsgi_app())
output = json.loads(res.body)
self.assertEqual(res.status_int, 200)
self.assertEqual(output, {'output': '2\n3\n4'})
def test_get_text_console_no_instance(self):
self.stubs.Set(compute.API, 'get', fake_get_not_found)

0 comments on commit b1bd80b

Please sign in to comment.