安装OpenStack Liberty版本,在获取token遇到如下错误,解决办法参看内容末尾,
[root@controller ~]# openstack --debug token issue
START with options: ['--debug', 'token', 'issue']
options: Namespace(access_token_endpoint='', auth_type='', auth_url='http://controller:35357/v3', cacert='', client_id='', client_secret='', cloud='', debug=True, default_domain='default', deferred_help=False, domain_id='', domain_name='', endpoint='', identity_provider='', insecure=None, interface='', log_file=None, os_compute_api_version='', os_identity_api_version='3', os_image_api_version='', os_network_api_version='', os_object_api_version='', os_project_id=None, os_project_name=None, os_volume_api_version='', password='admin', project_domain_id='default', project_domain_name='', project_id='', project_name='admin', protocol='', region_name='', scope='', timing=False, token='d17c48d4b1423e0b155b', trust_id='', url='http://controller:35357/v3', user_domain_id='default', user_domain_name='', user_id='', username='admin', verbose_level=3, verify=None)
defaults: {'auth_type': 'token_endpoint', 'compute_api_version': '2', 'key': None, 'database_api_version': '1.0', 'api_timeout': None, 'baremetal_api_version': '1', 'cacert': None, 'image_api_use_tasks': False, 'floating_ip_source': 'neutron', 'orchestration_api_version': '1', 'interface': None, 'network_api_version': '2', 'image_format': 'qcow2', 'object_api_version': '1', 'image_api_version': '2', 'verify': True, 'identity_api_version': '2', 'volume_api_version': '1', 'cert': None, 'secgroup_source': 'neutron', 'dns_api_version': '2', 'disable_vendor_agent': {}}
cloud cfg: {'auth_type': 'token_endpoint', 'compute_api_version': '2', 'orchestration_api_version': '1', 'database_api_version': '1.0', 'tenant_name': 'admin', 'interface': None, 'auth_url': 'http://controller:35357/v3', 'network_api_version': '2', 'image_format': 'qcow2', 'object_api_version': '1', 'image_api_version': '2', 'verify': True, 'timing': False, 'dns_api_version': '2', 'project_domain_id': 'default', 'username': 'admin', 'project_name': 'admin', 'verbose_level': 3, 'region_name': '', 'api_timeout': None, 'baremetal_api_version': '1', 'auth': {'url': 'http://controller:35357/v3', 'token': 'd17c48d4b1423e0b155b'}, 'default_domain': 'default', 'image_api_use_tasks': False, 'floating_ip_source': 'neutron', 'key': None, 'cacert': None, 'password': 'admin', 'user_domain_id': 'default', 'deferred_help': False, 'identity_api_version': '3', 'volume_api_version': '1', 'cert': None, 'secgroup_source': 'neutron', 'debug': True, 'disable_vendor_agent': {}}
compute API version 2, cmd group openstack.compute.v2
network API version 2, cmd group openstack.network.v2
image API version 2, cmd group openstack.image.v2
volume API version 1, cmd group openstack.volume.v1
identity API version 3, cmd group openstack.identity.v3
object_store API version 1, cmd group openstack.object_store.v1
command: token issue -> openstackclient.identity.v3.token.IssueToken
Auth plugin token_endpoint selected
auth_type: token_endpoint
Using auth plugin: token_endpoint
Using parameters {'url': 'http://controller:35357/v3', 'token': 'd17c48d4b1423e0b155b'}
Get auth_ref
take_action(Namespace(columns=[], formatter='table', max_width=0, noindent=False, prefix='', variables=[]))
Auth plugin token_endpoint selected
auth_type: token_endpoint
Using auth plugin: token_endpoint
Using parameters {'url': 'http://controller:35357/v3', 'token': 'd17c48d4b1423e0b155b'}
Get auth_ref
'NoneType' object has no attribute 'service_catalog'
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/cliff/app.py", line 374, in run_subcommand
result = cmd.run(parsed_args)
File "/usr/lib/python2.7/site-packages/cliff/display.py", line 92, in run
column_names, data = self.take_action(parsed_args)
File "/usr/lib/python2.7/site-packages/openstackclient/common/utils.py", line 45, in wrapper
return func(self, *args, **kwargs)
File "/usr/lib/python2.7/site-packages/openstackclient/identity/v3/token.py", line 187, in take_action
token = self.app.client_manager.auth_ref.service_catalog.get_token()
AttributeError: 'NoneType' object has no attribute 'service_catalog'
clean_up IssueToken: 'NoneType' object has no attribute 'service_catalog'
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/openstackclient/shell.py", line 112, in run
ret_val = super(OpenStackShell, self).run(argv)
File "/usr/lib/python2.7/site-packages/cliff/app.py", line 255, in run
result = self.run_subcommand(remainder)
File "/usr/lib/python2.7/site-packages/cliff/app.py", line 374, in run_subcommand
result = cmd.run(parsed_args)
File "/usr/lib/python2.7/site-packages/cliff/display.py", line 92, in run
column_names, data = self.take_action(parsed_args)
File "/usr/lib/python2.7/site-packages/openstackclient/common/utils.py", line 45, in wrapper
return func(self, *args, **kwargs)
File "/usr/lib/python2.7/site-packages/openstackclient/identity/v3/token.py", line 187, in take_action
token = self.app.client_manager.auth_ref.service_catalog.get_token()
AttributeError: 'NoneType' object has no attribute 'service_catalog'
END return value: 1
解决办法:
需要在admin-openrc.sh中添加一条环境变量:
1 export OS_PROJECT_DOMAIN_ID=default
2 export OS_USER_DOMAIN_ID=default
3 export OS_PROJECT_NAME=admin
4 export OS_TENANT_NAME=admin
5 export OS_USERNAME=admin
6 export OS_PASSWORD=admin
7 export OS_AUTH_URL=http://controller:35357/v3
8 export OS_AUTH_TYPE=password
9 export OS_IDENTITY_API_VERSION=3
然后运行就正常了:
[root@controller ~]# source admin-openrc.sh
[root@controller ~]# openstack token issue
+------------+----------------------------------+
| Field | Value |
+------------+----------------------------------+
| expires | 2016-07-22T13:42:31.027004Z |
| id | 2864231122d945498f5a696ac152cf70 |
| project_id | 2aaa6d43c5e04a4daff3d36d0bf31424 |
| user_id | 17900ac2085b4e67b89a753a1deab1bf |
+------------+----------------------------------+
|
|