Merge "Remove deprecated SHOW_KEYSTONE_V2_RC config option"

This commit is contained in:
Zuul 2019-05-16 05:56:19 +00:00 committed by Gerrit Code Review
commit 66e50035b0
11 changed files with 7 additions and 169 deletions

View File

@ -921,25 +921,6 @@ menu and the api access panel.
`OPENSTACK_CLOUDS_YAML_CUSTOM_TEMPLATE`_ to provide a custom
``clouds.yaml``.
SHOW_KEYSTONE_V2_RC
--------------------
.. versionadded:: 13.0.0(Queens)
.. versionchanged:: 15.0.0(Stein)
The default value is changed from ``True`` to ``False``
in favor of the deprecation of keystone v2 API support in horizon.
.. deprecated:: 15.0.0(Stein)
This option will be dropped in 16.0.0(Train) release.
Default: ``False``
Controls whether the keystone v2 openrc file is accessible from the user
menu and the api access panel.
THEME_COLLECTION_DIR
--------------------
@ -967,7 +948,7 @@ USER_MENU_LINKS
.. versionadded:: 13.0.0(Queens)
Default (when ``SHOW_KEYSTONE_V2_RC`` is ``False``):
Default:
.. code-block:: python
@ -979,23 +960,6 @@ Default (when ``SHOW_KEYSTONE_V2_RC`` is ``False``):
}
]
Default (when ``SHOW_KEYSTONE_V2_RC`` is ``True``):
.. code-block:: python
[
{'name': _('OpenStack RC File v2'),
'icon_classes': ['fa-download', ],
'url': 'horizon:project:api_access:openrcv2',
'external': False,
},
{'name': _('OpenStack RC File v3'),
'icon_classes': ['fa-download', ],
'url': 'horizon:project:api_access:openrc',
'external': False,
}
]
This setting controls the additional links on the user drop down menu.
A list of dictionaries defining all of the links should be provided. This
defaults to the standard OpenStack RC files.

View File

@ -88,11 +88,6 @@ def openstack(request):
user_menu_links = getattr(settings, "USER_MENU_LINKS", [])
if not getattr(settings, "SHOW_KEYSTONE_V2_RC", False):
user_menu_links = [
link for link in user_menu_links
if link['url'] != 'horizon:project:api_access:openrcv2']
context['USER_MENU_LINKS'] = user_menu_links
# Adding profiler support flag

View File

@ -62,30 +62,11 @@ class DownloadOpenRC(tables.LinkAction):
icon = "download"
url = "horizon:project:api_access:openrc"
def __init__(self, attrs=None, **kwargs):
super(DownloadOpenRC, self).__init__(attrs, **kwargs)
# When keystone v2 RC file is enabled, we need to show
# the version information of keystone API.
# Note that we don't need to care verbose_name_plural here.
if getattr(settings, 'SHOW_KEYSTONE_V2_RC', False):
self.verbose_name = _("OpenStack RC File (Identity API v3)")
def allowed(self, request, datum=None):
return (settings.SHOW_OPENRC_FILE and
utils.get_keystone_version() >= 3)
class DownloadOpenRCv2(tables.LinkAction):
name = "download_openrc_v2"
verbose_name = _("OpenStack RC File (Identity API v2.0)")
verbose_name_plural = _("OpenStack RC File (Identity API v2.0)")
icon = "download"
url = "horizon:project:api_access:openrcv2"
def allowed(self, request, datum=None):
return settings.SHOW_KEYSTONE_V2_RC
class ViewCredentials(tables.LinkAction):
name = "view_credentials"
verbose_name = _("View Credentials")
@ -130,7 +111,6 @@ class EndpointsTable(tables.DataTable):
multi_select = False
table_actions = (ViewCredentials, RecreateCredentials)
table_actions_menu = (DownloadCloudsYaml,
DownloadOpenRCv2,
DownloadOpenRC,
DownloadEC2)
table_actions_menu_label = _('Download OpenStack RC File')

View File

@ -1,43 +0,0 @@
{% load shellfilter %}#!/usr/bin/env bash
# To use an OpenStack cloud you need to authenticate against the Identity
# service named keystone, which returns a **Token** and **Service Catalog**.
# The catalog contains the endpoints for all services the user/tenant has
# access to - such as Compute, Image Service, Identity, Object Storage, Block
# Storage, and Networking (code-named nova, glance, keystone, swift,
# cinder, and neutron).
#
# *NOTE*: Using the 2.0 *Identity API* does not necessarily mean any other
# OpenStack API is version 2.0. For example, your cloud provider may implement
# Image API v1.1, Block Storage API v2, and Compute API v2.0. OS_AUTH_URL is
# only for the Identity API served through keystone.
export OS_AUTH_URL={{ auth_url }}
# With the addition of Keystone we have standardized on the term **tenant**
# as the entity that owns the resources.
export OS_TENANT_ID={{ tenant_id }}
export OS_TENANT_NAME="{{ tenant_name|shellfilter }}"
# unsetting v3 items in case set
unset OS_PROJECT_ID
unset OS_PROJECT_NAME
unset OS_USER_DOMAIN_NAME
unset OS_INTERFACE
# In addition to the owning entity (tenant), OpenStack stores the entity
# performing the action as the **user**.
export OS_USERNAME="{{ user.username|shellfilter }}"
# With Keystone you pass the keystone password.
echo "Please enter your OpenStack Password for project $OS_TENANT_NAME as user $OS_USERNAME: "
read -sr OS_PASSWORD_INPUT
export OS_PASSWORD=$OS_PASSWORD_INPUT
# If your configuration has multiple regions, we set that information here.
# OS_REGION_NAME is optional and only valid in certain environments.
export OS_REGION_NAME="{{ region|shellfilter }}"
# Don't leave a blank variable, unset it if it was empty
if [ -z "$OS_REGION_NAME" ]; then unset OS_REGION_NAME; fi
export OS_ENDPOINT_TYPE={{ os_endpoint_type }}
export OS_IDENTITY_API_VERSION={{ os_identity_api_version }}

View File

@ -28,7 +28,6 @@ INDEX_URL = reverse('horizon:project:api_access:index')
API_URL = "horizon:project:api_access"
EC2_URL = reverse(API_URL + ":ec2")
OPENRC_URL = reverse(API_URL + ":openrc")
OPENRCV2_URL = reverse(API_URL + ":openrcv2")
CREDS_URL = reverse(API_URL + ":view_credentials")
RECREATE_CREDS_URL = reverse(API_URL + ":recreate_credentials")
@ -50,20 +49,6 @@ class APIAccessTests(test.TestCase):
self.mock_create_ec2_credentials.assert_called_once_with(
test.IsHttpRequest(), self.user.id, self.tenant.id)
def test_openrcv2_credentials(self):
res = self.client.get(OPENRCV2_URL)
self.assertEqual(res.status_code, 200)
openrc = 'project/api_access/openrc_v2.sh.template'
self.assertTemplateUsed(res, openrc)
name = 'export OS_USERNAME="{}"'.format(self.request.user.username)
t_id = 'export OS_TENANT_ID={}'.format(self.request.user.tenant_id)
domain = 'export OS_USER_DOMAIN_NAME="{}"'.format(
self.request.user.user_domain_name)
self.assertIn(name.encode('utf-8'), res.content)
self.assertIn(t_id.encode('utf-8'), res.content)
# domain content should not be present for v2
self.assertNotIn(domain.encode('utf-8'), res.content)
@override_settings(OPENSTACK_API_VERSIONS={"identity": 3})
def test_openrc_credentials(self):
res = self.client.get(OPENRC_URL)
@ -139,13 +124,6 @@ class ASCIITenantNameRCTests(test.TestCase):
super(ASCIITenantNameRCTests, self)._setup_user(
tenant_name=self.TENANT_NAME)
def test_openrcv2_credentials_filename(self):
expected = 'attachment; filename="%s-openrc.sh"' % self.TENANT_NAME
res = self.client.get(OPENRCV2_URL)
self.assertEqual(res.status_code, 200)
self.assertEqual(expected, res['content-disposition'])
@override_settings(OPENSTACK_API_VERSIONS={"identity": 3})
def test_openrc_credentials_filename(self):
expected = 'attachment; filename="%s-openrc.sh"' % self.TENANT_NAME
@ -162,24 +140,6 @@ class UnicodeTenantNameRCTests(test.TestCase):
super(UnicodeTenantNameRCTests, self)._setup_user(
tenant_name=self.TENANT_NAME)
def test_openrcv2_credentials_filename(self):
expected = ('attachment; filename="%s-openrc.sh"' %
self.TENANT_NAME).encode('utf-8')
res = self.client.get(OPENRCV2_URL)
self.assertEqual(res.status_code, 200)
result_content_disposition = res['content-disposition']
# we need to encode('latin-1') because django response object
# has custom setter which encodes all values to latin-1 for Python3.
# https://github.com/django/django/blob/1.9.6/django/http/response.py#L142
# see _convert_to_charset() method for details.
if six.PY3:
result_content_disposition = result_content_disposition.\
encode('latin-1')
self.assertEqual(expected,
result_content_disposition)
@override_settings(OPENSTACK_API_VERSIONS={"identity": 3})
def test_openrc_credentials_filename(self):
expected = ('attachment; filename="%s-openrc.sh"' %

View File

@ -26,7 +26,6 @@ urlpatterns = [
url(r'^clouds.yaml/$',
views.download_clouds_yaml_file, name='clouds.yaml'),
url(r'^openrc/$', views.download_rc_file, name='openrc'),
url(r'^openrcv2/$', views.download_rc_file_v2, name='openrcv2'),
url(r'^view_credentials/$', views.CredentialsView.as_view(),
name='view_credentials'),
url(r'^recreate_ec2_credentials/$',

View File

@ -118,14 +118,6 @@ def download_ec2_bundle(request):
return response
def download_rc_file_v2(request):
template = 'project/api_access/openrc_v2.sh.template'
context = _get_openrc_credentials(request)
context['os_identity_api_version'] = 2
context['os_auth_version'] = 2
return _download_rc_file_for_template(request, context, template)
def download_rc_file(request):
template = getattr(settings, 'OPENRC_CUSTOM_TEMPLATE',
'project/api_access/openrc.sh.template')

View File

@ -108,11 +108,6 @@ WEBROOT = '/'
# or None. Set to None explicitly if you want to deactivate the console.
#CONSOLE_TYPE = "AUTO"
# Toggle showing the openrc file for Keystone V2.
# If set to false the link will be removed from the user dropdown menu
# 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

View File

@ -132,7 +132,7 @@ def check_invalid_settings(dummy=None):
'SESSION_EXPIRE_AT_BROWSER_CLOSE', 'SESSION_FILE_PATH',
'SESSION_REFRESH', 'SESSION_SAVE_EVERY_REQUEST', 'SESSION_SERIALIZER',
'SESSION_TIMEOUT', 'SETTINGS_MODULE', 'SHORT_DATETIME_FORMAT',
'SHORT_DATE_FORMAT', 'SHOW_KEYSTONE_V2_RC', 'SHOW_OPENRC_FILE',
'SHORT_DATE_FORMAT', 'SHOW_OPENRC_FILE',
'SHOW_OPENSTACK_CLOUDS_YAML', 'SIGNING_BACKEND',
'SILENCED_SYSTEM_CHECKS', 'SITE_BRANDING', 'SITE_BRANDING_LINK',
'STATICFILES_DIRS', 'STATICFILES_FINDERS', 'STATICFILES_STORAGE',

View File

@ -349,7 +349,6 @@ 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
@ -430,16 +429,9 @@ OPENSTACK_IMAGE_FORMATS = [fmt for (fmt, name)
if USER_MENU_LINKS is None:
USER_MENU_LINKS = []
if SHOW_KEYSTONE_V2_RC:
USER_MENU_LINKS.append({
'name': _('OpenStack RC File v2'),
'icon_classes': ['fa-download', ],
'url': 'horizon:project:api_access:openrcv2',
})
if SHOW_OPENRC_FILE:
USER_MENU_LINKS.append({
'name': (_('OpenStack RC File v3') if SHOW_KEYSTONE_V2_RC
else _('OpenStack RC File')),
'name': _('OpenStack RC File'),
'icon_classes': ['fa-download', ],
'url': 'horizon:project:api_access:openrc',
})

View File

@ -0,0 +1,4 @@
---
upgrade:
- |
Deprecated ``SHOW_KEYSTONE_V2_RC`` since Stein release is removed.