Ask Your Question

How to get service catalog with Python API?

asked 2019-08-07 15:01:07 -0600

Josh Fuhs gravatar image

I've been unsuccessful at finding documentation describing how to pull the service catalog via the Python API. It seems like this should be included in any "Getting Started with OpenStack and Python," but my search results are empty.

This describes the REST structures a bit: (

edit retag flag offensive close merge delete


The OpenStack SDK has a method for listing all endpoints. There is also a service list documented further down on that page.

DISCLAIMER: I haven't tried it.

Bernd Bausch gravatar imageBernd Bausch ( 2019-08-07 18:33:47 -0600 )edit

I hadn't even been using the openstack module. Most of the documentation I see goes directly to the service client APIs. I've found something that appears to work with keystoneauth1. I'll write it up shortly.

Josh Fuhs gravatar imageJosh Fuhs ( 2019-08-08 14:39:44 -0600 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2019-08-09 11:35:09 -0600

Josh Fuhs gravatar image

The following code will produce a service-type to public-endpoint URL dictionary in service_endpoints:

from keystoneauth1 import loading, identity, session, exceptions

auth = identity.Password(
    project_name=project_name )
sess = session.Session( auth=auth )

# Non-intuitive line
auth_info = sess.auth.get_auth_ref(sess)
catalog = auth_ref.service_catalog.get_endpoints( interface="public" )
service_endpoints = {}
for s_name in catalog:
    s = catalog[s_name]
    service_endpoints[s_name] = s[0]["url"]

# Here's the map.
edit flag offensive delete link more

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower


Asked: 2019-08-07 15:01:07 -0600

Seen: 264 times

Last updated: Aug 07 '19