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,
|
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):
|
admin=False):
|
||||||
"""Returns a client connected to the Keystone backend.
|
"""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():
|
if not user.is_admin():
|
||||||
raise exceptions.NotAuthorized
|
raise exceptions.NotAuthorized
|
||||||
endpoint_type = 'adminURL'
|
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.
|
# Take care of client connection caching/fetching a new client.
|
||||||
# Admin vs. non-admin clients are cached separately for token matching.
|
# 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)
|
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,
|
c = keystoneclient(request,
|
||||||
token_id=token,
|
token_id=token,
|
||||||
endpoint=_get_endpoint_url(request, endpoint_type),
|
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',
|
c.management_url = c.service_catalog.url_for(service_type='identity',
|
||||||
endpoint_type='adminURL')
|
endpoint_type='adminURL')
|
||||||
else:
|
else:
|
||||||
c.management_url = c.service_catalog.url_for(service_type='identity',
|
endpoint_type = getattr(settings,
|
||||||
endpoint_type='internalURL')
|
'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)
|
scoped_token = tokens.Token(tokens.TokenManager, raw_token)
|
||||||
return scoped_token
|
return scoped_token
|
||||||
|
|
||||||
|
@ -57,6 +57,11 @@ OPENSTACK_KEYSTONE_BACKEND = {
|
|||||||
'can_edit_user': True
|
'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
|
# The number of Swift containers and objects to display on a single page before
|
||||||
# providing a paging element (a "more" link) to paginate results.
|
# providing a paging element (a "more" link) to paginate results.
|
||||||
API_RESULT_LIMIT = 1000
|
API_RESULT_LIMIT = 1000
|
||||||
|
Loading…
x
Reference in New Issue
Block a user