
* 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
41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
import logging
|
|
|
|
from novaclient import client as nova_client
|
|
|
|
LOG = logging.getLogger(__name__)
|
|
|
|
|
|
def make_client(instance):
|
|
"""Returns a compute service client.
|
|
"""
|
|
LOG.debug('instantiating compute client')
|
|
client = nova_client.Client(
|
|
version=instance._compute_api_version,
|
|
username=instance._username,
|
|
api_key=instance._password,
|
|
project_id=instance._tenant_name,
|
|
auth_url=instance._auth_url,
|
|
# FIXME(dhellmann): add constructor argument for this
|
|
insecure=False,
|
|
region_name=instance._region_name,
|
|
# FIXME(dhellmann): get endpoint_type from option?
|
|
endpoint_type='publicURL',
|
|
# FIXME(dhellmann): add extension discovery
|
|
extensions=[],
|
|
service_type='compute',
|
|
# FIXME(dhellmann): what is service_name?
|
|
service_name='',
|
|
)
|
|
|
|
# Populate the Nova client to skip another auth query to Identity
|
|
if instance._url:
|
|
# token flow
|
|
client.client.management_url = instance._url
|
|
else:
|
|
# password flow
|
|
client.client.management_url = instance.get_endpoint_for_service_type(
|
|
'compute')
|
|
client.client.service_catalog = instance._service_catalog
|
|
client.client.auth_token = instance._token
|
|
return client
|