summaryrefslogtreecommitdiff
path: root/openstackclient/compute
diff options
context:
space:
mode:
authorThomas Goirand <zigo@debian.org>2018-02-07 09:25:33 +0100
committerDean Troyer <dtroyer@gmail.com>2018-03-16 11:30:51 -0500
commit9a173568548203757a7fd20883edd56f923cc7e8 (patch)
treeb876bc5d0e64a7951735e74a24527d3601e500ae /openstackclient/compute
parent25e60a4bf1184f2d9006d50d52ced1b5c83737af (diff)
downloadpython-openstackclient-9a173568548203757a7fd20883edd56f923cc7e8.tar.gz
Fix crashing "console log show"
Because of encoding issue, the "openstack console show log" is prone to a stack dump, as explained in the bug report. Use the stdout handle that has already been set up by cliff's App class with a sane default encoding. Change-Id: I4d8b0df7f16ee0463e638bb11276220e5b92023b Closes-Bug: 1747862
Diffstat (limited to 'openstackclient/compute')
-rw-r--r--openstackclient/compute/v2/console.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/openstackclient/compute/v2/console.py b/openstackclient/compute/v2/console.py
index 25f92108..b2f7288f 100644
--- a/openstackclient/compute/v2/console.py
+++ b/openstackclient/compute/v2/console.py
@@ -15,8 +15,6 @@
"""Compute v2 Console action implementations"""
-import sys
-
from osc_lib.cli import parseractions
from osc_lib.command import command
from osc_lib import utils
@@ -60,7 +58,10 @@ class ShowConsoleLog(command.Command):
length += 1
data = server.get_console_output(length=length)
- sys.stdout.write(data)
+
+ if data and data[-1] != '\n':
+ data += '\n'
+ self.app.stdout.write(data)
class ShowConsoleURL(command.ShowOne):