Generate plugin config file

Import the framework to generate sample config files using
oslo-config-generator so that we can easily maintain consistency
between code and the sample file.

Note that this effectively removes the override made in the previous
sample file.

Change-Id: I35352e26f28b0435c05956b0f99c75078d110cbc
This commit is contained in:
Takashi Kajinami 2024-09-17 23:46:25 +09:00
parent 749ac4557c
commit 4fd17b7229
9 changed files with 76 additions and 7 deletions

3
.gitignore vendored
View File

@ -56,3 +56,6 @@ ChangeLog
# Files created by releasenotes build # Files created by releasenotes build
releasenotes/build releasenotes/build
# Generated config files
etc/*.sample

View File

@ -1,4 +1,3 @@
# Devstack settings # Devstack settings
ABSOLUTE_PATH=$(cd `dirname "${BASH_SOURCE[0]}"` && pwd) ABSOLUTE_PATH=$(cd `dirname "${BASH_SOURCE[0]}"` && pwd)
TAAS_PLUGIN_PATH=$ABSOLUTE_PATH/.. TAAS_PLUGIN_PATH=$ABSOLUTE_PATH/..
TAAS_PLUGIN_CONF_FILE="/etc/neutron/taas_plugin.ini"

View File

@ -0,0 +1,5 @@
[DEFAULT]
output_file = etc/taas.ini.sample
wrap_width = 79
namespace = neutron.taas

View File

@ -1,3 +0,0 @@
[taas]
vlan_range_start = 3000
vlan_range_end = 3500

View File

@ -28,7 +28,7 @@ taas_quota_opts = [
] ]
TaasOpts = [ taas_opts = [
cfg.IntOpt( cfg.IntOpt(
'vlan_range_start', 'vlan_range_start',
default=3900, default=3900,
@ -42,4 +42,4 @@ TaasOpts = [
def register(): def register():
cfg.CONF.register_opts(taas_quota_opts, 'QUOTAS') cfg.CONF.register_opts(taas_quota_opts, 'QUOTAS')
cfg.CONF.register_opts(TaasOpts, 'taas') cfg.CONF.register_opts(taas_opts, 'taas')

27
neutron_taas/opts.py Normal file
View File

@ -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)
]

View File

@ -65,6 +65,9 @@ neutron.service_plugins =
taas = neutron_taas.services.taas.taas_plugin:TaasPlugin taas = neutron_taas.services.taas.taas_plugin:TaasPlugin
neutron.db.alembic_migrations = neutron.db.alembic_migrations =
tap-as-a-service = neutron_taas.db.migration:alembic_migration 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 = oslo.policy.policies =
tap-as-a-service = neutron_taas.policies:list_rules tap-as-a-service = neutron_taas.policies:list_rules
neutron.policies = neutron.policies =

View 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 `ls etc/oslo-config-generator/*`; do
$GEN_CMD --config-file=$file
done
set -x

View File

@ -19,7 +19,9 @@ commands = find . -type f -name "*.py[c|o]" -delete
find . -type l -name "*.py[c|o]" -delete find . -type l -name "*.py[c|o]" -delete
find . -type d -name "__pycache__" -delete find . -type d -name "__pycache__" -delete
stestr run '{posargs}' stestr run '{posargs}'
allowlist_externals = find allowlist_externals =
bash
find
[tox:jenkins] [tox:jenkins]
sitepackages = True sitepackages = True
@ -30,7 +32,9 @@ commands =
pylint --version pylint --version
pylint --rcfile=.pylintrc --output-format=colorized {posargs:neutron_taas} pylint --rcfile=.pylintrc --output-format=colorized {posargs:neutron_taas}
neutron-db-manage --subproject tap-as-a-service --database-connection sqlite:// check_migration neutron-db-manage --subproject tap-as-a-service --database-connection sqlite:// check_migration
{[testenv:genconfig]commands}
{[testenv:genpolicy]commands} {[testenv:genpolicy]commands}
allowlist_externals = bash
[testenv:venv] [testenv:venv]
commands = {posargs} commands = {posargs}
@ -97,6 +101,9 @@ extension =
[hacking] [hacking]
import_exceptions = neutron_taas._i18n import_exceptions = neutron_taas._i18n
[testenv:genconfig]
commands = bash {toxinidir}/tools/generate_config_file_samples.sh
[testenv:dev] [testenv:dev]
# run locally (not in the gate) using editable mode # run locally (not in the gate) using editable mode
# https://pip.pypa.io/en/stable/reference/pip_install/#editable-installs # https://pip.pypa.io/en/stable/reference/pip_install/#editable-installs