Dean Troyer 6fb1a4e496 More identity client config
* move auth option checking back to OpenStackShell() to keep the shell-level
  interaction at that level; add checking for token flow options

* make identity.client.make_client() configure keystoneclient.v2_0.Client()
  properly for both password flow and token flow auth

* eliminated ClientManager.init_token(), set _service_catalog in __init__()

* compute client handles token flow

Change-Id: I42481b5424489387798c4ec6d3e2a723ab1e6067
2012-05-10 13:54:58 -05:00

28 lines
801 B
Python

import logging
from keystoneclient.v2_0 import client as identity_client
LOG = logging.getLogger(__name__)
def make_client(instance):
"""Returns an identity service client.
"""
if instance._url:
LOG.debug('instantiating identity client: token flow')
client = identity_client.Client(
endpoint=instance._url,
token=instance._token,
)
else:
LOG.debug('instantiating identity client: password flow')
client = identity_client.Client(
username=instance._username,
password=instance._password,
tenant_name=instance._tenant_name,
tenant_id=instance._tenant_id,
auth_url=instance._auth_url,
region_name=instance._region_name,
)
return client