Merge "Allow to activate WSGIImportScript option"

This commit is contained in:
Zuul 2019-10-09 20:13:53 +00:00 committed by Gerrit Code Review
commit 4c54371bc9
3 changed files with 97 additions and 0 deletions

View File

@ -134,6 +134,25 @@
# WSGIChunkedRequest option in the vhost.
# Defaults to undef
#
# [*set_wsgi_import_script*]
# (Optional) Enable WSGIImportScript.
# Defaults to false
#
# [*wsgi_import_script*]
# (Optional) WSGIImportScript path.
# Defaults to undef
# If not set and set_wsgi_import_script is true, defaults to the WSGI
# application module path
#
# [*wsgi_import_script_options*]
# (Optional) Sets WSGIImportScript options.
# Defaults to undef
# If not set and set_wsgi_import_script is true, push a dict as follow:
# {
# process-group => $wsgi_daemon_process,
# application-group => $wsgi_application_group,
# }
#
# [*headers*]
# (Optional) Headers for the vhost.
# Defaults to undef
@ -224,6 +243,9 @@ define openstacklib::wsgi::apache (
$wsgi_application_group = '%{GLOBAL}',
$wsgi_pass_authorization = undef,
$wsgi_chunked_request = undef,
$set_wsgi_import_script = false,
$wsgi_import_script = undef,
$wsgi_import_script_options = undef,
$headers = undef,
$custom_wsgi_process_options = {},
$custom_wsgi_script_aliases = undef,
@ -285,6 +307,27 @@ define openstacklib::wsgi::apache (
$wsgi_script_aliases_real = $wsgi_script_aliases_default
}
# Sets WSGIImportScript related options
if $set_wsgi_import_script {
if $wsgi_import_script {
$wsgi_import_script_real = $wsgi_import_script
} else {
$wsgi_import_script_real = $wsgi_script_aliases_real[$path_real]
}
if $wsgi_import_script_options {
$wsgi_import_script_options_real = $wsgi_import_script_options
} else {
$wsgi_import_script_options_real = {
process-group => $wsgi_daemon_process,
application-group => $wsgi_application_group,
}
}
} else {
$wsgi_import_script_real = undef
$wsgi_import_script_options_real = undef
}
# End of WSGIImportScript related options
::apache::vhost { $service_name:
ensure => 'present',
servername => $servername,
@ -310,6 +353,8 @@ define openstacklib::wsgi::apache (
wsgi_application_group => $wsgi_application_group,
wsgi_pass_authorization => $wsgi_pass_authorization,
wsgi_chunked_request => $wsgi_chunked_request,
wsgi_import_script => $wsgi_import_script_real,
wsgi_import_script_options => $wsgi_import_script_options_real,
headers => $headers,
custom_fragment => $vhost_custom_fragment,
allow_encoded_slashes => $allow_encoded_slashes,

View File

@ -0,0 +1,5 @@
---
features:
- |
Add new WSGI related options that should allow faster application startup
and loading.

View File

@ -197,6 +197,53 @@ describe 'openstacklib::wsgi::apache' do
it { should contain_apache__vhost('keystone_wsgi').with_port(params[:bind_port]) }
end
context 'with set_wsgi_import_script enabled' do
let :params do
{
:bind_port => 5000,
:group => 'keystone',
:ssl => true,
:user => 'keystone',
:wsgi_script_dir => '/var/www/cgi-bin/keystone',
:wsgi_script_file => 'main',
:wsgi_script_source => '/usr/share/keystone/keystone.wsgi',
:set_wsgi_import_script => true,
}
end
it { should contain_apache__vhost('keystone_wsgi').with(
:wsgi_import_script_options => {
'process-group' => 'keystone_wsgi',
'application-group' => '%{GLOBAL}',
}
)}
end
context 'with custom wsgi_import_script and options' do
let :params do
{
:bind_port => 5000,
:group => 'keystone',
:ssl => true,
:user => 'keystone',
:wsgi_script_dir => '/var/www/cgi-bin/keystone',
:wsgi_script_file => 'main',
:wsgi_script_source => '/usr/share/keystone/keystone.wsgi',
:set_wsgi_import_script => true,
:wsgi_import_script => '/foo/bar',
:wsgi_import_script_options => {
'process-group' => 'foo',
'application-group' => 'bar',
},
}
end
it { should contain_apache__vhost('keystone_wsgi').with(
:wsgi_import_script => '/foo/bar',
:wsgi_import_script_options => {
'process-group' => 'foo',
'application-group' => 'bar',
}
)}
end
end
on_supported_os({