Keystone doesn't like UTF-8 characters
Issue
- We are having trouble when integrating Keystone with our LDAP, which uses non-ASCII characters in multiple fields. In this case, the error is triggered when the Keystone client output is not a terminal:
Apr 11 10:33:32 localhost os-collect-config: #033[1;31mError: Could not prefetch keystone_user provider 'openstack': Execution of '/usr/bin/openstack user list --quiet --format csv --long' returned 1: ERROR: openstack 'ascii' codec can't encode character u'\xd1' in position 24: ordinal not in range(128)
- This can be reproduced by hand by running the following command from a terminal:
[root@hostname01 ~]# openstack --os-token redacted --os-url http://10.10.10.10:35357/v2.0/ user list --quiet --format csv --long 2>&1 | grep .
ERROR: openstack 'ascii' codec can't encode character u'\xd1' in position 24: ordinal not in range(128)
- One workaround is to remove the "| grep ."
[root@hostname01 ~]# openstack --os-token redacted --os-url http://10.10.10.10:35357/v2.0/ user list --quiet --format csv --long
- Another workaround is to patch
/usr/lib/python2.7/site-packages/cliff/formatters/commaseparated.py
--- /usr/lib/python2.7/site-packages/cliff/formatters/commaseparated.py.old 2016-04-11 17:01:24.160958338 +0200
+++ /usr/lib/python2.7/site-packages/cliff/formatters/commaseparated.py 2016-04-11 17:01:31.964040445 +0200
@@ -3,6 +3,8 @@
import os
import sys
+reload(sys)
+sys.setdefaultencoding('UTF8')
from .base import ListFormatter
Environment
- Red Hat OpenStack 7.0 (RHOSP)
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.