summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/Server/Core.py14
-rw-r--r--src/lib/Server/Plugin.py13
-rw-r--r--src/lib/Server/Plugins/Deps.py8
3 files changed, 28 insertions, 7 deletions
diff --git a/src/lib/Server/Core.py b/src/lib/Server/Core.py
index d4f9b9f6e..4e014809b 100644
--- a/src/lib/Server/Core.py
+++ b/src/lib/Server/Core.py
@@ -194,10 +194,16 @@ class Core(object):
logger.error("error in GetStructures", exc_info=1)
return lxml.etree.Element("error", type='structure error')
- if 'Deps' in self.plugins:
- # do prereq processing
- prereqs = self.plugins['Deps'].GeneratePrereqs(structures, meta)
- structures.append(prereqs)
+ for plugin in self.plugins.values():
+ if isinstance(plugin, Bcfg2.Server.Plugin.StructureValidator):
+ try:
+ plugin.validate_structures(meta, structures)
+ except Bcfg2.Server.Plugin.ValidationError, err:
+ logger.error("Plugin %s structure validation failed: %s" \
+ % (plugin.name, err.message))
+ except:
+ logger.error("Plugin %s: unexpected structure val failure" \
+ % (plugin.name), exc_info=1)
# Perform altsrc consistency checking
esrcs = {}
diff --git a/src/lib/Server/Plugin.py b/src/lib/Server/Plugin.py
index 49f498a5e..35af42355 100644
--- a/src/lib/Server/Plugin.py
+++ b/src/lib/Server/Plugin.py
@@ -127,6 +127,19 @@ class Decision(object):
def GetDecisions(self, metadata, mode):
return []
+class ValidationError(Exception):
+ pass
+
+class StructureValidator(object):
+ '''Validate/modify goal structures'''
+ def validate_structures(self, metadata, structures):
+ raise ValidationError, "not implemented"
+
+class GoalValidator(object):
+ '''Validate/modify configuration goals'''
+ def validate_goals(self, metadata, goals):
+ raise ValidationError, "not implemented"
+
# the rest of the file contains classes for coherent file caching
class FileBacked(object):
diff --git a/src/lib/Server/Plugins/Deps.py b/src/lib/Server/Plugins/Deps.py
index cd9c4b79f..e61c7c029 100644
--- a/src/lib/Server/Plugins/Deps.py
+++ b/src/lib/Server/Plugins/Deps.py
@@ -34,7 +34,8 @@ class DNode(Bcfg2.Server.Plugin.INode):
class DepXMLSrc(Bcfg2.Server.Plugin.XMLSrc):
__node__ = DNode
-class Deps(Bcfg2.Server.Plugin.PrioDir):
+class Deps(Bcfg2.Server.Plugin.PrioDir,
+ Bcfg2.Server.Plugin.StructureValidator):
name = 'Deps'
__version__ = '$Id:$'
__author__ = 'bcfg-dev@mcs.anl.gov'
@@ -42,13 +43,14 @@ class Deps(Bcfg2.Server.Plugin.PrioDir):
def __init__(self, core, datastore):
Bcfg2.Server.Plugin.PrioDir.__init__(self, core, datastore)
+ Bcfg2.Server.Plugin.StructureValidator.__init__(self)
self.cache = {}
def HandleEvent(self, event):
self.cache = {}
Bcfg2.Server.Plugin.PrioDir.HandleEvent(self, event)
- def GeneratePrereqs(self, structures, metadata):
+ def validate_structures(self, metadata, structures):
entries = []
prereqs = []
for structure in structures:
@@ -96,4 +98,4 @@ class Deps(Bcfg2.Server.Plugin.PrioDir):
lxml.etree.SubElement(newstruct, tag, name=name)
except:
self.logger.error("Failed to add dep entry for %s:%s" % (tag, name))
- return newstruct
+ structures.append(newstruct)