Attributeerror encountered when using ceilometer and gnocchi to execute commands related to gnocchi metric list: _Environ instance has no attribute ‘

AttributeError encountered when executing gnocchi metric list related commands using ceilometer and gnocchi: _Environ instance has no attribute ‘。
Control node execution: gnocchi metric list
Traceback (most recent call last):
File “/usr/bin/gnocchi”, line 10, in
sys.exit(main())
File “/usr/lib/python2.7/site-packages/gnocchiclient/shell.py”, line 252, in main
return GnocchiShell().run(args)
File “/usr/lib/python2.7/site-packages/gnocchiclient/shell.py”, line 99, 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 130, in build_option_parser
os.environ.set(“OS_AUTH_TYPE”, “password”)
AttributeError: _Environ instance has no attribute ‘set’


Solution:
vi keystonerc_admin
Modify
unset OS_SERVICE_TOKEN
export OS_USERNAME=admin
export OS_PASSWORD=‘openstack password’
export OS_REGION_NAME=RegionOne
export OS_AUTH_URL=http://x.x.x.x:5000/v3
export PS1=’[\[email protected]\h \W(keystone_admin)]$ ’
export OS_PROJECT_NAME=admin
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_DOMAIN_NAME=Default
export OS_IDENTITY_API_VERSION=3
export OS_PLACEMENT_API_VERSION=1.17
export OS_AUTH_TYPE=password
At this point the following command can be used in the terminal:

source ~/keystonerc_admin
gnocchi metric list
gnocchi metric list | grep cpu
gnocchi resource list
gnocchi resource list  --type image
gnocchi measures show 839afa02-1668-4922-a33e-6b6ea7780715


Read More: