diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2006-01-25 16:48:06 +0000 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2006-01-25 16:48:06 +0000 |
commit | e3759d2a2e5fdb0e0a7f7dfa4f8244fdbb3ffe92 (patch) | |
tree | 31d523f4849b2a3232f92c2142cdd35b96beb5e1 /src/sbin/bcfg2-info | |
parent | edca0b698637c3fd0a70af7e4752a46afca938d3 (diff) | |
download | bcfg2-e3759d2a2e5fdb0e0a7f7dfa4f8244fdbb3ffe92.tar.gz bcfg2-e3759d2a2e5fdb0e0a7f7dfa4f8244fdbb3ffe92.tar.bz2 bcfg2-e3759d2a2e5fdb0e0a7f7dfa4f8244fdbb3ffe92.zip |
Introduce the new logging infrastructure and convert the server (and bcfg2-info) over to using it
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@1717 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/sbin/bcfg2-info')
-rwxr-xr-x | src/sbin/bcfg2-info | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/sbin/bcfg2-info b/src/sbin/bcfg2-info index e325b2fd0..7479f85a1 100755 --- a/src/sbin/bcfg2-info +++ b/src/sbin/bcfg2-info @@ -2,10 +2,7 @@ '''This tool loads the Bcfg2 core into an interactive debugger''' __revision__ = '$Revision$' -from sys import argv -from time import sleep -from Bcfg2.Server.Core import Core, CoreInitError -from lxml.etree import tostring +import logging, lxml.etree, sys, time, Bcfg2.Logging, Bcfg2.Server.Core def print_tabular(rows): '''print data in tabular format''' @@ -28,7 +25,7 @@ def do_build(cmd, core): '''build client configuration''' if len(cmd) == 3: output = open(cmd[2], 'w') - output.write(tostring(core.BuildConfiguration(cmd[1]))) + output.write(lxml.etree.tostring(core.BuildConfiguration(cmd[1]))) output.close() else: print 'Usage: build <hostname> <output file>' @@ -126,29 +123,36 @@ def do_version(cmd, core): print __revision__ if __name__ == '__main__': + Bcfg2.Logging.setup_logging(to_syslog=False) + logger = logging.getLogger('bcfg2-info') dispatch = {'build': do_build, 'bundles': do_bundles, 'clients': do_clients, 'generators': do_generators, 'groups': do_groups, 'help': do_help, 'mappings': do_mappings, 'quit': do_quit, 'update': do_update, 'version': do_version} - if '-c' in argv: - cfile = argv[-1] + if '-c' in sys.argv: + cfile = sys.argv[-1] else: cfile = '/etc/bcfg2.conf' try: - bcore = Core({}, cfile) - except CoreInitError, msg: + bcore = Bcfg2.Server.Core.Core({}, cfile) + except Bcfg2.Server.Core.CoreInitError, msg: print "Core load failed because %s" % msg raise SystemExit, 1 for i in range(25): bcore.fam.Service() - sleep(0.5) + time.sleep(0.5) ucmd = get_input() while True: if ucmd[0] == 'debug': break else: if dispatch.has_key(ucmd[0]): - dispatch[ucmd[0]](ucmd, bcore) + try: + dispatch[ucmd[0]](ucmd, bcore) + except SystemExit, code: + raise SystemExit, code + except: + logger.error("command failure", exc_info=1) else: print "Unknown command %s" % ucmd[0] ucmd = get_input() |