From 06a46ccf084a77eee183fba9f7aa7a609c1070bf Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Tue, 15 Sep 2009 20:26:19 +0000 Subject: bcfg2-admin: implement xcmd mode git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5438 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Server/Admin/Xcmd.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/lib/Server/Admin/Xcmd.py (limited to 'src/lib/Server/Admin/Xcmd.py') diff --git a/src/lib/Server/Admin/Xcmd.py b/src/lib/Server/Admin/Xcmd.py new file mode 100644 index 000000000..79f949fbd --- /dev/null +++ b/src/lib/Server/Admin/Xcmd.py @@ -0,0 +1,36 @@ +import Bcfg2.Options +import Bcfg2.Proxy +import Bcfg2.Server.Admin + +import sys + +class Xcmd(Bcfg2.Server.Admin.Mode): + __shorthelp__ = ("XML-RPC Command Interface") + __longhelp__ = (__shorthelp__ + "\n\nbcfg2-admin xcmd command") + __usage__ = ("bcfg2-admin xcmd ") + + def __init__(self, configfile): + Bcfg2.Server.Admin.Mode.__init__(self, configfile) + + def __call__(self, args): + optinfo = { + 'server': Bcfg2.Options.SERVER_LOCATION, + 'user': Bcfg2.Options.CLIENT_USER, + 'password': Bcfg2.Options.SERVER_PASSWORD, + 'key': Bcfg2.Options.SERVER_KEY, + 'certificate' : Bcfg2.Options.CLIENT_CERT, + 'ca' : Bcfg2.Options.CLIENT_CA + } + setup = Bcfg2.Options.OptionParser(optinfo) + setup.parse(sys.argv[2:]) + Bcfg2.Proxy.RetryMethod.max_retries = 1 + proxy = Bcfg2.Proxy.ComponentProxy(setup['server'], + setup['user'], + setup['password'], + key = setup['key'], + cert = setup['certificate'], + ca = setup['ca'], timeout=180) + cmd = setup['args'][0] + data = getattr(proxy, cmd)() + if data != None: + print data -- cgit v1.2.3-1-g7c22