summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-06-12 09:04:41 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-06-12 09:04:41 -0400
commite10a759d9bc471e0089ce773ae81440fb9a8d854 (patch)
tree3e1006e0332889fa1612ec77a24871c763bfc9be /src
parentf85839c194eead8a3bcfc7a16ff342a468cb85fd (diff)
downloadbcfg2-e10a759d9bc471e0089ce773ae81440fb9a8d854.tar.gz
bcfg2-e10a759d9bc471e0089ce773ae81440fb9a8d854.tar.bz2
bcfg2-e10a759d9bc471e0089ce773ae81440fb9a8d854.zip
added ClientRunHooks plugin role
Diffstat (limited to 'src')
-rw-r--r--src/lib/Bcfg2/Server/Core.py18
-rw-r--r--src/lib/Bcfg2/Server/Plugin.py9
2 files changed, 27 insertions, 0 deletions
diff --git a/src/lib/Bcfg2/Server/Core.py b/src/lib/Bcfg2/Server/Core.py
index 898d5e20e..1843dd756 100644
--- a/src/lib/Bcfg2/Server/Core.py
+++ b/src/lib/Bcfg2/Server/Core.py
@@ -211,6 +211,20 @@ class Core(Component):
for plugin in list(self.plugins.values()):
plugin.shutdown()
+ def client_run_hook(self, hook, metadata):
+ """Checks the data structure."""
+ for plugin in self.plugins_by_type(Bcfg2.Server.Plugin.ClientRunHooks):
+ try:
+ getattr(plugin, hook)(metadata)
+ except AttributeError:
+ err = sys.exc_info()[1]
+ logger.error("Unknown attribute: %s" % err)
+ raise
+ except:
+ err = sys.exc_info()[1]
+ logger.error("%s: Error invoking hook %s: %s" % (plugin, hook,
+ err))
+
def validate_structures(self, metadata, data):
"""Checks the data structure."""
for plugin in self.plugins_by_type(Bcfg2.Server.Plugin.StructureValidator):
@@ -320,6 +334,8 @@ class Core(Component):
logger.error("Metadata consistency error for client %s" % client)
return lxml.etree.Element("error", type='metadata error')
+ self.client_run_hook("start_client_run", meta)
+
try:
structures = self.GetStructures(meta)
except:
@@ -348,6 +364,8 @@ class Core(Component):
logger.error("error in BindStructure", exc_info=1)
self.validate_goals(meta, config)
+ self.client_run_hook("end_client_run", meta)
+
sort_xml(config, key=lambda e: e.get('name'))
logger.info("Generated config for %s in %.03f seconds" % \
diff --git a/src/lib/Bcfg2/Server/Plugin.py b/src/lib/Bcfg2/Server/Plugin.py
index 5e5abe0f6..06a491562 100644
--- a/src/lib/Bcfg2/Server/Plugin.py
+++ b/src/lib/Bcfg2/Server/Plugin.py
@@ -361,6 +361,15 @@ class Version(object):
pass
+class ClientRunHooks(object):
+ """ Provides hooks to interact with client runs """
+ def start_client_run(self, metadata):
+ pass
+
+ def end_client_run(self, metadata):
+ pass
+
+
# the rest of the file contains classes for coherent file caching
class FileBacked(object):