From c6baf007341aab17035bb5e77a6ab8143b069cd4 Mon Sep 17 00:00:00 2001 From: Akihiro Motoki Date: Sun, 23 Dec 2018 04:13:07 +0900 Subject: [PATCH] Allow to hide openrc and clouds.yaml download links Operators now can control whether the links of "Download OpenRC" and "Download clouds.yaml" are displayed or not via new settings SHOW_OPENRC_FILE and SHOW_OPENSTACK_CLOUDS_YAML. openrc and clouds.yaml files provided by horizon now assume the basic simple deployment and do not cover keystone authentication like saml2, openid and so on. The default openrc and clouds.yaml from horizon do not make sense for such environments. Change-Id: I1407a24387c7d7bd2c20c995cebf1350f8090e72 Partial-Bug: #1795851 --- doc/source/configuration/settings.rst | 19 +++++++++++++++++++ .../dashboards/project/api_access/tables.py | 6 +++++- .../local/local_settings.py.example | 8 ++++++++ openstack_dashboard/settings.py | 15 +++++++++------ ...nrc-clouds-yaml-link-f1642b77e25f08ba.yaml | 10 ++++++++++ 5 files changed, 51 insertions(+), 7 deletions(-) create mode 100644 releasenotes/notes/openrc-clouds-yaml-link-f1642b77e25f08ba.yaml diff --git a/doc/source/configuration/settings.rst b/doc/source/configuration/settings.rst index cb0c85b885..66c7e02b3e 100644 --- a/doc/source/configuration/settings.rst +++ b/doc/source/configuration/settings.rst @@ -820,6 +820,25 @@ MEMOIZED_MAX_SIZE_DEFAULT allows setting a global default to help control memory usage when caching. It should at least be 2 x the number of threads with a little bit of extra buffer. +SHOW_OPENRC_FILE +---------------- + +.. versionadded:: 15.0.0(Stein) + +Default:: ``True`` + +Controls whether the keystone openrc file is accesible from the user +menu and the api access panel. + +SHOW_OPENSTACK_CLOUDS_YAML +-------------------------- + +.. versionadded:: 15.0.0(Stein) + +Default:: ``True`` + +Controls whether clouds.yaml is accesible from the user +menu and the api access panel. SHOW_KEYSTONE_V2_RC -------------------- diff --git a/openstack_dashboard/dashboards/project/api_access/tables.py b/openstack_dashboard/dashboards/project/api_access/tables.py index 9788047b3d..9f4bc40c26 100644 --- a/openstack_dashboard/dashboards/project/api_access/tables.py +++ b/openstack_dashboard/dashboards/project/api_access/tables.py @@ -51,6 +51,9 @@ class DownloadCloudsYaml(tables.LinkAction): icon = "download" url = "horizon:project:api_access:clouds.yaml" + def allowed(self, request, datum=None): + return settings.SHOW_OPENSTACK_CLOUDS_YAML + class DownloadOpenRC(tables.LinkAction): name = "download_openrc" @@ -68,7 +71,8 @@ class DownloadOpenRC(tables.LinkAction): self.verbose_name = _("OpenStack RC File (Identity API v3)") def allowed(self, request, datum=None): - return utils.get_keystone_version() >= 3 + return (settings.SHOW_OPENRC_FILE and + utils.get_keystone_version() >= 3) class DownloadOpenRCv2(tables.LinkAction): diff --git a/openstack_dashboard/local/local_settings.py.example b/openstack_dashboard/local/local_settings.py.example index eb757d7a07..5bc6c243e8 100644 --- a/openstack_dashboard/local/local_settings.py.example +++ b/openstack_dashboard/local/local_settings.py.example @@ -114,6 +114,14 @@ WEBROOT = '/' # and the API Access page #SHOW_KEYSTONE_V2_RC = False +# Controls whether the keystone openrc file is accesible from the user +# menu and the api access panel. +SHOW_OPENRC_FILE = True + +# Controls whether clouds.yaml is accesible from the user +# menu and the api access panel. +SHOW_OPENSTACK_CLOUDS_YAML = True + # If provided, a "Report Bug" link will be displayed in the site header # which links to the value of this setting (ideally a URL containing # information on how to report issues). diff --git a/openstack_dashboard/settings.py b/openstack_dashboard/settings.py index 18aae0e97f..1b26aa7b02 100644 --- a/openstack_dashboard/settings.py +++ b/openstack_dashboard/settings.py @@ -340,6 +340,8 @@ CSRF_COOKIE_AGE = None COMPRESS_OFFLINE_CONTEXT = 'horizon.themes.offline_context' SHOW_KEYSTONE_V2_RC = False +SHOW_OPENRC_FILE = True +SHOW_OPENSTACK_CLOUDS_YAML = True # Dictionary of currently available angular features ANGULAR_FEATURES = { @@ -421,12 +423,13 @@ if USER_MENU_LINKS is None: 'icon_classes': ['fa-download', ], 'url': 'horizon:project:api_access:openrcv2', }) - USER_MENU_LINKS.append({ - 'name': (_('OpenStack RC File v3') if SHOW_KEYSTONE_V2_RC - else _('OpenStack RC File')), - 'icon_classes': ['fa-download', ], - 'url': 'horizon:project:api_access:openrc', - }) + if SHOW_OPENRC_FILE: + USER_MENU_LINKS.append({ + 'name': (_('OpenStack RC File v3') if SHOW_KEYSTONE_V2_RC + else _('OpenStack RC File')), + 'icon_classes': ['fa-download', ], + 'url': 'horizon:project:api_access:openrc', + }) if not WEBROOT.endswith('/'): WEBROOT += '/' diff --git a/releasenotes/notes/openrc-clouds-yaml-link-f1642b77e25f08ba.yaml b/releasenotes/notes/openrc-clouds-yaml-link-f1642b77e25f08ba.yaml new file mode 100644 index 0000000000..bd03223f26 --- /dev/null +++ b/releasenotes/notes/openrc-clouds-yaml-link-f1642b77e25f08ba.yaml @@ -0,0 +1,10 @@ +--- +features: + - | + [:bug:`1795851`] Operators now can control whether the links of + "Download OpenRC" and "Download clouds.yaml" are displayed or not + via new settings ``SHOW_OPENRC_FILE`` and ``SHOW_OPENSTACK_CLOUDS_YAML``. + ``openrc`` and ``clouds.yaml`` files provided by horizon now assume + the basic simple deployment and do not cover keystone authentication + like saml2, openid and so on. The default ``openrc`` and ``clouds.yaml`` + from horizon do not make sense for such environments.