Automatically generate neutron VPNaaS configuration files
This adds a new tox environment, genconfig, which generates sample neutron VPNaaS configuration file using oslo-config-generator. Updates to some configuration option help messages to reflect useful details that were missing in the code but were present in config files. DocImpact: Update the docs that VPNaaS no longer includes static example configuration files. Instead, use tools/generate_config_file_samples.sh to generate them and the files generated now end with .sample extension. Partially-Implements: blueprint autogen-neutron-conf-file Change-Id: I4a6094b8218dfd320d05bfb1e3bc121e8930c551 Partial-bug: #1199963
This commit is contained in:
parent
f7ed0ebd89
commit
5c8941eeed
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,6 +6,7 @@ cover/
|
|||||||
covhtml/
|
covhtml/
|
||||||
dist/
|
dist/
|
||||||
doc/build
|
doc/build
|
||||||
|
etc/*.sample
|
||||||
*.DS_Store
|
*.DS_Store
|
||||||
*.pyc
|
*.pyc
|
||||||
neutron.egg-info/
|
neutron.egg-info/
|
||||||
|
@ -20,7 +20,7 @@ function neutron_agent_vpnaas_install_agent_packages {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function neutron_vpnaas_configure_common {
|
function neutron_vpnaas_configure_common {
|
||||||
cp $NEUTRON_VPNAAS_DIR/etc/neutron_vpnaas.conf $NEUTRON_VPNAAS_CONF
|
cp $NEUTRON_VPNAAS_DIR/etc/neutron_vpnaas.conf.sample $NEUTRON_VPNAAS_CONF
|
||||||
_neutron_service_plugin_class_add $VPN_PLUGIN
|
_neutron_service_plugin_class_add $VPN_PLUGIN
|
||||||
_neutron_deploy_rootwrap_filters $NEUTRON_VPNAAS_DIR
|
_neutron_deploy_rootwrap_filters $NEUTRON_VPNAAS_DIR
|
||||||
inicomment $NEUTRON_VPNAAS_CONF service_providers service_provider
|
inicomment $NEUTRON_VPNAAS_CONF service_providers service_provider
|
||||||
@ -31,7 +31,7 @@ function neutron_vpnaas_configure_common {
|
|||||||
|
|
||||||
function neutron_vpnaas_configure_agent {
|
function neutron_vpnaas_configure_agent {
|
||||||
local conf_file=${1:-$Q_VPN_CONF_FILE}
|
local conf_file=${1:-$Q_VPN_CONF_FILE}
|
||||||
cp $NEUTRON_VPNAAS_DIR/etc/vpn_agent.ini $conf_file
|
cp $NEUTRON_VPNAAS_DIR/etc/vpn_agent.ini.sample $conf_file
|
||||||
if [[ "$IPSEC_PACKAGE" == "strongswan" ]]; then
|
if [[ "$IPSEC_PACKAGE" == "strongswan" ]]; then
|
||||||
if is_fedora; then
|
if is_fedora; then
|
||||||
iniset_multiline $conf_file vpnagent vpn_device_driver neutron_vpnaas.services.vpn.device_drivers.fedora_strongswan_ipsec.FedoraStrongSwanDriver
|
iniset_multiline $conf_file vpnagent vpn_device_driver neutron_vpnaas.services.vpn.device_drivers.fedora_strongswan_ipsec.FedoraStrongSwanDriver
|
||||||
@ -69,6 +69,11 @@ function neutron_vpnaas_stop {
|
|||||||
stop_process neutron-vpnaas
|
stop_process neutron-vpnaas
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function neutron_vpnaas_generate_config_files {
|
||||||
|
# Uses oslo config generator to generate VPNaaS sample configuration files
|
||||||
|
(cd $NEUTRON_VPNAAS_DIR && exec sudo ./tools/generate_config_file_samples.sh)
|
||||||
|
}
|
||||||
|
|
||||||
# Main plugin processing
|
# Main plugin processing
|
||||||
|
|
||||||
# NOP for pre-install step
|
# NOP for pre-install step
|
||||||
@ -79,6 +84,7 @@ if [[ "$1" == "stack" && "$2" == "install" ]]; then
|
|||||||
|
|
||||||
elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
|
elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
|
||||||
echo_summary "Configuring neutron-vpnaas"
|
echo_summary "Configuring neutron-vpnaas"
|
||||||
|
neutron_vpnaas_generate_config_files
|
||||||
neutron_vpnaas_configure_common
|
neutron_vpnaas_configure_common
|
||||||
neutron_vpnaas_configure_agent
|
neutron_vpnaas_configure_agent
|
||||||
|
|
||||||
|
9
etc/README.txt
Normal file
9
etc/README.txt
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
To generate the sample neutron VPNaaS configuration files, run the following
|
||||||
|
command from the top level of the neutron VPNaaS directory:
|
||||||
|
|
||||||
|
tox -e genconfig
|
||||||
|
|
||||||
|
If a 'tox' environment is unavailable, then you can run the following script
|
||||||
|
instead to generate the configuration files:
|
||||||
|
|
||||||
|
./tools/generate_config_file_samples.sh
|
5
etc/oslo-config-generator/neutron_vpnaas.conf
Normal file
5
etc/oslo-config-generator/neutron_vpnaas.conf
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
[DEFAULT]
|
||||||
|
output_file = etc/neutron_vpnaas.conf.sample
|
||||||
|
wrap_width = 79
|
||||||
|
|
||||||
|
namespace = neutron.vpnaas
|
5
etc/oslo-config-generator/vpn_agent.ini
Normal file
5
etc/oslo-config-generator/vpn_agent.ini
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
[DEFAULT]
|
||||||
|
output_file = etc/vpn_agent.ini.sample
|
||||||
|
wrap_width = 79
|
||||||
|
|
||||||
|
namespace = neutron.vpnaas.agent
|
38
neutron_vpnaas/opts.py
Normal file
38
neutron_vpnaas/opts.py
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
import neutron.services.provider_configuration
|
||||||
|
|
||||||
|
import neutron_vpnaas.services.vpn.agent
|
||||||
|
import neutron_vpnaas.services.vpn.device_drivers.ipsec
|
||||||
|
import neutron_vpnaas.services.vpn.device_drivers.strongswan_ipsec
|
||||||
|
|
||||||
|
|
||||||
|
def list_agent_opts():
|
||||||
|
return [
|
||||||
|
('vpnagent',
|
||||||
|
neutron_vpnaas.services.vpn.agent.vpn_agent_opts),
|
||||||
|
('ipsec',
|
||||||
|
neutron_vpnaas.services.vpn.device_drivers.ipsec.ipsec_opts),
|
||||||
|
('strongswan',
|
||||||
|
neutron_vpnaas.services.vpn.device_drivers.strongswan_ipsec.
|
||||||
|
strongswan_opts),
|
||||||
|
('pluto',
|
||||||
|
neutron_vpnaas.services.vpn.device_drivers.ipsec.pluto_opts)
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def list_opts():
|
||||||
|
return [
|
||||||
|
('service_providers',
|
||||||
|
neutron.services.provider_configuration.serviceprovider_opts)
|
||||||
|
]
|
@ -25,6 +25,18 @@ vpn_agent_opts = [
|
|||||||
'vpn_device_driver',
|
'vpn_device_driver',
|
||||||
default=['neutron_vpnaas.services.vpn.device_drivers.'
|
default=['neutron_vpnaas.services.vpn.device_drivers.'
|
||||||
'ipsec.OpenSwanDriver'],
|
'ipsec.OpenSwanDriver'],
|
||||||
|
sample_default=['neutron_vpnaas.services.vpn.device_drivers.ipsec.'
|
||||||
|
'OpenSwanDriver, '
|
||||||
|
'neutron_vpnaas.services.vpn.device_drivers.'
|
||||||
|
'cisco_ipsec.CiscoCsrIPsecDriver, '
|
||||||
|
'neutron_vpnaas.services.vpn.device_drivers.'
|
||||||
|
'vyatta_ipsec.VyattaIPSecDriver, '
|
||||||
|
'neutron_vpnaas.services.vpn.device_drivers.'
|
||||||
|
'strongswan_ipsec.StrongSwanDriver, '
|
||||||
|
'neutron_vpnaas.services.vpn.device_drivers.'
|
||||||
|
'fedora_strongswan_ipsec.FedoraStrongSwanDriver, '
|
||||||
|
'neutron_vpnaas.services.vpn.device_drivers.'
|
||||||
|
'libreswan_ipsec.LibreSwanDriver'],
|
||||||
help=_("The vpn device drivers Neutron will use")),
|
help=_("The vpn device drivers Neutron will use")),
|
||||||
]
|
]
|
||||||
cfg.CONF.register_opts(vpn_agent_opts, 'vpnagent')
|
cfg.CONF.register_opts(vpn_agent_opts, 'vpnagent')
|
||||||
|
@ -56,7 +56,9 @@ ipsec_opts = [
|
|||||||
default=False,
|
default=False,
|
||||||
help=_("Enable detail logging for ipsec pluto process. "
|
help=_("Enable detail logging for ipsec pluto process. "
|
||||||
"If the flag set to True, the detailed logging will "
|
"If the flag set to True, the detailed logging will "
|
||||||
"be written into config_base_dir/<pid>/log.")),
|
"be written into config_base_dir/<pid>/log. "
|
||||||
|
"Note: This setting applies to OpenSwan and LibreSwan "
|
||||||
|
"only. StrongSwan logs to syslog.")),
|
||||||
]
|
]
|
||||||
cfg.CONF.register_opts(ipsec_opts, 'ipsec')
|
cfg.CONF.register_opts(ipsec_opts, 'ipsec')
|
||||||
|
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
prelude: >
|
||||||
|
Generation of sample Neutron VPNaaS configuration files.
|
||||||
|
features:
|
||||||
|
- Neutron VPNaaS no longer includes static example configuration files.
|
||||||
|
Instead, use tools/generate_config_file_samples.sh to generate them.
|
||||||
|
The files are generated with a .sample extension.
|
@ -40,6 +40,9 @@ device_drivers =
|
|||||||
neutron.services.vpn.device_drivers.vyatta_ipsec.VyattaIPsecDriver = neutron_vpnaas.services.vpn.device_drivers.vyatta_ipsec:VyattaIPsecDriver
|
neutron.services.vpn.device_drivers.vyatta_ipsec.VyattaIPsecDriver = neutron_vpnaas.services.vpn.device_drivers.vyatta_ipsec:VyattaIPsecDriver
|
||||||
neutron.db.alembic_migrations =
|
neutron.db.alembic_migrations =
|
||||||
neutron-vpnaas = neutron_vpnaas.db.migration:alembic_migrations
|
neutron-vpnaas = neutron_vpnaas.db.migration:alembic_migrations
|
||||||
|
oslo.config.opts =
|
||||||
|
neutron.vpnaas = neutron_vpnaas.opts:list_opts
|
||||||
|
neutron.vpnaas.agent = neutron_vpnaas.opts:list_agent_opts
|
||||||
|
|
||||||
[build_sphinx]
|
[build_sphinx]
|
||||||
all_files = 1
|
all_files = 1
|
||||||
|
@ -41,6 +41,7 @@ function _install_vpn_package {
|
|||||||
function _configure_vpn_ini_file {
|
function _configure_vpn_ini_file {
|
||||||
echo_summary "Configuring VPN ini file"
|
echo_summary "Configuring VPN ini file"
|
||||||
local temp_ini=$(mktemp)
|
local temp_ini=$(mktemp)
|
||||||
|
neutron_vpnaas_generate_config_files
|
||||||
neutron_vpnaas_configure_agent $temp_ini
|
neutron_vpnaas_configure_agent $temp_ini
|
||||||
sudo install -d -o $STACK_USER /etc/neutron/
|
sudo install -d -o $STACK_USER /etc/neutron/
|
||||||
sudo install -m 644 -o $STACK_USER $temp_ini $Q_VPN_CONF_FILE
|
sudo install -m 644 -o $STACK_USER $temp_ini $Q_VPN_CONF_FILE
|
||||||
@ -52,6 +53,7 @@ function configure_host_for_vpn_func_testing {
|
|||||||
if [ "$IS_GATE" == "True" ]; then
|
if [ "$IS_GATE" == "True" ]; then
|
||||||
configure_host_for_func_testing
|
configure_host_for_func_testing
|
||||||
fi
|
fi
|
||||||
|
sudo pip install --force oslo.config==3.0.0 # req for oslo-config-generator
|
||||||
_install_vpn_package
|
_install_vpn_package
|
||||||
_configure_vpn_ini_file
|
_configure_vpn_ini_file
|
||||||
}
|
}
|
||||||
|
28
tools/generate_config_file_samples.sh
Executable file
28
tools/generate_config_file_samples.sh
Executable file
@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
GEN_CMD=oslo-config-generator
|
||||||
|
|
||||||
|
if ! type "$GEN_CMD" > /dev/null; then
|
||||||
|
echo "ERROR: $GEN_CMD not installed on the system."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
for file in etc/oslo-config-generator/*; do
|
||||||
|
$GEN_CMD --config-file=$file
|
||||||
|
done
|
||||||
|
|
||||||
|
set -x
|
4
tox.ini
4
tox.ini
@ -72,6 +72,7 @@ commands =
|
|||||||
pylint --rcfile=.pylintrc --output-format=colorized {posargs:neutron_vpnaas}
|
pylint --rcfile=.pylintrc --output-format=colorized {posargs:neutron_vpnaas}
|
||||||
{toxinidir}/tools/check_unit_test_structure.sh
|
{toxinidir}/tools/check_unit_test_structure.sh
|
||||||
neutron-db-manage --subproject neutron-vpnaas --database-connection sqlite:// check_migration
|
neutron-db-manage --subproject neutron-vpnaas --database-connection sqlite:// check_migration
|
||||||
|
{[testenv:genconfig]commands}
|
||||||
whitelist_externals = sh
|
whitelist_externals = sh
|
||||||
|
|
||||||
[testenv:pep8-constraints]
|
[testenv:pep8-constraints]
|
||||||
@ -136,3 +137,6 @@ exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,to
|
|||||||
[hacking]
|
[hacking]
|
||||||
import_exceptions = neutron_vpnaas._i18n
|
import_exceptions = neutron_vpnaas._i18n
|
||||||
local-check-factory = neutron.hacking.checks.factory
|
local-check-factory = neutron.hacking.checks.factory
|
||||||
|
|
||||||
|
[testenv:genconfig]
|
||||||
|
commands = {toxinidir}/tools/generate_config_file_samples.sh
|
||||||
|
Loading…
Reference in New Issue
Block a user