Allows for custom location to static assets

Gives the ability to specify the path to static assets.
Closes-Bug: #1684194

Change-Id: I580380472ad816b12237dc444178c953251d86bc
This commit is contained in:
Mariusz Karpiarz 2017-04-19 16:14:31 +01:00
parent 04cf3ccbb3
commit 8a280b091c
5 changed files with 85 additions and 4 deletions

View File

@ -238,6 +238,10 @@
# (optional) The base URL used to contruct horizon web addresses.
# Defaults to '/dashboard' or '/horizon' depending OS
#
# [*root_path*]
# (optional) The path to the location of static assets.
# Defaults to "${::horizon::params::static_path}/openstack-dashboard"
#
# [*session_timeout*]
# (optional) The session timeout for horizon in seconds. After this many seconds of inactivity
# the user is logged out.
@ -442,6 +446,7 @@ class horizon(
$image_backend = {},
$overview_days_range = undef,
$root_url = $::horizon::params::root_url,
$root_path = "${::horizon::params::static_path}/openstack-dashboard",
$session_timeout = 1800,
$timezone = 'UTC',
$secure_cookies = false,
@ -539,6 +544,7 @@ settings_local.py and parameter server_aliases for setting ServerAlias directive
validate_hash($api_versions)
validate_re($password_autocomplete, ['^on$', '^off$'])
validate_re($images_panel, ['^legacy$', '^angular$'])
validate_absolute_path($root_path)
if $cache_backend =~ /MemcachedCache/ {
ensure_resources('package', { 'python-memcache' =>
@ -596,7 +602,8 @@ settings_local.py and parameter server_aliases for setting ServerAlias directive
horizon_ca => $horizon_ca,
extra_params => $vhost_extra_params,
redirect_type => $redirect_type,
root_url => $root_url
root_url => $root_url,
root_path => $root_path,
}
}

View File

@ -79,6 +79,10 @@
# (optional) The base URL used to contruct horizon web addresses.
# Defaults to '/dashboard' or '/horizon' depending OS
#
# [*root_path*]
# (optional) The path to the location of static assets.
# Defaults to "${::horizon::params::static_path}/openstack-dashboard"
#
class horizon::wsgi::apache (
$bind_address = undef,
$fqdn = undef,
@ -99,6 +103,7 @@ class horizon::wsgi::apache (
$extra_params = {},
$redirect_type = 'permanent',
$root_url = $::horizon::params::root_url,
$root_path = "${::horizon::params::static_path}/openstack-dashboard",
) inherits horizon::params {
include ::apache
@ -206,7 +211,7 @@ class horizon::wsgi::apache (
priority => $priority,
aliases => [{
alias => "${root_url}/static",
path => "${::horizon::params::static_path}/openstack-dashboard/static",
path => "${root_path}/static",
}],
port => $http_port,
ssl_cert => $horizon_cert,

View File

@ -0,0 +1,3 @@
---
features:
- Allows to specify a custom root_path to static assets.

View File

@ -285,6 +285,28 @@ describe 'horizon' do
end
end
context 'with default root_path' do
it 'configures apache' do
is_expected.to contain_class('horizon::wsgi::apache').with({
:root_path => "#{platforms_params[:root_path]}",
})
end
end
context 'with root_path set to /tmp/horizon' do
before do
params.merge!({
:root_path => '/tmp/horizon',
})
end
it 'configures apache' do
is_expected.to contain_class('horizon::wsgi::apache').with({
:root_path => '/tmp/horizon',
})
end
end
context 'without apache' do
before do
params.merge!({ :configure_apache => false })
@ -538,11 +560,15 @@ describe 'horizon' do
when 'Debian'
{ :config_file => '/etc/openstack-dashboard/local_settings.py',
:package_name => 'openstack-dashboard',
:root_url => '/horizon' }
:root_url => '/horizon',
:root_path => '/var/lib/openstack-dashboard',
}
when 'RedHat'
{ :config_file => '/etc/openstack-dashboard/local_settings',
:package_name => 'openstack-dashboard',
:root_url => '/dashboard' }
:root_url => '/dashboard',
:root_path => '/usr/share/openstack-dashboard',
}
end
end

View File

@ -232,6 +232,26 @@ describe 'horizon::wsgi::apache' do
)
end
end
context 'with root_path set to /tmp/horizon' do
before do
params.merge!({
:root_path => '/tmp/horizon',
})
end
it 'configures webroot alias' do
if (Gem::Version.new(Puppet.version) >= Gem::Version.new('4.0'))
is_expected.to contain_apache__vhost('horizon_vhost').with(
'aliases' => [{'alias' => '/dashboard/static', 'path' => '/tmp/horizon/static'}],
)
else
is_expected.to contain_apache__vhost('horizon_vhost').with(
'aliases' => [['alias', '/dashboard/static'], ['path', '/tmp/horizon/static']],
)
end
end
end
end
shared_examples_for 'apache for horizon on Debian platforms' do
@ -246,6 +266,26 @@ describe 'horizon::wsgi::apache' do
)
end
end
context 'with root_path set to /tmp/horizon' do
before do
params.merge!({
:root_path => '/tmp/horizon',
})
end
it 'configures webroot alias' do
if (Gem::Version.new(Puppet.version) >= Gem::Version.new('4.0'))
is_expected.to contain_apache__vhost('horizon_vhost').with(
'aliases' => [{'alias' => '/horizon/static', 'path' => '/tmp/horizon/static'}],
)
else
is_expected.to contain_apache__vhost('horizon_vhost').with(
'aliases' => [['alias', '/horizon/static'], ['path', '/tmp/horizon/static']],
)
end
end
end
end