0

I have a project that authenticates against the keystone API using python, in the last few weeks my auth method has stopped working and I can't see why.

The module looks like this:

from keystoneauth1.identity import v3
from keystoneauth1 import session as keystone_session
from keystoneclient.v3 import client
from keystoneclient import utils

def connect():
    auth = v3.Password(
        auth_url="http://localhost:5000/v3/",
        username="admin",
        password="secret",
        project_name="admin",
        user_domain_name="default",
        project_domain_name="default"
        )
    session = keystone_session.Session(auth=auth,verify=False)
    keystone = client.Client(session=session,interface="public")
    return (keystone)

When I run keystone.projects.list() in ipython using the above code I get an unauthorized error and I don't understand why. If I use the same credentials with the openstack cli client and run openstack project list I get the list of projects I expect.

Environment:

  • python-openstackclient 4.0.0
  • python-keystoneclient 3.19.0

I am certain I have missed something important.

Lance Haig
  • 332
  • 4
  • 13
  • There is a syntax error in your code (`password=s"secret"`), but other than that, everything looks fine. If I replace `auth_url` and `password` with values appropriate for my local cloud, this works fine. – larsks Jan 06 '20 at 20:40
  • The typo is because I was replacing variables with text :-) I will fix the typo. Unfortunately this means that there is something in my local keystone that is not working properly or not being configured properly. – Lance Haig Jan 07 '20 at 08:16
  • Anything interesting in your keystone log? How are you providing the credentials to the openstack client? – larsks Jan 07 '20 at 11:38
  • The keystone log just shows the same error message and nothing else. I use system environment variables for the client as per the docs. I will spin up the environment on the weekend to see if I can debug further. It just seems strange that the client is working but the code that does essentially the same fails. – Lance Haig Jan 08 '20 at 08:49
  • So it seems this error only happens when I run my code against a keystone instance that I created in a container for running the tests. I am not sure why it is failing for now as it seems that user that I create as part of the setup is not able to see the default project. I will have to try to figure that out. This is the repository for the docker image https://github.com/lhaig/usery-keystone – Lance Haig Jan 14 '20 at 19:24

0 Answers0