cloudopenstacklibcloud

Libcloud - serviceCatalog empty, but OpenStack lists the services


I'm trying to run some tests with libcloud for OpenStack, but getting stuck on Could not find specified endpoint issue. When I run this code:

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()

I get this error:

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'>

According to the docs https://libcloud.readthedocs.org/en/latest/compute/drivers/openstack.html#i-get-could-not-find-specified-endpoint-error it seems the service catalog from OpenStack is not being filled. And that seems to be true, because this is the answer I get from the server. You can see the serviceCatalog is empty.

{
    "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"
        }
    }
}

but when I run openstack catalog list command, I get this result:

+------------+----------+------------------------------------------------------------------------+
| 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                                        |
...

How do I make libcloud identify my service catalog from openstack, as it does seems to be OK, but not being fetched? Already tried using the ex_force_service_type, ex_force_service_name, ex_force_service_region with the same result. Using ex_force_auth_token and ex_force_base_url results on a 404 error.

Thanks!


Solution

  • Turns out it was a problem with keystone (authentication) version. It is necessary to use

    ex_force_auth_version='3.x_password'
    

    instead of

    ex_force_auth_version='2.0_password'
    

    which is not documented in the libcloud docs for OpenStack: https://libcloud.readthedocs.org/en/latest/compute/drivers/openstack.html#connecting-to-the-openstack-installation

    Also had to include

    ex_tenant_name='admin'
    

    in my case to get it working. Weird part is that doing auth with v2 actually runs auth fine (I was able to get a wrong credentials message), but do not return the catalog list. Only v3 does that. Anybody can explain why that happens?