diff options
author | Thomas Goirand <zigo@debian.org> | 2018-02-07 09:17:12 +0100 |
---|---|---|
committer | Thomas Goirand <zigo@debian.org> | 2018-02-08 09:23:05 +0100 |
commit | d272d6f3df2610a62f81e2ca26798ea8a6674b06 (patch) | |
tree | 79e04983fea84a6156051201864b74b1953e9e4f | |
parent | 5de74bef5c67f08811ab0c166df0230b01e4ed8a (diff) | |
download | python-novaclient-d272d6f3df2610a62f81e2ca26798ea8a6674b06.tar.gz |
Fix crashing console-log
Because of encoding issue, the "nova console-log" is prone to a stack
dump, as explained in the bug report.
This patch sets the encoding output of stdout to utf8 before attempting
to print in it.
Change-Id: I63bc3dc8807021f5a97f58b0fe13a10d93688c7e
Closes-Bug: 1746534
-rw-r--r-- | novaclient/v2/shell.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/novaclient/v2/shell.py b/novaclient/v2/shell.py index e73bd504..e919caa1 100644 --- a/novaclient/v2/shell.py +++ b/novaclient/v2/shell.py @@ -19,6 +19,7 @@ from __future__ import print_function import argparse +import codecs import collections import datetime import getpass @@ -2594,7 +2595,10 @@ def do_console_log(cs, args): """Get console log output of a server.""" server = _find_server(cs, args.server) data = server.get_console_output(length=args.length) - print(data) + + if data and data[-1] != '\n': + data += '\n' + codecs.getwriter('utf-8')(sys.stdout).write(data) @utils.arg('server', metavar='<server>', help=_('Name or ID of server.')) |