EndpointNotFound errors with Keystone v3 Python API [closed]
Using Juno...
I'm an operator trying to replace the crufty Essex era bash scripts we use for account registration with something saner. Using keystone v3 python api seems the right thing.
Keystone is serving v2 and v3. My 'identity' endoint points to v2 but Horizion uses v3 and I can access v3 vi the 'openstack' cli by specifying the right OS_AUTH_URL and OS_IDENTITY_API_VERSION=3
But...I cannot get my python script to do the right thing, it keeps failing with:
keystoneclient.openstack.common.apiclient.exceptions.EndpointNotFound
If I switch my identity enpoint to be explicity /v3 then everything works but my understanding is that leaving it a /v2.0 for the majority version 2 clients should work with newer clients being able to do discovery.
I'm following the example at http://docs.openstack.org/developer/p...
My specific case uses
from keystoneclient.auth.identity import v3
from keystoneclient import session
from keystoneclient.v3 import client
from os import environ
from subprocess import Popen, PIPE, call, check_output, check_call
#interactive-fu
import rlcompleter, readline
readline.parse_and_bind('tab: complete')
debug=True
os_auth_file='/etc/openrcV3' #where to find authentication bits
def source(script, update=True, clean=True):
"""
Source variables from a shell script
import them in the environment (if update==True)
and report only the script variables (if clean==True)
"""
global environ
if clean:
environ_back = dict(environ)
environ.clear()
pipe = Popen(". %s; env" % script, stdout=PIPE, shell=True)
data = pipe.communicate()[0]
env = dict((line.split("=", 1) for line in data.splitlines()))
if clean:
# remove unwanted minimal vars
env.pop('LINES', None)
env.pop('COLUMNS', None)
environ = dict(environ_back)
if update:
environ.update(env)
return env
os_auth = source(os_auth_file)
auth = v3.Password(auth_url=os_auth['OS_AUTH_URL'],
username=os_auth['OS_USERNAME'],
password=os_auth['OS_PASSWORD'],
project_domain_name='default',user_domain_name='default',
project_name=os_auth['OS_TENANT_NAME'])
sess = session.Session(auth=auth)
keystone = client.Client(version='v3',session=sess)
users=keystone.users.list()
print users
The addion of version='v3'
to the 'client.Client'
call is not in the
docs but was suggested by Adma Young on IRC and got the code to 'work
for him' but oddly makes no change for me.
That 'source' call parses the same shell script fragment I source to use v3 with python-openstackclient cli. My test case is:
keystone.users.list()
I expect a list of users, I get EndpointNotFound.
Trying to force my way through I created an 'identityv3' service and endpoint then specified
endpoint_filter={'service_type': 'identityv3',
'interface': 'public',
'region_name': 'RegionOne'}
in the session.Session call, which (mis)reading keystoneclient/session.py and http://docs.openstack.org/developer/p... I though t I could put there, but apparently can't ( unexpected keyword argument).
Grasping at straws I moved the endpoint filter to the client.Client call and did not get and unexpected argument error but did still get the EndpointNotFound.
If I make a more direct call (after including the above) I can get a user list...
>>> resp = sess.get('/users', endpoint_filter={'service_type': 'identityv3',
... 'interface': 'public',
... 'region_name': 'RegionOne'})
now resp.content has a list of ...