Change the requirement validation system to return all unsatisfied requirements, to provide more feedback.

This commit is contained in:
Mike Auty
2017-01-08 17:26:09 +00:00
parent cafc09a6d3
commit 149e57afee
8 changed files with 85 additions and 65 deletions
+1 -8
View File
@@ -38,7 +38,7 @@ class PluginInterface(interfaces_configuration.ConfigurableInterface, validity.V
super().__init__(context, config_path)
# Plugins self validate on construction, it makes it more difficult to work with them, but then
# the validation doesn't need to be repeated over and over again by externals
if not self.validate(context, config_path):
if self.unsatisfied(context, config_path):
vollog.warning("Plugin failed validation")
raise exceptions.PluginRequirementException("The plugin configuration failed to validate")
@@ -47,13 +47,6 @@ class PluginInterface(interfaces_configuration.ConfigurableInterface, validity.V
"""Returns a list of Requirement objects for this plugin"""
return []
@classmethod
def validate(cls, context, config_path):
"""Ensures that the plugin's requirements have been met appropriately"""
result_set = [(config_path + "." + requirement.name, requirement.validate(context, config_path)) for requirement
in cls.get_requirements() if not requirement.optional]
return all([r for _, r in result_set])
@abstractmethod
def run(self):
"""Executes the functionality of the code