Can now specify endpoint type via setting.
Fixes bug 969725 Change-Id: Ifd3179f5e76ba316fdeda31140cea4c47a780c60
This commit is contained in:
parent
ef371d7610
commit
a0805e35a5
@ -70,7 +70,7 @@ def _get_endpoint_url(request, endpoint_type, catalog=None):
|
||||
|
||||
|
||||
def keystoneclient(request, username=None, password=None, tenant_id=None,
|
||||
token_id=None, endpoint=None, endpoint_type='internalURL',
|
||||
token_id=None, endpoint=None, endpoint_type=None,
|
||||
admin=False):
|
||||
"""Returns a client connected to the Keystone backend.
|
||||
|
||||
@ -98,6 +98,10 @@ def keystoneclient(request, username=None, password=None, tenant_id=None,
|
||||
if not user.is_admin():
|
||||
raise exceptions.NotAuthorized
|
||||
endpoint_type = 'adminURL'
|
||||
else:
|
||||
endpoint_type = endpoint_type or getattr(settings,
|
||||
'OPENSTACK_ENDPOINT_TYPE',
|
||||
'internalURL')
|
||||
|
||||
# Take care of client connection caching/fetching a new client.
|
||||
# Admin vs. non-admin clients are cached separately for token matching.
|
||||
@ -157,7 +161,10 @@ def tenant_update(request, tenant_id, tenant_name, description, enabled):
|
||||
enabled)
|
||||
|
||||
|
||||
def tenant_list_for_token(request, token, endpoint_type='internalURL'):
|
||||
def tenant_list_for_token(request, token, endpoint_type=None):
|
||||
endpoint_type = endpoint_type or getattr(settings,
|
||||
'OPENSTACK_ENDPOINT_TYPE',
|
||||
'internalURL')
|
||||
c = keystoneclient(request,
|
||||
token_id=token,
|
||||
endpoint=_get_endpoint_url(request, endpoint_type),
|
||||
@ -202,8 +209,11 @@ def token_create_scoped(request, tenant, token):
|
||||
c.management_url = c.service_catalog.url_for(service_type='identity',
|
||||
endpoint_type='adminURL')
|
||||
else:
|
||||
c.management_url = c.service_catalog.url_for(service_type='identity',
|
||||
endpoint_type='internalURL')
|
||||
endpoint_type = getattr(settings,
|
||||
'OPENSTACK_ENDPOINT_TYPE',
|
||||
'internalURL')
|
||||
c.management_url = c.service_catalog.url_for(
|
||||
service_type='identity', endpoint_type=endpoint_type)
|
||||
scoped_token = tokens.Token(tokens.TokenManager, raw_token)
|
||||
return scoped_token
|
||||
|
||||
|
@ -57,6 +57,11 @@ OPENSTACK_KEYSTONE_BACKEND = {
|
||||
'can_edit_user': True
|
||||
}
|
||||
|
||||
# OPENSTACK_ENDPOINT_TYPE specifies the endpoint type to use for the endpoints
|
||||
# in the Keystone service catalog. Use this setting when Horizon is running
|
||||
# external to the OpenStack environment. The default is 'internalURL'.
|
||||
#OPENSTACK_ENDPOINT_TYPE = "publicURL"
|
||||
|
||||
# The number of Swift containers and objects to display on a single page before
|
||||
# providing a paging element (a "more" link) to paginate results.
|
||||
API_RESULT_LIMIT = 1000
|
||||
|
Loading…
Reference in New Issue
Block a user