diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2009-09-18 01:18:23 +0000 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2009-09-18 01:18:23 +0000 |
commit | f1634aacdf8e05400ccbf11c835da85edf920140 (patch) | |
tree | 85cf527c3c86835bee5ab1ff0e000cc405fac8ef /src/lib/Server/Admin | |
parent | 93bdc3f15a050f200c54db5f22781d23f8caa2af (diff) | |
download | bcfg2-f1634aacdf8e05400ccbf11c835da85edf920140.tar.gz bcfg2-f1634aacdf8e05400ccbf11c835da85edf920140.tar.bz2 bcfg2-f1634aacdf8e05400ccbf11c835da85edf920140.zip |
bcfg2-admin xcmd: improve error handling (Resolves Ticket #734)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5441 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Server/Admin')
-rw-r--r-- | src/lib/Server/Admin/Xcmd.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/lib/Server/Admin/Xcmd.py b/src/lib/Server/Admin/Xcmd.py index 79f949fbd..7591c0c45 100644 --- a/src/lib/Server/Admin/Xcmd.py +++ b/src/lib/Server/Admin/Xcmd.py @@ -3,6 +3,7 @@ import Bcfg2.Proxy import Bcfg2.Server.Admin import sys +import xmlrpclib class Xcmd(Bcfg2.Server.Admin.Mode): __shorthelp__ = ("XML-RPC Command Interface") @@ -30,7 +31,20 @@ class Xcmd(Bcfg2.Server.Admin.Mode): key = setup['key'], cert = setup['certificate'], ca = setup['ca'], timeout=180) + if len(setup['args']) == 0: + print("Usage: xcmd <xmlrpc method> <optional arguments>") + return cmd = setup['args'][0] - data = getattr(proxy, cmd)() + args = () + if len(setup['args']) > 1: + args = tuple(setup['args'][1:]) + try: + data = apply(getattr(proxy, cmd), args) + except xmlrpclib.Fault, flt: + if flt.faultCode == 1: + print("Unknown method %s" % cmd) + return + else: + raise if data != None: print data |