From a966d0f83b3f89490e90557442741c900738954b Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Wed, 1 Jul 2015 17:37:31 -0400 Subject: [PATCH] Add plugin interface for appending to tempest config This commit adds a new interface to the external plugin interface for adding configuration options to the config file. This is accomplished by adding a method to the abstract class which plugins can use for registering additional opts on the tempest config object. Then on the tempest side a method is added to the plugin manager class to call the register function for each plugin. This is then called at the end of tempest's normal register_opts() function. Partially Implements: bp external-plugin-interface Change-Id: I2a7915cd978c496091dcf2cbf9d6a89ecbd8c2aa --- tempest/config.py | 6 ++++++ tempest/test_discover/plugins.py | 15 +++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/tempest/config.py b/tempest/config.py index 7382088d45..c61f6dc065 100644 --- a/tempest/config.py +++ b/tempest/config.py @@ -22,6 +22,8 @@ from oslo_config import cfg from oslo_log import log as logging +from tempest.test_discover import plugins + # TODO(marun) Replace use of oslo_config's global ConfigOpts # (cfg.CONF) instance with a local instance (cfg.ConfigOpts()) once @@ -1184,8 +1186,12 @@ _opts = [ def register_opts(): + ext_plugins = plugins.TempestTestPluginManager() + # Register in-tree tempest config options for g, o in _opts: register_opt_group(_CONF, g, o) + # Call external plugin config option registration + ext_plugins.register_plugin_opts(_CONF) def list_opts(): diff --git a/tempest/test_discover/plugins.py b/tempest/test_discover/plugins.py index 197bd0cb13..29b719cf66 100644 --- a/tempest/test_discover/plugins.py +++ b/tempest/test_discover/plugins.py @@ -36,6 +36,17 @@ class TempestPlugin(object): """ return + @abc.abstractmethod + def register_opts(self, conf): + """Method to add additional configuration options to tempest. This + method will be run for the plugin during the register_opts() function + in tempest.config + + :param ConfigOpts conf: The conf object that can be used to register + additional options on. + """ + return + @misc.singleton class TempestTestPluginManager(object): @@ -54,3 +65,7 @@ class TempestTestPluginManager(object): for plug in self.ext_plugins: load_tests_dict[plug.name] = plug.obj.load_tests() return load_tests_dict + + def register_plugin_opts(self, conf): + for plug in self.ext_plugins: + plug.obj.register_opts(conf)