From f09a9ce4c7b5821a8d84ef43ac8ae012db489156 Mon Sep 17 00:00:00 2001 From: Timur Sufiev Date: Wed, 15 Jun 2016 21:22:08 +0300 Subject: [PATCH] Use the new fix_auth_url_version_prefix() call It is a variation of existing fix_auth_url_version() call which returns as a second value a boolean flag indicating whether the auth_url was fixed to point to /v3 endpoint. So we could display a more clear message to deployers from Horizon, based on the value of this flag. The legacy fix_auth_url_version() call is to be phased out as soon as Horizon cease to depend on it. Also provide a release note about removing the old function. Change-Id: I6c6a35b1c460e22dadf39634fce1bdfa257b8c63 Depends-On: I3a04d838a707465c8c6e81e0e6e2fcf918b7b059 --- openstack_dashboard/api/keystone.py | 10 +++++++++- .../project/access_and_security/api_access/views.py | 3 ++- ...ise-keystone-endpoint-message-03129e37a6377715.yaml | 9 +++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/fix-precise-keystone-endpoint-message-03129e37a6377715.yaml diff --git a/openstack_dashboard/api/keystone.py b/openstack_dashboard/api/keystone.py index 8dc384a53f..eb80da7cec 100644 --- a/openstack_dashboard/api/keystone.py +++ b/openstack_dashboard/api/keystone.py @@ -113,13 +113,21 @@ def _get_endpoint_url(request, endpoint_type, catalog=None): url = base.url_for(request, service_type='identity', endpoint_type=endpoint_type) + message = ("The Keystone URL in service catalog points to a v2.0 " + "Keystone endpoint, but v3 is specified as the API version " + "to use by Horizon. Using v3 endpoint for authentication.") else: auth_url = getattr(settings, 'OPENSTACK_KEYSTONE_URL') url = request.session.get('region_endpoint', auth_url) + message = ("The OPENSTACK_KEYSTONE_URL setting points to a v2.0 " + "Keystone endpoint, but v3 is specified as the API version " + "to use by Horizon. Using v3 endpoint for authentication.") # TODO(gabriel): When the Service Catalog no longer contains API versions # in the endpoints this can be removed. - url = auth_utils.fix_auth_url_version(url) + url, url_fixed = auth_utils.fix_auth_url_version_prefix(url) + if url_fixed: + LOG.warning(message) return url diff --git a/openstack_dashboard/dashboards/project/access_and_security/api_access/views.py b/openstack_dashboard/dashboards/project/access_and_security/api_access/views.py index b499a06bac..212abfbf4c 100644 --- a/openstack_dashboard/dashboards/project/access_and_security/api_access/views.py +++ b/openstack_dashboard/dashboards/project/access_and_security/api_access/views.py @@ -133,7 +133,8 @@ def download_rc_file(request): # make v3 specific changes context['user_domain_name'] = request.user.user_domain_name # sanity fix for removing v2.0 from the url if present - context['auth_url'] = utils.fix_auth_url_version(context['auth_url']) + context['auth_url'], _ = utils.fix_auth_url_version_prefix( + context['auth_url']) context['os_identity_api_version'] = 3 context['os_auth_version'] = 3 return _download_rc_file_for_template(request, context, template) diff --git a/releasenotes/notes/fix-precise-keystone-endpoint-message-03129e37a6377715.yaml b/releasenotes/notes/fix-precise-keystone-endpoint-message-03129e37a6377715.yaml new file mode 100644 index 0000000000..8712e2e625 --- /dev/null +++ b/releasenotes/notes/fix-precise-keystone-endpoint-message-03129e37a6377715.yaml @@ -0,0 +1,9 @@ +--- +deprecations: + - The function fix_auth_url_version() should be removed + from openstack_auth library as soon as Horizon no longer + needs it. The replacement function is fix_auth_url_version_prefix() + which returns a fixed url and a boolean flag indicating + if the url was actually fixed. Having a separate flag + allows to emit more precise warning messages about + inconsistencies in Keystone endpoint URL.