From 0b3d33d8f07ea595aee82cec6e6a908dc1e6f20e Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Mon, 12 Feb 2007 16:36:03 +0000 Subject: Add buildall mode to bcfg2-info (generates all client configs in a directory) git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@2800 ce84e21b-d406-0410-9b95-82705330c041 --- src/sbin/bcfg2-info | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/sbin/bcfg2-info b/src/sbin/bcfg2-info index f2cae5b52..989139bc5 100755 --- a/src/sbin/bcfg2-info +++ b/src/sbin/bcfg2-info @@ -2,7 +2,7 @@ '''This tool loads the Bcfg2 core into an interactive debugger''' __revision__ = '$Revision$' -import logging, lxml.etree, sys, time, Bcfg2.Logging, Bcfg2.Server.Core +import logging, lxml.etree, sys, time, Bcfg2.Logging, Bcfg2.Server.Core, os import Bcfg2.Server.Plugins.Metadata, Bcfg2.Server.Plugin def printTabular(rows): @@ -56,6 +56,17 @@ def doBuild(cmd, core): else: print 'Usage: build ' +def doBuildAll(cmd, core): + if len(cmd) != 2: + print "Usage: buildall " + return + try: + os.mkdir(cmd[1]) + except: + pass + for client in core.metadata.clients: + doBuild(['build', client, cmd[1] + '/' + client + '.xml'], core) + def doBuildFile(cmd, core): '''build a config file for client''' if len(cmd) == 3: @@ -88,6 +99,7 @@ def doHelp(_, dummy): '''print out usage info''' print 'Commands:' print 'build - build config for hostname, writing to filename' + print 'buildall - build configs for all clients in directory' print 'buildfile - build config file for hostname (not written to disk)' print 'bundles - print out group/bundle information' print 'clients - print out client/profile information' @@ -163,9 +175,9 @@ def doVersion(_, dummy): if __name__ == '__main__': Bcfg2.Logging.setup_logging('bcfg2-info', to_syslog=False) logger = logging.getLogger('bcfg2-info') - dispatch = {'build': doBuild, 'buildfile': doBuildFile, 'bundles': doBundles, - 'clients': doClients, 'generators': doGenerators, 'groups': doGroups, - 'help': doHelp, 'mappings': doMappings, 'quit': doQuit, + dispatch = {'build': doBuild, 'buildall': doBuildAll, 'buildfile': doBuildFile, + 'bundles': doBundles, 'clients': doClients, 'generators': doGenerators, + 'groups': doGroups, 'help': doHelp, 'mappings': doMappings, 'quit': doQuit, 'showentries': doShowentries, 'update': doUpdate, 'version': doVersion} if '-c' in sys.argv: cfile = sys.argv[-1] -- cgit v1.2.3-1-g7c22