Merge lp://staging/~thedac/charm-helpers/get-catalog into lp://staging/charm-helpers

Proposed by David Ames
Status: Merged
Merged at revision: 752
Proposed branch: lp://staging/~thedac/charm-helpers/get-catalog
Merge into: lp://staging/charm-helpers
Diff against target: 133 lines (+42/-38)
1 file modified
charmhelpers/contrib/openstack/amulet/utils.py (+42/-38)
To merge this branch: bzr merge lp://staging/~thedac/charm-helpers/get-catalog
Reviewer Review Type Date Requested Status
Edward Hope-Morley Approve
Review via email: mp+325427@code.staging.launchpad.net

Description of the change

Update use of client.service_catalog with sessions

Due to a bug in keystone client when using keystoneauth1.sessions
keystoneclient.service_catalog is no longer populated automatically.

Manually setting client.auth_ref has the side effect of populating
the service_catalog and has become the undocumented but accepted
practice.

This change adds the manual setting of auth_ref and updates the query
arguments for url_for().

To post a comment you must log in.
Revision history for this message
Alex Kavanagh (ajkavanagh) wrote :

Unless something has changed, and it may well have done, then this is in response to https://bugs.launchpad.net/python-keystoneclient/+bug/1547331 which is about v3 keystone client having the missing service_catalog?

If so, the get_access() method forces a pre-auth and if placed on the keystone client, will then get the service catalog:

e.g.

    auth = keystoneclient.auth.identity.v3.Password(...)
    sess = keystoneclient.session.Session(auth=auth)
    keystone = keystone.v3.client.Client(session=sess)
    keystone.auth_ref = auth.get_access(sess)

At this point the keystone variable can be used to get the catalog:

    keystone.service_catalog.get_endpoints()

This works (for v3) as it is in the Barbican charm's keystone v3 code. It's also backwards compatible with the v2_0 client if v2.Password(...) is used.

See https://github.com/openstack/charm-barbican/blob/master/src/tests/basic_deployment.py#L142 as an example?

However, if this isn't the use case, then sorry for the interruption!

Revision history for this message
David Ames (thedac) wrote :

To be clear I this now implements Alex's proposed changes.

753. By David Ames

Normalize client.Client for v2 and v3

Revision history for this message
Edward Hope-Morley (hopem) wrote :

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches