Creating oslo.config.opts entry_points for plugins

To assist with automated configuration validation, we need entry points
for oslo.config.opts for each one of the plugins.

Change-Id: I7fc132f917949d147dd6371d54e01a6cfd995aae
This commit is contained in:
David Vallee Delisle 2021-05-04 18:44:46 -04:00
parent d8af3568b8
commit c9b2077786
4 changed files with 50 additions and 0 deletions

34
os_vif/opts.py Normal file
View File

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

View File

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

View File

@ -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.

View File

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