From a3c565340fde4e811a6a7c8af0d71244c80cfed0 Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Thu, 11 Jan 2007 16:31:59 +0000 Subject: Add conflicts support for tool drivers * Add Yum conflict with RPM * Add Yum dependency on /var/lib/rpm git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@2645 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Client/Frame.py | 11 +++++++++-- src/lib/Client/Tools/Yum.py | 6 ++++-- 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/lib/Client/Frame.py b/src/lib/Client/Frame.py index e1ff3b669..6147e15a6 100644 --- a/src/lib/Client/Frame.py +++ b/src/lib/Client/Frame.py @@ -42,19 +42,26 @@ class Frame: tools = self.setup['drivers'].split(',') else: tools = Bcfg2.Client.Tools.__all__[:] + tmods = {} + tool_class = "Bcfg2.Client.Tools.%s" % tool for tool in tools: try: - tool_class = "Bcfg2.Client.Tools.%s" % tool - mod = __import__(tool_class, globals(), locals(), ['*']) + tmods[tool] = __import__(tool_class, globals(), locals(), ['*']) except ImportError: continue + for tool in tools: + for conflict in getattr(tool, 'conflicts', []): + del tmods[conflict] + + for (tool, mod) in tmods.iteritems(): try: self.tools.append(getattr(mod, tool)(self.logger, setup, config, self.states)) except Bcfg2.Client.Tools.toolInstantiationError: continue except: self.logger.error("Failed to instantiate tool %s" % (tool), exc_info=1) + self.logger.info("Loaded tool drivers:") self.logger.info([tool.__name__ for tool in self.tools]) if not self.setup['dryrun']: diff --git a/src/lib/Client/Tools/Yum.py b/src/lib/Client/Tools/Yum.py index 62ccbffc4..641d30a30 100644 --- a/src/lib/Client/Tools/Yum.py +++ b/src/lib/Client/Tools/Yum.py @@ -1,15 +1,17 @@ # This is the bcfg2 support for yum '''This provides bcfg2 support for yum''' -__revision__ = '$Revision:$' +__revision__ = '$Revision$' import Bcfg2.Client.Tools.RPM +conflicts = ['RPM'] + class Yum(Bcfg2.Client.Tools.RPM.RPM): '''Support for Yum packages''' pkgtype = 'yum' pkgtool = ("/usr/bin/yum install %s", ("%s-%s", ["name", "version"])) __name__ = 'Yum' - __execs__ = ['/usr/bin/yum'] + __execs__ = ['/usr/bin/yum', '/var/lib/rpm'] __handles__ = [('Package', 'yum')] def RemovePackages(self, packages): -- cgit v1.2.3-1-g7c22