summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-07-11 12:39:21 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-07-11 12:39:21 -0400
commit4dc14648cce88f7d7d9a945929912a6c806dbf4f (patch)
tree4e217aac3fe241c3e1553dee904dd4a0b1fa890a
parentb35d708ea1e56a8d79b2f4e5651c57ebc99e7f8d (diff)
downloadbcfg2-4dc14648cce88f7d7d9a945929912a6c806dbf4f.tar.gz
bcfg2-4dc14648cce88f7d7d9a945929912a6c806dbf4f.tar.bz2
bcfg2-4dc14648cce88f7d7d9a945929912a6c806dbf4f.zip
added ServiceCompat plugin for running 1.3 server with 1.2 clients
-rw-r--r--src/lib/Bcfg2/Server/Plugins/ServiceCompat.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/lib/Bcfg2/Server/Plugins/ServiceCompat.py b/src/lib/Bcfg2/Server/Plugins/ServiceCompat.py
new file mode 100644
index 000000000..aad92b7c7
--- /dev/null
+++ b/src/lib/Bcfg2/Server/Plugins/ServiceCompat.py
@@ -0,0 +1,32 @@
+import Bcfg2.Server.Plugin
+
+class ServiceCompat(Bcfg2.Server.Plugin.Plugin,
+ Bcfg2.Server.Plugin.StructureValidator):
+ """ Use old-style service modes for older clients """
+ name = 'ServiceCompat'
+ __author__ = 'bcfg-dev@mcs.anl.gov'
+ mode_map = {('true', 'true'): 'default',
+ ('interactive', 'true'): 'interactive_only',
+ ('false', 'false'): 'manual'}
+
+ def validate_structures(self, metadata, structures):
+ """ Apply defaults """
+ if metadata.version_info and metadata.version_info > (1, 3, 0, '', 0):
+ # do not care about a client that is _any_ 1.3.0 release
+ # (including prereleases and RCs)
+ return
+
+ for struct in structures:
+ for entry in struct.xpath("//BoundService|//Service"):
+ mode_key = (entry.get("restart", "true").lower(),
+ entry.get("install", "true").lower())
+ try:
+ mode = self.mode_map[mode_key]
+ except KeyError:
+ self.logger.info("Could not map restart and install "
+ "settings of %s:%s to an old-style "
+ "Service mode for %s; using 'manual'" %
+ (entry.tag, entry.get("name"),
+ metadata.hostname))
+ mode = "manual"
+ entry.set("mode", mode)