使用openstack project list时,报以下错误:
'ascii' codec can't encode characters in position 453-457: ordinal not in range(128)
然后通过openstack --debug project list,尝试找到更多的报错信息
GET call to identity for http://keystone-ha-vip:35357/v3/projects used request id req-ba08ac3e-476c-49b9-837a-c08cd6ad0f6d
'ascii' codec can't encode characters in position 453-457: ordinal not in range(128)
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/cliff/app.py", line 400, in run_subcommand
result = cmd.run(parsed_args)
File "/usr/lib/python2.7/site-packages/osc_lib/command/command.py", line 41, in run
return super(Command, self).run(parsed_args)
File "/usr/lib/python2.7/site-packages/cliff/display.py", line 115, in run
self.produce_output(parsed_args, column_names, data)
File "/usr/lib/python2.7/site-packages/cliff/lister.py", line 53, in produce_output
parsed_args,
File "/usr/lib/python2.7/site-packages/cliff/formatters/table.py", line 112, in emit_list
stdout.write(formatted)
File "/usr/lib64/python2.7/codecs.py", line 351, in write
data, consumed = self.encode(object, self.errors)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 453-457: ordinal not in range(128)
clean_up ListProject: 'ascii' codec can't encode characters in position 453-457: ordinal not in range(128)
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/osc_lib/shell.py", line 134, in run
ret_val = super(OpenStackShell, self).run(argv)
File "/usr/lib/python2.7/site-packages/cliff/app.py", line 279, in run
result = self.run_subcommand(remainder)
File "/usr/lib/python2.7/site-packages/osc_lib/shell.py", line 169, in run_subcommand
ret_value = super(OpenStackShell, self).run_subcommand(argv)
File "/usr/lib/python2.7/site-packages/cliff/app.py", line 400, in run_subcommand
result = cmd.run(parsed_args)
File "/usr/lib/python2.7/site-packages/osc_lib/command/command.py", line 41, in run
return super(Command, self).run(parsed_args)
File "/usr/lib/python2.7/site-packages/cliff/display.py", line 115, in run
self.produce_output(parsed_args, column_names, data)
File "/usr/lib/python2.7/site-packages/cliff/lister.py", line 53, in produce_output
parsed_args,
File "/usr/lib/python2.7/site-packages/cliff/formatters/table.py", line 112, in emit_list
stdout.write(formatted)
File "/usr/lib64/python2.7/codecs.py", line 351, in write
data, consumed = self.encode(object, self.errors)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 453-457: ordinal not in range(128)
由此可见,是client端编码出了问题
检查系统环境变量
echo $LC_ALL, 输出C
确实是编码问题
解决方法是,在admin-openrc.sh脚本中增加:
export LC_ALL='en_US.UTF-8'解决