summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Client/Tools
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2014-11-25 00:51:23 +0100
committerAlexander Sulfrian <alexander@sulfrian.net>2014-11-25 16:00:48 +0100
commitbe564316c7c4deaad090bfc0bc79c460965cb1d6 (patch)
tree38c7ab16fc403d8d067cdae1f91fcc3d9af07317 /src/lib/Bcfg2/Client/Tools
parentc544b18a985edd7444593e75ad52483f4842c119 (diff)
downloadbcfg2-be564316c7c4deaad090bfc0bc79c460965cb1d6.tar.gz
bcfg2-be564316c7c4deaad090bfc0bc79c460965cb1d6.tar.bz2
bcfg2-be564316c7c4deaad090bfc0bc79c460965cb1d6.zip
Bundler: add modification support to Bundle dependencies
Bundle dependencies are now realized with RequiredBundle and support inheritance of the modification flag. This requires new client support and will only work with clients >= 1.4.0pre2.
Diffstat (limited to 'src/lib/Bcfg2/Client/Tools')
-rw-r--r--src/lib/Bcfg2/Client/Tools/BundleDeps.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/lib/Bcfg2/Client/Tools/BundleDeps.py b/src/lib/Bcfg2/Client/Tools/BundleDeps.py
new file mode 100644
index 000000000..aaa090633
--- /dev/null
+++ b/src/lib/Bcfg2/Client/Tools/BundleDeps.py
@@ -0,0 +1,34 @@
+""" Bundle dependency support """
+
+import Bcfg2.Client.Tools
+
+
+class BundleDeps(Bcfg2.Client.Tools.Tool):
+ """Bundle dependency helper for Bcfg2. It handles Bundle tags inside the
+ bundles that references the required other bundles that should change the
+ modification status if the referenced bundles is modified."""
+
+ name = 'Bundle'
+ __handles__ = [('Bundle', None)]
+ __req__ = {'Bundle': ['name']}
+
+ def InstallBundle(self, _):
+ """Simple no-op because we only need the BundleUpdated hook."""
+ return dict()
+
+ def VerifyBundle(self, entry, _): # pylint: disable=W0613
+ """Simple no-op because we only need the BundleUpdated hook."""
+ return True
+
+ def BundleUpdated(self, entry):
+ """This handles the dependencies on this bundle. It searches all
+ Bundle tags in other bundles that references the current bundle name
+ and marks those tags as modified to trigger the modification hook on
+ the other bundles."""
+
+ bundle_name = entry.get('name')
+ for bundle in self.config.findall('./Bundle/Bundle'):
+ if bundle.get('name') == bundle_name and \
+ bundle not in self.modified:
+ self.modified.append(bundle)
+ return dict()