aboutsummaryrefslogtreecommitdiffstats
path: root/nfvbench/config_plugin.py
diff options
context:
space:
mode:
Diffstat (limited to 'nfvbench/config_plugin.py')
-rw-r--r--nfvbench/config_plugin.py48
1 files changed, 28 insertions, 20 deletions
diff --git a/nfvbench/config_plugin.py b/nfvbench/config_plugin.py
index 78c2ebb..86e5505 100644
--- a/nfvbench/config_plugin.py
+++ b/nfvbench/config_plugin.py
@@ -13,44 +13,47 @@
# License for the specific language governing permissions and limitations
# under the License.
#
+"""Configuration Plugin.
+This module is used to override the configuration with platform specific constraints and extensions
+"""
import abc
-import specs
+from . import specs
-class ConfigPluginBase(object):
- """Base class for config plugins. Need to implement public interfaces."""
- __metaclass__ = abc.ABCMeta
+class ConfigPluginBase(object, metaclass=abc.ABCMeta):
+ """Base class for config plugins."""
class InitializationFailure(Exception):
- pass
+ """Used in case of any init failure."""
def __init__(self, config):
+ """Save configuration."""
if not config:
raise ConfigPluginBase.InitializationFailure(
'Initialization parameters need to be assigned.')
-
self.config = config
@abc.abstractmethod
def get_config(self):
- """Returns updated default configuration file."""
+ """Return updated default configuration file."""
def set_config(self, config):
- """This method is called when the config has changed after this instance was initialized.
+ """Set a new configuration.
- This is needed in teh frequent case where the main config is changed in a copy and to
+ This method is called when the config has changed after this instance was initialized.
+ This is needed in the frequent case where the main config is changed in a copy and to
prevent this instance to keep pointing to the old copy of the config
"""
self.config = config
@abc.abstractmethod
def get_openstack_spec(self):
- """Returns OpenStack specs for host."""
+ """Return OpenStack specs for host."""
@abc.abstractmethod
- def get_run_spec(self, openstack_spec):
- """Returns RunSpec for given platform."""
+ def get_run_spec(self, config, openstack_spec):
+ """Return RunSpec for given platform."""
@abc.abstractmethod
def validate_config(self, cfg, openstack_spec):
@@ -58,19 +61,22 @@ class ConfigPluginBase(object):
@abc.abstractmethod
def prepare_results_config(self, cfg):
- """This function is called before running configuration is copied.
+ """Insert any plugin specific information to the results.
+
+ This function is called before running configuration is copied.
Example usage is to remove sensitive information like switch credentials.
"""
@abc.abstractmethod
def get_version(self):
- """Returns platform version."""
+ """Return platform version."""
class ConfigPlugin(ConfigPluginBase):
"""No-op config plugin class. Does not change anything."""
def __init__(self, config):
+ """Invoke the base class constructor."""
ConfigPluginBase.__init__(self, config)
def get_config(self):
@@ -78,18 +84,20 @@ class ConfigPlugin(ConfigPluginBase):
return self.config
def get_openstack_spec(self):
- """Returns OpenStack specs for host."""
+ """Return OpenStack specs for host."""
return specs.OpenStackSpec()
- def get_run_spec(self, openstack_spec):
- """Returns RunSpec for given platform."""
- return specs.RunSpec(self.config.no_vswitch_access, openstack_spec)
+ def get_run_spec(self, config, openstack_spec):
+ """Return RunSpec for given platform."""
+ return specs.RunSpec(config.no_vswitch_access, openstack_spec)
- def validate_config(self, config, openstack_spec):
- pass
+ def validate_config(self, cfg, openstack_spec):
+ """Nothing to validate by default."""
def prepare_results_config(self, cfg):
+ """Nothing to add the results by default."""
return cfg
def get_version(self):
+ """Return an empty version."""
return {}