From 7acbc5f1f8d6d8079f7aaf5e60c8b7a2ee3a5932 Mon Sep 17 00:00:00 2001 From: Ken'ichi Ohmichi Date: Tue, 15 Apr 2014 09:47:51 +0900 Subject: [PATCH] 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 --- novaclient/tests/v3/test_servers.py | 9 ++++++--- novaclient/v3/servers.py | 5 +++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/novaclient/tests/v3/test_servers.py b/novaclient/tests/v3/test_servers.py index fdeb02721..c29b7e1c4 100644 --- a/novaclient/tests/v3/test_servers.py +++ b/novaclient/tests/v3/test_servers.py @@ -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) diff --git a/novaclient/v3/servers.py b/novaclient/v3/servers.py index 92dffcfd1..076a6bf35 100644 --- a/novaclient/v3/servers.py +++ b/novaclient/v3/servers.py @@ -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']