From 5d34774f0a1dba05dbb2878acfb4dabef296147d Mon Sep 17 00:00:00 2001 From: Adrian Turjak Date: Wed, 19 Feb 2020 15:26:18 +1300 Subject: [PATCH] Change Adjutant UI to use the correct service type Keep a fallback to the old one to ease migrations. Change-Id: Ic7e1e554a3c4197a09fe52f01fadcc10ccb534cc --- adjutant_ui/api/adjutant.py | 11 +++++++++-- doc/source/configuration.rst | 6 +++--- doc/source/installation.rst | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/adjutant_ui/api/adjutant.py b/adjutant_ui/api/adjutant.py index de03289..863de56 100644 --- a/adjutant_ui/api/adjutant.py +++ b/adjutant_ui/api/adjutant.py @@ -21,6 +21,7 @@ from urllib.parse import urljoin from django.conf import settings from django.utils.translation import ugettext_lazy as _ +from horizon import exceptions from horizon.utils import functions as utils from horizon.utils import memoized @@ -159,9 +160,15 @@ def _get_endpoint_url(request): # If the request is made by an anonymous user, this endpoint request fails. # Thus, we must hardcode this in Horizon. if getattr(request.user, "service_catalog", None): - url = base.url_for(request, service_type='registration') + try: + url = base.url_for(request, service_type='admin-logic') + except exceptions.ServiceCatalogException: + url = base.url_for(request, service_type='registration') else: - url = getattr(settings, 'OPENSTACK_REGISTRATION_URL') + try: + url = getattr(settings, 'OPENSTACK_ADJUTANT_URL') + except AttributeError: + url = getattr(settings, 'OPENSTACK_REGISTRATION_URL') # Ensure ends in slash if not url.endswith('/'): diff --git a/doc/source/configuration.rst b/doc/source/configuration.rst index 5db267d..c413b2f 100644 --- a/doc/source/configuration.rst +++ b/doc/source/configuration.rst @@ -1,14 +1,14 @@ Configuring Adjutant-UI ======================= -Adjutant-ui relies solely on the ``OPENSTACK_REGISTRATION_URL`` setting, as -much like Keystone's url, this is needed before the user is authenticated and a +Adjutant-ui relies on the ``OPENSTACK_ADJUTANT_URL`` setting, as much +like Keystone's url, this is needed before the user is authenticated and a valid catalog has been returned. This url is used for the password reset functionality, and signup if that panel is turned on. .. code-block:: python - OPENSTACK_REGISTRATION_URL = "http://127.0.0.1:5050/v1" + OPENSTACK_ADJUTANT_URL = "http://127.0.0.1:5050/v1" Beyond that all the other settings are optional, with reasonably sensible diff --git a/doc/source/installation.rst b/doc/source/installation.rst index 8cf0e5b..58ffc83 100644 --- a/doc/source/installation.rst +++ b/doc/source/installation.rst @@ -19,7 +19,7 @@ Open up the copied ``local_settings.py`` file in your preferred text editor. You will want to customize several settings: - Verify that the ``OPENSTACK_KEYSTONE_URL`` is correct for your environment. -- ``OPENSTACK_REGISTRATION_URL`` should also be configured to point to your +- ``OPENSTACK_ADJUTANT_URL`` should also be configured to point to your Adjutant server and version. You will also need to update the ``keystone_policy.json`` file in horizon with