diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2009-01-06 17:32:51 +0000 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2009-01-06 17:32:51 +0000 |
commit | d887ad88674aef96f96ab0ff97c54617b8d715e7 (patch) | |
tree | 12b1da1a6b3943a2534c3dd7cbda342a79dfeb5e | |
parent | a9388f7859586d5d98e815efdcf8d6a85b973bef (diff) | |
download | bcfg2-d887ad88674aef96f96ab0ff97c54617b8d715e7.tar.gz bcfg2-d887ad88674aef96f96ab0ff97c54617b8d715e7.tar.bz2 bcfg2-d887ad88674aef96f96ab0ff97c54617b8d715e7.zip |
Implement generic structure validators and reimplement Deps as one
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5005 ce84e21b-d406-0410-9b95-82705330c041
-rw-r--r-- | doc/1.0-roadmap | 1 | ||||
-rw-r--r-- | doc/plugin-roles | 30 | ||||
-rw-r--r-- | src/lib/Server/Core.py | 14 | ||||
-rw-r--r-- | src/lib/Server/Plugin.py | 13 | ||||
-rw-r--r-- | src/lib/Server/Plugins/Deps.py | 8 |
5 files changed, 59 insertions, 7 deletions
diff --git a/doc/1.0-roadmap b/doc/1.0-roadmap index ac5e4334e..2d90d6f66 100644 --- a/doc/1.0-roadmap +++ b/doc/1.0-roadmap @@ -9,3 +9,4 @@ a 1.0 release. *** Structure Verifier/Modifier *** Configuration Validator/Modifier ** Version Control Backend +** Clean up client/server statistics data format diff --git a/doc/plugin-roles b/doc/plugin-roles new file mode 100644 index 000000000..d34a88c77 --- /dev/null +++ b/doc/plugin-roles @@ -0,0 +1,30 @@ +This documents available plugin roles. + +1) list of plugin roles + +| Role | Class | Status | +|---------------+--------------------+---------------| +| Generator | Generator | done | +| Structure | Structure | done | +| Pull | PullSource | class defined | +| Metadata | Metadata | done | +| Connector | Connector | class defined | +| Probing | Probing | done | +| Decision | Decision | done | +| Remote | Remote | none | +| Statistics | Statistics | class defined | +| Structure Val | StructureValidator | done | +| Goals Val | GoalValidator | class defined | +| Syncing | Syncing | none | +|---------------+--------------------+---------------| + + +2) Configuration of plugins + +3) Implementation Plan + +* Switch Plugin.__name__ => Plugin.name (Fix spurious pylint errors) [done] +* Switch all plugins to new class hierarchy [done] +* Fix Core to use memberships in new classes + + 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) |