Fix the unlimited length of console-log

Since the commit Idf88a238d1b0e545ebab5be872269b1b1030cc56 of Nova,
the unlimited length has been changed to -1 for API consistency.

This patch applies it to novaclient.

Change-Id: I581609a55f081184ad9d791ba38d78fa30d298a6
Closes-Bug: #1295426
This commit is contained in:
Ken'ichi Ohmichi 2014-04-15 09:47:51 +09:00
parent 5ff5e05fac
commit 7acbc5f1f8
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']