Browse Source

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
changes/54/511054/1
Lokesh Jain 4 years ago
parent
commit
5657428cab
  1. 12
      manifests/init.pp
  2. 8
      releasenotes/notes/add-customization-module-config-option-798d0bb4e00737c3.yaml
  3. 63
      spec/classes/horizon_init_spec.rb
  4. 3
      spec/fixtures/override_local_settings.py.erb
  5. 3
      templates/local_settings.py.erb

12
manifests/init.pp

@ -388,6 +388,17 @@
# (optional) Enable the password field while launching a Heat stack.
# 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
#
# [*fqdn*]
@ -498,6 +509,7 @@ class horizon(
$password_validator = undef,
$password_validator_help = undef,
$enable_user_pass = true,
$customization_module = undef,
# DEPRECATED PARAMETERS
$custom_theme_path = undef,
$fqdn = undef,

8
releasenotes/notes/add-customization-module-config-option-798d0bb4e00737c3.yaml

@ -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.

63
spec/classes/horizon_init_spec.rb

@ -537,6 +537,69 @@ describe 'horizon' do
])
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
shared_examples_for 'horizon on RedHat' do

3
spec/fixtures/override_local_settings.py.erb

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

3
templates/local_settings.py.erb

@ -111,6 +111,9 @@ HORIZON_CONFIG = {
'exceptions': {'recoverable': exceptions.RECOVERABLE,
'not_found': exceptions.NOT_FOUND,
'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

Loading…
Cancel
Save