Libcloud - serviceCatalog 为空,但 OpenStack 列出了服务
Libcloud - serviceCatalog empty, but OpenStack lists the services
我正在尝试 运行 对 OpenStack 的 libcloud 进行一些测试,但卡在 找不到指定的端点 问题上。当我 运行 此代码时:
from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driver
import libcloud.security
libcloud.security.VERIFY_SSL_CERT = False
OpenStack = get_driver(Provider.OPENSTACK)
driver = OpenStack(
'admin', 'password',
ex_force_auth_url='http://controller:5000',
ex_force_auth_version='2.0_password'
)
driver.list_images()
我收到这个错误:
Traceback (most recent call last):
File "my_script.py", line 25, in <module>
driver.list_images()
File "/usr/local/lib/python2.7/dist-packages/libcloud/compute/drivers/openstack.py", line 279, in list_images
self.connection.request('/images/detail').object, ex_only_active)
File "/usr/local/lib/python2.7/dist-packages/libcloud/common/openstack.py", line 202, in request
raw=raw)
File "/usr/local/lib/python2.7/dist-packages/libcloud/common/base.py", line 709, in request
action = self.morph_action_hook(action)
File "/usr/local/lib/python2.7/dist-packages/libcloud/common/openstack.py", line 269, in morph_action_hook
self._populate_hosts_and_request_paths()
File "/usr/local/lib/python2.7/dist-packages/libcloud/common/openstack.py", line 313, in _populate_hosts_and_request_paths
url = self._ex_force_base_url or self.get_endpoint()
File "/usr/local/lib/python2.7/dist-packages/libcloud/common/openstack.py", line 254, in get_endpoint
region=service_region)
File "/usr/local/lib/python2.7/dist-packages/libcloud/common/openstack_identity.py", line 278, in get_endpoint
raise LibcloudError('Could not find specified endpoint')
libcloud.common.types.LibcloudError: <LibcloudError in None 'Could not find specified endpoint'>
根据文档 https://libcloud.readthedocs.org/en/latest/compute/drivers/openstack.html#i-get-could-not-find-specified-endpoint-error 看来 OpenStack 的服务目录没有被填充。这似乎是真的,因为这是我从服务器得到的答案。可以看到serviceCatalog是空的。
{
"access": {
"metadata": {
"is_admin": 0,
"roles": []
},
"serviceCatalog": [],
"token": {
"audit_ids": [
"bH-SKGBdRCWlZTtB8LcDIg"
],
"expires": "2016-04-18T20:41:38Z",
"id": "3298b08a96284dfd9473881afce659c9",
"issued_at": "2016-04-18T19:41:38.277756"
},
"user": {
"id": "74767f37d3ee4e3d92a1d0fe6d7da82f",
"name": "admin",
"roles": [],
"roles_links": [],
"username": "admin"
}
}
}
但是当我 运行 openstack catalog list
命令时,我得到这个结果:
+------------+----------+------------------------------------------------------------------------+
| Name | Type | Endpoints |
+------------+----------+------------------------------------------------------------------------+
| keystone | identity | RegionOne |
| | | public: http://controller:5000/v2.0 |
| | | RegionOne |
| | | admin: http://controller:35357/v2.0 |
| | | RegionOne |
| | | internal: http://controller:5000/v2.0 |
| | | |
| glance | image | RegionOne |
| | | public: http://controller:9292 |
| | | RegionOne |
| | | internal: http://controller:9292 |
| | | RegionOne |
| | | admin: http://controller:9292 |
...
我如何让 libcloud 从 openstack 识别我的服务目录,因为它似乎没问题,但没有被提取?已经尝试使用 ex_force_service_type、ex_force_service_name、ex_force_service_region,结果相同。使用 ex_force_auth_token 和 ex_force_base_url 会导致 404 错误。
谢谢!
原来是keystone(认证)版本的问题。必须使用
ex_force_auth_version='3.x_password'
而不是
ex_force_auth_version='2.0_password'
OpenStack 的 libcloud 文档中没有记录:
https://libcloud.readthedocs.org/en/latest/compute/drivers/openstack.html#connecting-to-the-openstack-installation
还必须包括
ex_tenant_name='admin'
在我的例子中让它工作。奇怪的是,使用 v2 进行身份验证实际上可以很好地运行身份验证(我能够得到错误的凭据消息),但不要 return 目录列表。只有 v3 可以做到这一点。谁能解释为什么会这样?
我正在尝试 运行 对 OpenStack 的 libcloud 进行一些测试,但卡在 找不到指定的端点 问题上。当我 运行 此代码时:
from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driver
import libcloud.security
libcloud.security.VERIFY_SSL_CERT = False
OpenStack = get_driver(Provider.OPENSTACK)
driver = OpenStack(
'admin', 'password',
ex_force_auth_url='http://controller:5000',
ex_force_auth_version='2.0_password'
)
driver.list_images()
我收到这个错误:
Traceback (most recent call last):
File "my_script.py", line 25, in <module>
driver.list_images()
File "/usr/local/lib/python2.7/dist-packages/libcloud/compute/drivers/openstack.py", line 279, in list_images
self.connection.request('/images/detail').object, ex_only_active)
File "/usr/local/lib/python2.7/dist-packages/libcloud/common/openstack.py", line 202, in request
raw=raw)
File "/usr/local/lib/python2.7/dist-packages/libcloud/common/base.py", line 709, in request
action = self.morph_action_hook(action)
File "/usr/local/lib/python2.7/dist-packages/libcloud/common/openstack.py", line 269, in morph_action_hook
self._populate_hosts_and_request_paths()
File "/usr/local/lib/python2.7/dist-packages/libcloud/common/openstack.py", line 313, in _populate_hosts_and_request_paths
url = self._ex_force_base_url or self.get_endpoint()
File "/usr/local/lib/python2.7/dist-packages/libcloud/common/openstack.py", line 254, in get_endpoint
region=service_region)
File "/usr/local/lib/python2.7/dist-packages/libcloud/common/openstack_identity.py", line 278, in get_endpoint
raise LibcloudError('Could not find specified endpoint')
libcloud.common.types.LibcloudError: <LibcloudError in None 'Could not find specified endpoint'>
根据文档 https://libcloud.readthedocs.org/en/latest/compute/drivers/openstack.html#i-get-could-not-find-specified-endpoint-error 看来 OpenStack 的服务目录没有被填充。这似乎是真的,因为这是我从服务器得到的答案。可以看到serviceCatalog是空的。
{
"access": {
"metadata": {
"is_admin": 0,
"roles": []
},
"serviceCatalog": [],
"token": {
"audit_ids": [
"bH-SKGBdRCWlZTtB8LcDIg"
],
"expires": "2016-04-18T20:41:38Z",
"id": "3298b08a96284dfd9473881afce659c9",
"issued_at": "2016-04-18T19:41:38.277756"
},
"user": {
"id": "74767f37d3ee4e3d92a1d0fe6d7da82f",
"name": "admin",
"roles": [],
"roles_links": [],
"username": "admin"
}
}
}
但是当我 运行 openstack catalog list
命令时,我得到这个结果:
+------------+----------+------------------------------------------------------------------------+
| Name | Type | Endpoints |
+------------+----------+------------------------------------------------------------------------+
| keystone | identity | RegionOne |
| | | public: http://controller:5000/v2.0 |
| | | RegionOne |
| | | admin: http://controller:35357/v2.0 |
| | | RegionOne |
| | | internal: http://controller:5000/v2.0 |
| | | |
| glance | image | RegionOne |
| | | public: http://controller:9292 |
| | | RegionOne |
| | | internal: http://controller:9292 |
| | | RegionOne |
| | | admin: http://controller:9292 |
...
我如何让 libcloud 从 openstack 识别我的服务目录,因为它似乎没问题,但没有被提取?已经尝试使用 ex_force_service_type、ex_force_service_name、ex_force_service_region,结果相同。使用 ex_force_auth_token 和 ex_force_base_url 会导致 404 错误。
谢谢!
原来是keystone(认证)版本的问题。必须使用
ex_force_auth_version='3.x_password'
而不是
ex_force_auth_version='2.0_password'
OpenStack 的 libcloud 文档中没有记录: https://libcloud.readthedocs.org/en/latest/compute/drivers/openstack.html#connecting-to-the-openstack-installation
还必须包括
ex_tenant_name='admin'
在我的例子中让它工作。奇怪的是,使用 v2 进行身份验证实际上可以很好地运行身份验证(我能够得到错误的凭据消息),但不要 return 目录列表。只有 v3 可以做到这一点。谁能解释为什么会这样?