Fix fetching of maximum length of VM's console output

In nova's client code there is constant
MAX_SERVER_CONSOLE_OUTPUT_LENGTH which is used if parameter
"length" is not passed to the "get_console_output" function.
But it wasn't used as max possible length of console output to
fetch but rather like default length and there was possibility to
call "get_console_output" function with length parameter set to
some value higher than MAX_SERVER_CONSOLE_OUTPUT_LENGTH.
Now it will always be limited to MAX_SERVER_CONSOLE_OUTPUT_LENGTH,
even if "length" passed to the "get_console_output" function will be
higher.

Change-Id: Iafee632e7c8487372bbe6bfbae91b5fa53150c21
This commit is contained in:
Slawek Kaplonski
2019-12-19 23:39:09 +01:00
committed by Federico Ressi
parent 78fcbbf119
commit 7c96c04bfd

View File

@@ -105,7 +105,10 @@ def get_console_output(server, timeout=None, interval=1., length=None,
client=None):
client = nova_client(client)
start_time = time.time()
length = length or MAX_SERVER_CONSOLE_OUTPUT_LENGTH
if length is not None:
length = min(length, MAX_SERVER_CONSOLE_OUTPUT_LENGTH)
else:
length = MAX_SERVER_CONSOLE_OUTPUT_LENGTH
while True:
try:
output = client.servers.get_console_output(server=server,