From 93883c17db888809c2a0cfeafabb43d2cbddb30f Mon Sep 17 00:00:00 2001 From: Martin Hickey Date: Tue, 1 Dec 2015 16:58:50 +0000 Subject: [PATCH] Automatically generate neutron FWaaS configuration files This adds a new tox environment, genconfig, which generates sample neutron FWaaS configuration file using oslo-config-generator. Partially-Implements: blueprint autogen-neutron-conf-file Change-Id: I8e9113dfb88e5290f6eedd012d1a52fc35c3c88c Partial-bug: #1199963 --- .gitignore | 1 + etc/README.txt | 9 ++++++ etc/oslo-config-generator/fwaas_driver.ini | 5 ++++ neutron_fwaas/opts.py | 20 +++++++++++++ ...nfig-file-generation-265c5256668a26bf.yaml | 7 +++++ setup.cfg | 2 ++ tools/generate_config_file_samples.sh | 28 +++++++++++++++++++ tox.ini | 4 +++ 8 files changed, 76 insertions(+) create mode 100644 etc/README.txt create mode 100644 etc/oslo-config-generator/fwaas_driver.ini create mode 100644 neutron_fwaas/opts.py create mode 100644 releasenotes/notes/config-file-generation-265c5256668a26bf.yaml create mode 100755 tools/generate_config_file_samples.sh diff --git a/.gitignore b/.gitignore index dae00f07a..71062c5df 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ cover/ covhtml/ dist/ doc/build +etc/*.sample *.DS_Store *.pyc neutron.egg-info/ diff --git a/etc/README.txt b/etc/README.txt new file mode 100644 index 000000000..074e68141 --- /dev/null +++ b/etc/README.txt @@ -0,0 +1,9 @@ +To generate the sample neutron-fwaas configuration files, run the following +command from the top level of the neutron-fwaas 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 diff --git a/etc/oslo-config-generator/fwaas_driver.ini b/etc/oslo-config-generator/fwaas_driver.ini new file mode 100644 index 000000000..aa5205db7 --- /dev/null +++ b/etc/oslo-config-generator/fwaas_driver.ini @@ -0,0 +1,5 @@ +[DEFAULT] +output_file = etc/fwaas_driver.ini.sample +wrap_width = 79 + +namespace = firewall.agent diff --git a/neutron_fwaas/opts.py b/neutron_fwaas/opts.py new file mode 100644 index 000000000..4eee39665 --- /dev/null +++ b/neutron_fwaas/opts.py @@ -0,0 +1,20 @@ +# 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_fwaas.services.firewall.agents.firewall_agent_api + + +def list_agent_opts(): + return [ + ('fwaas', + neutron_fwaas.services.firewall.agents.firewall_agent_api.FWaaSOpts) + ] diff --git a/releasenotes/notes/config-file-generation-265c5256668a26bf.yaml b/releasenotes/notes/config-file-generation-265c5256668a26bf.yaml new file mode 100644 index 000000000..bb8749ce5 --- /dev/null +++ b/releasenotes/notes/config-file-generation-265c5256668a26bf.yaml @@ -0,0 +1,7 @@ +--- +prelude: > + Generation of sample Neutron FWaaS configuration files. +features: + - Neutron FWaaS 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. diff --git a/setup.cfg b/setup.cfg index 7540e8fae..1ab9b4baf 100644 --- a/setup.cfg +++ b/setup.cfg @@ -36,6 +36,8 @@ neutron.db.alembic_migrations = neutron-fwaas = neutron_fwaas.db.migration:alembic_migrations tempest.test_plugins = neutron-fwaas = neutron_fwaas.tests.tempest_plugin.plugin:NeutronFWaaSPlugin +oslo.config.opts = + firewall.agent = neutron_fwaas.opts:list_agent_opts [build_sphinx] all_files = 1 diff --git a/tools/generate_config_file_samples.sh b/tools/generate_config_file_samples.sh new file mode 100755 index 000000000..6b0f4ec2e --- /dev/null +++ b/tools/generate_config_file_samples.sh @@ -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 `ls etc/oslo-config-generator/*`; do + $GEN_CMD --config-file=$file +done + +set -x diff --git a/tox.ini b/tox.ini index d60554c97..e5be1ea68 100644 --- a/tox.ini +++ b/tox.ini @@ -41,6 +41,7 @@ commands = flake8 {toxinidir}/tools/check_unit_test_structure.sh neutron-db-manage --subproject neutron-fwaas --database-connection sqlite:// check_migration + {[testenv:genconfig]commands} whitelist_externals = sh [testenv:i18n] @@ -80,3 +81,6 @@ commands = [hacking] import_exceptions = neutron.i18n local-check-factory = neutron.hacking.checks.factory + +[testenv:genconfig] +commands = {toxinidir}/tools/generate_config_file_samples.sh