问题现象
[root@BFJD-PSC-BCEC-CORE-SV26 ~]# neutron port-list
'ascii' codec can't encode characters in position 180791-180794: ordinal not in range(128)
问题分析
port信息中包含中文字符
neutronclient format时不支持ascii code
File "/usr/lib/python2.7/site-packages/cliff/formatters/table.py", line 56, in emit_list
问题处理
- 修改table.py中相关代码
vim /usr/lib/python2.7/site-packages/cliff/formatters/table.py
修改前:
def emit_list(self, column_names, data, stdout, parsed_args):
......
formatted = x.get_string(fields=column_names)
stdout.write(formatted)
stdout.write('\n')
return
def emit_one(self, column_names, data, stdout, parsed_args):
......
formatted = x.get_string(fields=('Field', 'Value'))
stdout.write(formatted)
stdout.write('\n')
修改后:
def emit_list(self, column_names, data, stdout, parsed_args):
......
formatted = x.get_string(fields=column_names)
formatted = formatted.encode('utf-8')
stdout.write(formatted)
stdout.write('\n')
return
def emit_one(self, column_names, data, stdout, parsed_args):
......
formatted = x.get_string(fields=('Field', 'Value'))
formatted = formatted.encode('utf-8')
stdout.write(formatted)
stdout.write('\n')
- 重新查询port信息: