Added customization-module option to Horizon config

Horizon has a global override mechanism available to perform
customizations. This change adds customization_module key
to HORIZON_CONFIG dictionary in local_settings.py. The
corresponding template file is also modified to configure the
parameter. Spec tests are added to test the configuration.

Change-Id: Id204b60b2676f49713fb6ce7eede6200221f7163
Closes-Bug: #1722653
This commit is contained in:
Lokesh Jain 2017-10-10 17:34:07 -04:00
parent f583d96659
commit 5657428cab
5 changed files with 89 additions and 0 deletions

View File

@ -388,6 +388,17 @@
# (optional) Enable the password field while launching a Heat stack. # (optional) Enable the password field while launching a Heat stack.
# Defaults to true # Defaults to true
# #
# [*customization_module*]
# (optional) Horizon has a global override mechanism available to perform
# customizations. This adds a key - customization_module - to HORIZON_CONFIG
# dictionary in local_settings.py. The value should be a string with the
# path to your module containing modifications in dotted python path
# notation.
# Defaults to undef
#
# Example:
# customization_module => "my_project.overrides"
#
# === DEPRECATED group/name # === DEPRECATED group/name
# #
# [*fqdn*] # [*fqdn*]
@ -498,6 +509,7 @@ class horizon(
$password_validator = undef, $password_validator = undef,
$password_validator_help = undef, $password_validator_help = undef,
$enable_user_pass = true, $enable_user_pass = true,
$customization_module = undef,
# DEPRECATED PARAMETERS # DEPRECATED PARAMETERS
$custom_theme_path = undef, $custom_theme_path = undef,
$fqdn = undef, $fqdn = undef,

View File

@ -0,0 +1,8 @@
---
features:
- Horizon has a global override mechanism available to perform
customizations. This change adds customization_module key
to HORIZON_CONFIG dictionary in local_settings.py. The
value of the parameter should be a string with the path
to the module containing modifications in dotted python
path notation.

View File

@ -537,6 +537,69 @@ describe 'horizon' do
]) ])
end end
end end
context 'with customization_module provided' do
before do
params.merge!({
:help_url => 'https://docs.openstack.org',
:customization_module => 'my_project.overrides',
:local_settings_template => fixtures_path + '/override_local_settings.py.erb'
})
end
it 'uses the custom local_settings.py template' do
verify_concat_fragment_contents(catalogue, 'local_settings.py', [
'# Custom local_settings.py',
"HORIZON_CONFIG = {",
" 'dashboards': ('project', 'admin', 'settings',),",
" 'default_dashboard': 'project',",
" 'user_home': 'openstack_dashboard.views.get_user_home',",
" 'ajax_queue_limit': 10,",
" 'auto_fade_alerts': {",
" 'delay': 3000,",
" 'fade_duration': 1500,",
" 'types': ['alert-success', 'alert-info']",
" },",
" 'help_url': \"https://docs.openstack.org\",",
" 'exceptions': {'recoverable': exceptions.RECOVERABLE,",
" 'not_found': exceptions.NOT_FOUND,",
" 'unauthorized': exceptions.UNAUTHORIZED},",
" 'customization_module': 'my_project.overrides',",
"}",
])
end
end
context 'with customization_module empty' do
before do
params.merge!({
:help_url => 'https://docs.openstack.org',
:customization_module => '',
:local_settings_template => fixtures_path + '/override_local_settings.py.erb'
})
end
it 'uses the custom local_settings.py template' do
verify_concat_fragment_contents(catalogue, 'local_settings.py', [
'# Custom local_settings.py',
"HORIZON_CONFIG = {",
" 'dashboards': ('project', 'admin', 'settings',),",
" 'default_dashboard': 'project',",
" 'user_home': 'openstack_dashboard.views.get_user_home',",
" 'ajax_queue_limit': 10,",
" 'auto_fade_alerts': {",
" 'delay': 3000,",
" 'fade_duration': 1500,",
" 'types': ['alert-success', 'alert-info']",
" },",
" 'help_url': \"https://docs.openstack.org\",",
" 'exceptions': {'recoverable': exceptions.RECOVERABLE,",
" 'not_found': exceptions.NOT_FOUND,",
" 'unauthorized': exceptions.UNAUTHORIZED},",
"}",
])
end
end
end end
shared_examples_for 'horizon on RedHat' do shared_examples_for 'horizon on RedHat' do

View File

@ -15,4 +15,7 @@ HORIZON_CONFIG = {
'exceptions': {'recoverable': exceptions.RECOVERABLE, 'exceptions': {'recoverable': exceptions.RECOVERABLE,
'not_found': exceptions.NOT_FOUND, 'not_found': exceptions.NOT_FOUND,
'unauthorized': exceptions.UNAUTHORIZED}, 'unauthorized': exceptions.UNAUTHORIZED},
<% if @customization_module and ! (@customization_module.empty?) -%>
'customization_module': '<%= @customization_module -%>',
<% end -%>
} }

View File

@ -111,6 +111,9 @@ HORIZON_CONFIG = {
'exceptions': {'recoverable': exceptions.RECOVERABLE, 'exceptions': {'recoverable': exceptions.RECOVERABLE,
'not_found': exceptions.NOT_FOUND, 'not_found': exceptions.NOT_FOUND,
'unauthorized': exceptions.UNAUTHORIZED}, 'unauthorized': exceptions.UNAUTHORIZED},
<% if @customization_module and ! (@customization_module.empty?) -%>
'customization_module': '<%= @customization_module -%>',
<% end -%>
} }
# If provided, a "Report Bug" link will be displayed in the site header # If provided, a "Report Bug" link will be displayed in the site header