diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2009-09-15 20:26:19 +0000 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2009-09-15 20:26:19 +0000 |
commit | 06a46ccf084a77eee183fba9f7aa7a609c1070bf (patch) | |
tree | 4dd29619baf5ef504354ae7334278487a75d4641 /src | |
parent | 658ce802833b4770b9a1970b779d4a5a85bdd4bf (diff) | |
download | bcfg2-06a46ccf084a77eee183fba9f7aa7a609c1070bf.tar.gz bcfg2-06a46ccf084a77eee183fba9f7aa7a609c1070bf.tar.bz2 bcfg2-06a46ccf084a77eee183fba9f7aa7a609c1070bf.zip |
bcfg2-admin: implement xcmd mode
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5438 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/Server/Admin/Xcmd.py | 36 | ||||
-rw-r--r-- | src/lib/Server/Admin/__init__.py | 2 |
2 files changed, 37 insertions, 1 deletions
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 <command>") + + 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 diff --git a/src/lib/Server/Admin/__init__.py b/src/lib/Server/Admin/__init__.py index 31cb8fa1b..532afc65e 100644 --- a/src/lib/Server/Admin/__init__.py +++ b/src/lib/Server/Admin/__init__.py @@ -1,7 +1,7 @@ __revision__ = '$Revision$' __all__ = ['Mode', 'Client', 'Compare', 'Init', 'Minestruct', 'Perf', - 'Pull', 'Query', 'Snapshots', 'Tidy', 'Viz'] + 'Pull', 'Query', 'Snapshots', 'Tidy', 'Viz', 'Xcmd'] import ConfigParser import logging |