summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2007-02-12 16:36:03 +0000
committerNarayan Desai <desai@mcs.anl.gov>2007-02-12 16:36:03 +0000
commit0b3d33d8f07ea595aee82cec6e6a908dc1e6f20e (patch)
tree0a046e4c655e14941a8eab7a9917a8d1ee3502dc /src
parent64094271640e11ea6a074a1df7e9fdebde65fd79 (diff)
downloadbcfg2-0b3d33d8f07ea595aee82cec6e6a908dc1e6f20e.tar.gz
bcfg2-0b3d33d8f07ea595aee82cec6e6a908dc1e6f20e.tar.bz2
bcfg2-0b3d33d8f07ea595aee82cec6e6a908dc1e6f20e.zip
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
Diffstat (limited to 'src')
-rwxr-xr-xsrc/sbin/bcfg2-info20
1 files changed, 16 insertions, 4 deletions
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 <hostname> <output file>'
+def doBuildAll(cmd, core):
+ if len(cmd) != 2:
+ print "Usage: buildall <directory>"
+ 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 <hostname> <filename> - build config for hostname, writing to filename'
+ print 'buildall <directory> - build configs for all clients in directory'
print 'buildfile <filename> <hostname> - 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]