diff options
author | Sol Jerome <sol.jerome@gmail.com> | 2015-01-03 13:07:14 -0600 |
---|---|---|
committer | Sol Jerome <sol.jerome@gmail.com> | 2015-01-03 13:07:14 -0600 |
commit | 99f7a6addbad7c7f4bc4e1bcb5238f039e1c5692 (patch) | |
tree | 852aa12fe61fb9559f3888fed7b1bf234de6b9e9 /src/lib/Bcfg2/Client/__init__.py | |
parent | 128efd62c9acf84c54f071043e1ea954da3361dd (diff) | |
parent | d4ae5e04739d9a8e0732dd35ee28c14b0ff96957 (diff) | |
download | bcfg2-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/__init__.py')
-rw-r--r-- | src/lib/Bcfg2/Client/__init__.py | 59 |
1 files changed, 47 insertions, 12 deletions
diff --git a/src/lib/Bcfg2/Client/__init__.py b/src/lib/Bcfg2/Client/__init__.py index e07eef2fb..359d7ac73 100644 --- a/src/lib/Bcfg2/Client/__init__.py +++ b/src/lib/Bcfg2/Client/__init__.py @@ -774,29 +774,29 @@ class Client(object): if not Bcfg2.Options.setup.interactive: self.DispatchInstallCalls(clobbered) - for bundle in self.config.findall('.//Bundle'): + all_bundles = self.config.findall('./Bundle') + mbundles.extend(self._get_all_modified_bundles(mbundles, all_bundles)) + + for bundle in all_bundles: if (Bcfg2.Options.setup.only_bundles and bundle.get('name') not in Bcfg2.Options.setup.only_bundles): # prune out unspecified bundles when running with -b continue if bundle in mbundles: - self.logger.debug("Bundle %s was modified" % - bundle.get('name')) - func = "BundleUpdated" - else: - self.logger.debug("Bundle %s was not modified" % - bundle.get('name')) - func = "BundleNotUpdated" + continue + + self.logger.debug("Bundle %s was not modified" % + bundle.get('name')) for tool in self.tools: try: - self.states.update(getattr(tool, func)(bundle)) + self.states.update(tool.BundleNotUpdated(bundle)) except KeyboardInterrupt: raise except: # pylint: disable=W0702 - self.logger.error("%s.%s(%s:%s) call failed:" % - (tool.name, func, bundle.tag, - bundle.get("name")), exc_info=1) + self.logger.error('%s.BundleNotUpdated(%s:%s) call failed:' + % (tool.name, bundle.tag, + bundle.get('name')), exc_info=1) for indep in self.config.findall('.//Independent'): for tool in self.tools: @@ -809,6 +809,41 @@ class Client(object): % (tool.name, indep.tag, indep.get("name")), exc_info=1) + def _get_all_modified_bundles(self, mbundles, all_bundles): + """This gets all modified bundles by calling BundleUpdated until no + new bundles get added to the modification list.""" + new_mbundles = mbundles + add_mbundles = [] + + while new_mbundles: + for bundle in self.config.findall('./Bundle'): + if (Bcfg2.Options.setup.only_bundles and + bundle.get('name') not in + Bcfg2.Options.setup.only_bundles): + # prune out unspecified bundles when running with -b + continue + if bundle not in new_mbundles: + continue + + self.logger.debug('Bundle %s was modified' % + bundle.get('name')) + for tool in self.tools: + try: + self.states.update(tool.BundleUpdated(bundle)) + except: # pylint: disable=W0702 + self.logger.error('%s.BundleUpdated(%s:%s) call ' + 'failed:' % (tool.name, bundle.tag, + bundle.get("name")), + exc_info=1) + + mods = self.modified + new_mbundles = [struct for struct in all_bundles + if any(True for mod in mods if mod in struct) + and struct not in mbundles + add_mbundles] + add_mbundles.extend(new_mbundles) + + return add_mbundles + def Remove(self): """Remove extra entries.""" for tool in self.tools: |