Merge "Fix the unlimited length of console-log"

This commit is contained in:
Jenkins 2014-04-22 03:54:21 +00:00 committed by Gerrit Code Review
commit 4f10b51627
2 changed files with 11 additions and 3 deletions

View File

@ -364,7 +364,8 @@ class ServersTest(utils.TestCase):
cs.servers.get_console_output(s)
self.assertEqual(cs.servers.get_console_output(s), success)
cs.assert_called('POST', '/servers/1234/action')
cs.assert_called('POST', '/servers/1234/action',
{'get_console_output': {'length': -1}})
def test_get_console_output_with_length(self):
success = 'foo'
@ -372,11 +373,13 @@ class ServersTest(utils.TestCase):
s = cs.servers.get(1234)
s.get_console_output(length=50)
self.assertEqual(s.get_console_output(length=50), success)
cs.assert_called('POST', '/servers/1234/action')
cs.assert_called('POST', '/servers/1234/action',
{'get_console_output': {'length': 50}})
cs.servers.get_console_output(s, length=50)
self.assertEqual(cs.servers.get_console_output(s, length=50), success)
cs.assert_called('POST', '/servers/1234/action')
cs.assert_called('POST', '/servers/1234/action',
{'get_console_output': {'length': 50}})
def test_get_password(self):
s = cs.servers.get(1234)

View File

@ -902,6 +902,11 @@ class ServerManager(base.BootingManagerWithFind):
you would like to retrieve.
:param length: The number of tail loglines you would like to retrieve.
"""
if length is None:
# NOTE: On v3 get_console_output API, -1 means an unlimited length.
# Here translates None, which means an unlimited in the internal
# implementation, to -1.
length = -1
return self._action('get_console_output',
server, {'length': length})[1]['output']