diff --git a/os_vif/opts.py b/os_vif/opts.py new file mode 100644 index 00000000..dc48dc36 --- /dev/null +++ b/os_vif/opts.py @@ -0,0 +1,34 @@ +# Copyright (c) 2021 OpenStack Foundation. +# +# 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. + +__all__ = [ + 'list_plugins_opts', +] + +from copy import deepcopy +import os_vif + + +os_vif.initialize() + +_EXT_MANAGER = os_vif._EXT_MANAGER + +plugins_list = [ + (name, _EXT_MANAGER[name].obj) + for name in sorted(_EXT_MANAGER.names()) +] + + +def list_plugins_opts(): + return [('os_vif_' + g, deepcopy(o.CONFIG_OPTS)) for g, o in plugins_list] diff --git a/os_vif/tests/unit/test_os_vif.py b/os_vif/tests/unit/test_os_vif.py index 6ec20562..c76c6d49 100644 --- a/os_vif/tests/unit/test_os_vif.py +++ b/os_vif/tests/unit/test_os_vif.py @@ -18,6 +18,7 @@ from stevedore import extension import os_vif from os_vif import exception from os_vif import objects +from os_vif import opts from os_vif import plugin from os_vif.tests.unit import base @@ -170,3 +171,10 @@ class TestOSVIF(base.TestCase): vif_info = info.plugin_info[0].vif_info self.assertEqual(len(vif_info), 1) self.assertEqual(vif_info[0].vif_object_name, "VIFOpenVSwitch") + + def test_list_opts_entrypoints(self): + list_opts = opts.list_plugins_opts() + for group in list_opts: + for opt in group[1]: + self.assertTrue("oslo_config.cfg" == opt.__module__) + self.assertGreaterEqual(len(list_opts), 3) diff --git a/releasenotes/notes/oslo-config-opts-entrypoints-e83f907b686d774a.yaml b/releasenotes/notes/oslo-config-opts-entrypoints-e83f907b686d774a.yaml new file mode 100644 index 00000000..43d5f980 --- /dev/null +++ b/releasenotes/notes/oslo-config-opts-entrypoints-e83f907b686d774a.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + We now create entrypoints for oslo.config options to allow automated + documentation and validation of the configurable options for all the + plugins. diff --git a/setup.cfg b/setup.cfg index 8e424222..174bd5ff 100644 --- a/setup.cfg +++ b/setup.cfg @@ -31,3 +31,5 @@ os_vif = linux_bridge = vif_plug_linux_bridge.linux_bridge:LinuxBridgePlugin ovs = vif_plug_ovs.ovs:OvsPlugin noop = vif_plug_noop.noop:NoOpPlugin +oslo.config.opts = + os_vif = os_vif.opts:list_plugins_opts