运行 gnocchi resource list --type image,报AttributeError: _Environ instance has no attribute ‘set‘的解决

43 篇文章 0 订阅
30 篇文章 1 订阅

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"

以上两种方法供借鉴

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值