summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Client/Tools/BundleDeps.py
diff options
context:
space:
mode:
authorSol Jerome <sol.jerome@gmail.com>2015-01-03 13:07:14 -0600
committerSol Jerome <sol.jerome@gmail.com>2015-01-03 13:07:14 -0600
commit99f7a6addbad7c7f4bc4e1bcb5238f039e1c5692 (patch)
tree852aa12fe61fb9559f3888fed7b1bf234de6b9e9 /src/lib/Bcfg2/Client/Tools/BundleDeps.py
parent128efd62c9acf84c54f071043e1ea954da3361dd (diff)
parentd4ae5e04739d9a8e0732dd35ee28c14b0ff96957 (diff)
downloadbcfg2-99f7a6addbad7c7f4bc4e1bcb5238f039e1c5692.tar.gz
bcfg2-99f7a6addbad7c7f4bc4e1bcb5238f039e1c5692.tar.bz2
bcfg2-99f7a6addbad7c7f4bc4e1bcb5238f039e1c5692.zip
Merge branch 'bundle-modification-deps' of https://github.com/AlexanderS/bcfg2
Conflicts: src/lib/Bcfg2/Client/__init__.py
Diffstat (limited to 'src/lib/Bcfg2/Client/Tools/BundleDeps.py')
-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()