summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Riedemann <mriedem.os@gmail.com>2019-04-11 12:03:30 -0400
committerMatt Riedemann <mriedem.os@gmail.com>2019-04-11 20:49:27 +0000
commit60bf9a236dfbaa98e7d93b4baf0997e645b02bb0 (patch)
tree960ef2812a0bf422a7ac75f4cd498292db6bde2e
parent2ca1814a2b4d1e887974a71951b7e744273a43b4 (diff)
downloadpython-novaclient-60bf9a236dfbaa98e7d93b4baf0997e645b02bb0.tar.gz
Add test for console-log and docs for bug 1746534
We had no unit test coverage for the console-log command so this adds a simple test. It unfortunately does not recreate the original UnicodeEncodeError bug though, but it gives us some test coverage anyway. This change also adds docs on how to resolve bug 1746534 by configuring the environment for UTF-8 as noted in the revert change Iaeec1e74262a35f3de3c81f7013835a6aa6f9029. The documentation added here is shamelessly copied from Click [1] which was found via the PEP 538 docs [2]. [1] https://click.palletsprojects.com/en/5.x/python3/#python-3-surrogate-handling [2] https://www.python.org/dev/peps/pep-0538/ Change-Id: Ic7059260dfc031ea1b08d2b8a7cec684bbe7dfa5 Related-Bug: #1823287 Related-Bug: #1746534 (cherry picked from commit e8f7aaf9091330bbb046f2bd42dc9c92f1dcebaa)
-rw-r--r--doc/source/cli/nova.rst27
-rw-r--r--novaclient/tests/unit/v2/test_shell.py6
2 files changed, 33 insertions, 0 deletions
diff --git a/doc/source/cli/nova.rst b/doc/source/cli/nova.rst
index 21f760d7..6caca058 100644
--- a/doc/source/cli/nova.rst
+++ b/doc/source/cli/nova.rst
@@ -1177,6 +1177,33 @@ nova console-log
Get console log output of a server.
+**Locale encoding issues**
+
+If you encounter an error such as:
+
+.. code-block:: console
+
+ UnicodeEncodeError: 'ascii' codec can't encode characters in position
+
+The solution to these problems is different depending on which locale your
+computer is running in.
+
+For instance, if you have a German Linux machine, you can fix the problem by
+exporting the locale to de_DE.utf-8:
+
+.. code-block:: console
+
+ export LC_ALL=de_DE.utf-8
+ export LANG=de_DE.utf-8
+
+If you are on a US machine, en_US.utf-8 is the encoding of choice. On some
+newer Linux systems, you could also try C.UTF-8 as the locale:
+
+.. code-block:: console
+
+ export LC_ALL=C.UTF-8
+ export LANG=C.UTF-8
+
**Positional arguments:**
``<server>``
diff --git a/novaclient/tests/unit/v2/test_shell.py b/novaclient/tests/unit/v2/test_shell.py
index e2297699..bf7a8667 100644
--- a/novaclient/tests/unit/v2/test_shell.py
+++ b/novaclient/tests/unit/v2/test_shell.py
@@ -3553,6 +3553,12 @@ class ShellTest(utils.TestCase):
self.run_command('availability-zone-list')
self.assert_called('GET', '/os-availability-zone/detail')
+ def test_console_log(self):
+ out = self.run_command('console-log --length 20 1234')[0]
+ self.assert_called('POST', '/servers/1234/action',
+ body={'os-getConsoleOutput': {'length': '20'}})
+ self.assertIn('foo', out)
+
def test_server_security_group_add(self):
self.run_command('add-secgroup sample-server testgroup')
self.assert_called('POST', '/servers/1234/action',