diff --git a/.gitignore b/.gitignore index 77f2db9c..6b772e83 100644 --- a/.gitignore +++ b/.gitignore @@ -56,3 +56,6 @@ ChangeLog # Files created by releasenotes build releasenotes/build + +# Generated config files +etc/*.sample diff --git a/devstack/settings b/devstack/settings index c40ed293..9943b977 100644 --- a/devstack/settings +++ b/devstack/settings @@ -1,4 +1,3 @@ # Devstack settings ABSOLUTE_PATH=$(cd `dirname "${BASH_SOURCE[0]}"` && pwd) TAAS_PLUGIN_PATH=$ABSOLUTE_PATH/.. -TAAS_PLUGIN_CONF_FILE="/etc/neutron/taas_plugin.ini" diff --git a/etc/oslo-config-generator/taas.ini b/etc/oslo-config-generator/taas.ini new file mode 100644 index 00000000..5587bd54 --- /dev/null +++ b/etc/oslo-config-generator/taas.ini @@ -0,0 +1,5 @@ +[DEFAULT] +output_file = etc/taas.ini.sample +wrap_width = 79 + +namespace = neutron.taas diff --git a/etc/taas.ini b/etc/taas.ini deleted file mode 100644 index a5481c71..00000000 --- a/etc/taas.ini +++ /dev/null @@ -1,3 +0,0 @@ -[taas] -vlan_range_start = 3000 -vlan_range_end = 3500 diff --git a/neutron_taas/common/config.py b/neutron_taas/common/config.py index cf1cc2b2..5a808876 100644 --- a/neutron_taas/common/config.py +++ b/neutron_taas/common/config.py @@ -28,7 +28,7 @@ taas_quota_opts = [ ] -TaasOpts = [ +taas_opts = [ cfg.IntOpt( 'vlan_range_start', default=3900, @@ -42,4 +42,4 @@ TaasOpts = [ def register(): cfg.CONF.register_opts(taas_quota_opts, 'QUOTAS') - cfg.CONF.register_opts(TaasOpts, 'taas') + cfg.CONF.register_opts(taas_opts, 'taas') diff --git a/neutron_taas/opts.py b/neutron_taas/opts.py new file mode 100644 index 00000000..e90ffc57 --- /dev/null +++ b/neutron_taas/opts.py @@ -0,0 +1,27 @@ +# 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_taas.common.config +import neutron_taas.services.taas.agents.extensions + + +def list_agent_opts(): + return [ + ('DEFAULT', neutron_taas.services.taas.agents.extensions.OPTS) + ] + + +def list_opts(): + return [ + ('quotas', neutron_taas.common.config.taas_quota_opts), + ('taas', neutron_taas.common.config.taas_opts) + ] diff --git a/setup.cfg b/setup.cfg index 87f1e0d6..ac67ae26 100644 --- a/setup.cfg +++ b/setup.cfg @@ -65,6 +65,9 @@ neutron.service_plugins = taas = neutron_taas.services.taas.taas_plugin:TaasPlugin neutron.db.alembic_migrations = tap-as-a-service = neutron_taas.db.migration:alembic_migration +oslo.config.opts = + neutron.taas = neutron_taas.opts:list_opts + neutron.taas.agent = neutron_taas.opts:list_agent_opts oslo.policy.policies = tap-as-a-service = neutron_taas.policies:list_rules neutron.policies = diff --git a/tools/generate_config_file_samples.sh b/tools/generate_config_file_samples.sh new file mode 100755 index 00000000..6b0f4ec2 --- /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 240769b1..6066a051 100644 --- a/tox.ini +++ b/tox.ini @@ -19,7 +19,9 @@ commands = find . -type f -name "*.py[c|o]" -delete find . -type l -name "*.py[c|o]" -delete find . -type d -name "__pycache__" -delete stestr run '{posargs}' -allowlist_externals = find +allowlist_externals = + bash + find [tox:jenkins] sitepackages = True @@ -30,7 +32,9 @@ commands = pylint --version pylint --rcfile=.pylintrc --output-format=colorized {posargs:neutron_taas} neutron-db-manage --subproject tap-as-a-service --database-connection sqlite:// check_migration + {[testenv:genconfig]commands} {[testenv:genpolicy]commands} +allowlist_externals = bash [testenv:venv] commands = {posargs} @@ -97,6 +101,9 @@ extension = [hacking] import_exceptions = neutron_taas._i18n +[testenv:genconfig] +commands = bash {toxinidir}/tools/generate_config_file_samples.sh + [testenv:dev] # run locally (not in the gate) using editable mode # https://pip.pypa.io/en/stable/reference/pip_install/#editable-installs