Allow to specify custom templates for clouds.yaml and openrc
Change-Id: I1ef6899f4d14c660eba50f16e813c280657475fc Closes-Bug: #1795851
This commit is contained in:
parent
c6baf00734
commit
e832c8549b
@ -505,6 +505,34 @@ OpenStack dashboard to use a specific API version for a given service API.
|
||||
"compute": 2
|
||||
}
|
||||
|
||||
OPENSTACK_CLOUDS_YAML_CUSTOM_TEMPLATE
|
||||
-------------------------------------
|
||||
|
||||
.. versionadded:: 15.0.0(Stein)
|
||||
|
||||
Default: ``None``
|
||||
|
||||
Example:: ``my-clouds.yaml.template``
|
||||
|
||||
A template name for a custom user's ``clouds.yaml`` file.
|
||||
``None`` means the default template for ``clouds.yaml`` is used.
|
||||
|
||||
If the default template is not suitable for your deployment,
|
||||
you can provide your own clouds.yaml by specifying this setting.
|
||||
|
||||
The default template is defined as `clouds.yaml.template
|
||||
<http://git.openstack.org/cgit/openstack/horizon/tree/openstack_dashboard/dashboards/project/api_access/templates/api_access/clouds.yaml.template>`__
|
||||
and available context parameters are found in ``_get_openrc_credentials()``
|
||||
and ``download_clouds_yaml_file()`` functions in
|
||||
`openstack_dashboard/dashboards/project/api_access/views.py
|
||||
<http://git.openstack.org/cgit/openstack/horizon/tree/openstack_dashboard/dashboards/project/api_access/views.py>`__.
|
||||
|
||||
.. note::
|
||||
|
||||
Your template needs to be placed in the search paths of Django templates.
|
||||
You may need to configure `ADD_TEMPLATE_DIRS`_ setting
|
||||
to contain a path where your template exists.
|
||||
|
||||
OPENSTACK_CLOUDS_YAML_NAME
|
||||
--------------------------
|
||||
|
||||
@ -552,6 +580,37 @@ basic deployment.
|
||||
If you have multiple regions you should use the `AVAILABLE_REGIONS`_ setting
|
||||
instead.
|
||||
|
||||
OPENRC_CUSTOM_TEMPLATE
|
||||
----------------------
|
||||
|
||||
.. versionadded:: 15.0.0(Stein)
|
||||
|
||||
Default: ``None``
|
||||
|
||||
Example:: ``my-openrc.sh.template``
|
||||
|
||||
A template name for a custom user's ``openrc`` file.
|
||||
``None`` means the default template for ``openrc`` is used.
|
||||
|
||||
If the default template is not suitable for your deployment,
|
||||
for example, if your deployment uses saml2, openid and so on
|
||||
for authentication, the default ``openrc`` would not be sufficient.
|
||||
You can provide your own clouds.yaml by specifying this setting.
|
||||
|
||||
The default template is defined as `openrc.sh.template
|
||||
<http://git.openstack.org/cgit/openstack/horizon/tree/openstack_dashboard/dashboards/project/api_access/templates/api_access/openrc.sh.template>`__
|
||||
and available context parameters are found in ``_get_openrc_credentials()``
|
||||
and ``download_rc_file()`` functions in
|
||||
`openstack_dashboard/dashboards/project/api_access/views.py
|
||||
<http://git.openstack.org/cgit/openstack/horizon/tree/openstack_dashboard/dashboards/project/api_access/views.py>`__.
|
||||
|
||||
.. note::
|
||||
|
||||
Your template needs to be placed in the search paths of Django templates.
|
||||
Check ``TEMPLATES[0]['DIRS']``.
|
||||
You may need to specify somewhere your template exist
|
||||
to ``DIRS`` in ``TEMPLATES`` setting.
|
||||
|
||||
OPENSTACK_PROFILER
|
||||
------------------
|
||||
|
||||
@ -830,6 +889,10 @@ Default:: ``True``
|
||||
Controls whether the keystone openrc file is accesible from the user
|
||||
menu and the api access panel.
|
||||
|
||||
.. seealso::
|
||||
|
||||
`OPENRC_CUSTOM_TEMPLATE`_ to provide a custom ``openrc``.
|
||||
|
||||
SHOW_OPENSTACK_CLOUDS_YAML
|
||||
--------------------------
|
||||
|
||||
@ -840,6 +903,11 @@ Default:: ``True``
|
||||
Controls whether clouds.yaml is accesible from the user
|
||||
menu and the api access panel.
|
||||
|
||||
.. seealso::
|
||||
|
||||
`OPENSTACK_CLOUDS_YAML_CUSTOM_TEMPLATE`_ to provide a custom
|
||||
``clouds.yaml``.
|
||||
|
||||
SHOW_KEYSTONE_V2_RC
|
||||
--------------------
|
||||
|
||||
@ -2431,6 +2499,15 @@ Horizon's usage of the ``TEMPLATES`` involves 3 further settings below;
|
||||
it is generally advised to use those before attempting to alter the
|
||||
``TEMPLATES`` setting itself.
|
||||
|
||||
ADD_TEMPLATE_DIRS
|
||||
-----------------
|
||||
|
||||
.. versionadded:: 15.0.0(Stein)
|
||||
|
||||
Template directories defined here will be added to ``DIRS`` option
|
||||
of Django ``TEMPLATES`` setting. It is useful when you would like to
|
||||
load deployment-specific templates.
|
||||
|
||||
ADD_TEMPLATE_LOADERS
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
@ -75,14 +75,15 @@ def _get_openrc_credentials(request):
|
||||
keystone_url = api.base.url_for(request,
|
||||
'identity',
|
||||
endpoint_type='publicURL')
|
||||
credentials = dict(tenant_id=request.user.tenant_id,
|
||||
tenant_name=request.user.tenant_name,
|
||||
auth_url=keystone_url,
|
||||
user=request.user,
|
||||
interface='public',
|
||||
os_endpoint_type='publicURL',
|
||||
region=getattr(request.user, 'services_region') or "")
|
||||
return credentials
|
||||
return {
|
||||
'tenant_id': request.user.tenant_id,
|
||||
'tenant_name': request.user.tenant_name,
|
||||
'auth_url': keystone_url,
|
||||
'user': request.user,
|
||||
'interface': 'public',
|
||||
'os_endpoint_type': 'publicURL',
|
||||
'region': getattr(request.user, 'services_region') or "",
|
||||
}
|
||||
|
||||
|
||||
def download_ec2_bundle(request):
|
||||
@ -126,9 +127,10 @@ def download_rc_file_v2(request):
|
||||
|
||||
|
||||
def download_rc_file(request):
|
||||
template = 'project/api_access/openrc.sh.template'
|
||||
context = _get_openrc_credentials(request)
|
||||
template = getattr(settings, 'OPENRC_CUSTOM_TEMPLATE',
|
||||
'project/api_access/openrc.sh.template')
|
||||
|
||||
context = _get_openrc_credentials(request)
|
||||
# make v3 specific changes
|
||||
context['user_domain_name'] = request.user.user_domain_name
|
||||
try:
|
||||
@ -145,7 +147,9 @@ def download_rc_file(request):
|
||||
|
||||
|
||||
def download_clouds_yaml_file(request):
|
||||
template = 'project/api_access/clouds.yaml.template'
|
||||
template = getattr(settings, 'OPENSTACK_CLOUDS_YAML_CUSTOM_TEMPLATE',
|
||||
'project/api_access/clouds.yaml.template')
|
||||
|
||||
context = _get_openrc_credentials(request)
|
||||
context['cloud_name'] = getattr(
|
||||
settings, "OPENSTACK_CLOUDS_YAML_NAME", 'openstack')
|
||||
|
@ -135,6 +135,7 @@ CACHED_TEMPLATE_LOADERS = [
|
||||
]
|
||||
|
||||
ADD_TEMPLATE_LOADERS = []
|
||||
ADD_TEMPLATE_DIRS = []
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
@ -382,6 +383,8 @@ except ImportError:
|
||||
if not TEMPLATES[0]['DIRS']:
|
||||
TEMPLATES[0]['DIRS'] = [os.path.join(ROOT_PATH, 'templates')]
|
||||
|
||||
TEMPLATES[0]['DIRS'] += ADD_TEMPLATE_DIRS
|
||||
|
||||
# configure template debugging
|
||||
TEMPLATES[0]['OPTIONS']['debug'] = DEBUG
|
||||
|
||||
|
@ -8,3 +8,11 @@ features:
|
||||
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.
|
||||
|
||||
Custom templates for ``clouds.yaml`` and ``openrc`` files can be
|
||||
configured now via ``OPENSTACK_CLOUDS_YAML_CUSTOM_TEMPLATE`` and
|
||||
``OPENRC_CUSTOM_TEMPLATE`` settings. For more detail, see the
|
||||
`Settings Reference <https://docs.openstack.org/horizon/latest/configuration/settings.html>`__.
|
||||
|
||||
``ADD_TEMPLATE_DIRS`` setting is also added so that operators can place
|
||||
custom templates for ``clouds.yaml`` at deployment-specific paths.
|
||||
|
Loading…
Reference in New Issue
Block a user