openstack安装和配置好ceilometer服务,运行命令后报错
[root@controller]# gnocchi resource list --type image
报的错误如下:
Traceback (most recent call last):
File "/usr/bin/gnocchi", line 10, in <module>
sys.exit(main())
File "/usr/lib/python2.7/site-packages/gnocchiclient/shell.py", line 253, in main
return GnocchiShell().run(args)
File "/usr/lib/python2.7/site-packages/gnocchiclient/shell.py", line 100, in __init__
deferred_help=True,
File "/usr/lib/python2.7/site-packages/cliff/app.py", line 79, in __init__
self.parser = self.build_option_parser(description, version)
File "/usr/lib/python2.7/site-packages/gnocchiclient/shell.py", line 131, in build_option_parser
os.environ.set("OS_AUTH_TYPE","password")
AttributeError: _Environ instance has no attribute 'set'
AttributeError: _Environ instance has no attribute 'set',是python相关的。可能是函数没有相应的值,应该怎么该,琢磨了好久,尝试了几次,总结出两个办法消除这个错误。
方法一:
vim /usr/lib/python2.7/site-packages/gnocchiclient/shell.py
#将
# NOTE(jd) This is a workaroun for people using Keystone auth with the
# CLI. A lot of rc files do not export OS_AUTH_TYPE=password and
# assumes it is the default. It's not in that case, but since we can't
# fix all the rc files of the world, workaround it here.
if ("OS_PASSWORD" in os.environ and
"OS_AUTH_TYPE" not in os.environ):
os.environ.set("OS_AUTH_TYPE","password")
#修改为
# NOTE(jd) This is a workaroun for people using Keystone auth with the
# CLI. A lot of rc files do not export OS_AUTH_TYPE=password and
# assumes it is the default. It's not in that case, but since we can't
# fix all the rc files of the world, workaround it here.
if ("OS_PASSWORD" in os.environ and
"OS_AUTH_TYPE" not in os.environ):
os.environ.setdefault("OS_AUTH_TYPE","password")
就是将 os.environ.set("OS_AUTH_TYPE","password")修改为os.environ.setdefault("OS_AUTH_TYPE","password")
方法二:
#将
# NOTE(jd) This is a workaroun for people using Keystone auth with the
# CLI. A lot of rc files do not export OS_AUTH_TYPE=password and
# assumes it is the default. It's not in that case, but since we can't
# fix all the rc files of the world, workaround it here.
if ("OS_PASSWORD" in os.environ and
"OS_AUTH_TYPE" not in os.environ):
os.environ.set("OS_AUTH_TYPE","password")
#修改为
# NOTE(jd) This is a workaroun for people using Keystone auth with the
# CLI. A lot of rc files do not export OS_AUTH_TYPE=password and
# assumes it is the default. It's not in that case, but since we can't
# fix all the rc files of the world, workaround it here.
if ("OS_PASSWORD" in os.environ and
"OS_AUTH_TYPE" not in os.environ):
os.environ["OS_AUTH_TYPE"]="password"
就是将os.environ.set("OS_AUTH_TYPE","password")修改为os.environ["OS_AUTH_TYPE"]="password"
以上两种方法供借鉴