From 62f2da3e6c4f26225e418336572a4ef48968021e Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Thu, 5 Apr 2007 18:26:46 +0000 Subject: Add better driver control support to bcfg2 client (Resolves Ticket #389) git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@3012 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Client/Frame.py | 10 ++++++++-- src/lib/Client/Tools/__init__.py | 1 + src/sbin/bcfg2 | 8 ++++++-- 3 files changed, 15 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/lib/Client/Frame.py b/src/lib/Client/Frame.py index 17bbf2417..b62e5a5d8 100644 --- a/src/lib/Client/Frame.py +++ b/src/lib/Client/Frame.py @@ -47,9 +47,15 @@ class Frame: self.removal = [] self.logger = logging.getLogger("Bcfg2.Client.Frame") if self.setup['drivers']: - tools = self.setup['drivers'].split(',') + tools = [] + for tcandidate in self.setup['drivers'].split(','): + if tcandidate not in Bcfg2.Client.Tools.drivers: + self.logger.error("Tool driver %s is not available"\ + % (tcandidate)) + else: + tools.append(tcandidate) else: - tools = Bcfg2.Client.Tools.drivers[:] + tools = Bcfg2.Client.Tools.default[:] tclass = {} for tool in tools: tool_class = "Bcfg2.Client.Tools.%s" % tool diff --git a/src/lib/Client/Tools/__init__.py b/src/lib/Client/Tools/__init__.py index 21b5a4a00..fd998f271 100644 --- a/src/lib/Client/Tools/__init__.py +++ b/src/lib/Client/Tools/__init__.py @@ -5,6 +5,7 @@ __all__ = ["Action", "APT", "Blast", "Chkconfig", "DebInit", "Encap", "launchd", "Portage", "POSIX", "RPM", "RcUpdate", "SMF", "SYSV", "Yum"] drivers = __all__[:] +default = drivers[:] import os, popen2, stat, sys, Bcfg2.Client.XML, time diff --git a/src/sbin/bcfg2 b/src/sbin/bcfg2 index cccfda910..24ab67592 100755 --- a/src/sbin/bcfg2 +++ b/src/sbin/bcfg2 @@ -4,7 +4,7 @@ __revision__ = '$Revision$' import logging, os, signal, tempfile, time, xmlrpclib -import Bcfg2.Options, Bcfg2.Client.XML, Bcfg2.Client.Frame +import Bcfg2.Options, Bcfg2.Client.XML, Bcfg2.Client.Frame, Bcfg2.Client.Tools try: import Bcfg2.Client.Proxy, Bcfg2.Logging @@ -34,7 +34,7 @@ class Client: 'debug':(('-d', False, "enable debugging output"), False, False, False, True), 'drivers':(('-D', ',', "Specify tool driver set"), - False, False, False, False), + False, ('client', 'drivers'), False, False), 'fingerprint':(('-F', '', "Server Fingerprint"), False, ('communication', 'fingerprint'), False, False), 'dryrun':(('-n', False, "do not actually change the system"), @@ -80,6 +80,10 @@ class Client: Bcfg2.Logging.setup_logging('bcfg2', to_syslog=False, level=level) self.logger = logging.getLogger('bcfg2') self.logger.debug(self.setup) + if self.setup['drivers'] == 'help': + self.logger.info("The following drivers are available:") + self.logger.info(Bcfg2.Client.Tools.drivers) + raise SystemExit, 0 if 'services' in self.setup['remove']: self.logger.error("Service removal is nonsensical, disable services to get former behavior") if self.setup['remove'] not in [False, 'all', 'services', 'packages']: -- cgit v1.2.3-1-g7c22