LibserviceCatalog为空,但OpenStack列出了服务



我试图用libcloud for OpenStack运行一些测试,但遇到了找不到指定端点问题。当我运行此代码时:

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找不到指定的端点错误,似乎没有填充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_foorce_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-到openstack安装

还必须包括

ex_tenant_name='admin'

就我而言,让它发挥作用。奇怪的是,使用v2进行身份验证实际上会运行身份验证(我得到了一个错误的凭据消息),但不会返回目录列表。只有v3能做到这一点。有人能解释为什么会发生这种事吗?

相关内容

  • 没有找到相关文章

最新更新