Created
April 20, 2015 22:00
-
-
Save the2hill/6fb8ff1d06905d98d0bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from keystoneclient import session | |
from keystoneclient.v2_0 import client as v2_client | |
from keystoneclient.v3 import client as v3_client | |
global _SESSION | |
if not _SESSION: | |
if cfg.CONF.keystone_authtoken.auth_version == '2': | |
client = v2_client | |
elif cfg.CONF.keystone_authtoken.auth_version == '3': | |
client = v3_client | |
else: | |
raise Exception('Unknown keystone version!') | |
try: | |
kc = client.Client( | |
auth_url=cfg.CONF.keystone_authtoken.auth_uri, | |
username=cfg.CONF.keystone_authtoken.admin_user, | |
password=cfg.CONF.keystone_authtoken.admin_password, | |
tenant_name=cfg.CONF.keystone_authtoken.admin_tenant_name | |
) | |
_SESSION = session.Session(auth=kc) | |
except Exception: | |
with excutils.save_and_reraise_exception(): | |
LOG.exception(_LE("Error creating Keystone session.")) | |
return client.Client(session=_SESSION) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment