aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorEwan Mellor <ewan@xensource.com>2007-02-25 21:52:54 +0000
committerEwan Mellor <ewan@xensource.com>2007-02-25 21:52:54 +0000
commitbc26603f4ba5b0e2b4bffe9b2375212daa75ee19 (patch)
tree04eae856efeabc29056c47a18aad1fbca6076802 /tools
parent5baa3458c54ea77ce40bf9148b7a99425810d62a (diff)
downloadxen-bc26603f4ba5b0e2b4bffe9b2375212daa75ee19.tar.gz
xen-bc26603f4ba5b0e2b4bffe9b2375212daa75ee19.tar.bz2
xen-bc26603f4ba5b0e2b4bffe9b2375212daa75ee19.zip
Added tab completion for methods and object references to xm shell.
Signed-off-by: Ewan Mellor <ewan@xensource.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/python/xen/xend/XendAPI.py10
-rw-r--r--tools/python/xen/xm/main.py14
2 files changed, 23 insertions, 1 deletions
diff --git a/tools/python/xen/xend/XendAPI.py b/tools/python/xen/xend/XendAPI.py
index 70bd93c99f..5beb037a5b 100644
--- a/tools/python/xen/xend/XendAPI.py
+++ b/tools/python/xen/xend/XendAPI.py
@@ -2138,7 +2138,15 @@ class XendAPI(object):
def debug_get_record(self, session, debug_ref):
return xen_api_success({'uuid': debug_ref})
-
+
+ def list_all_methods(self, _):
+ def _funcs():
+ return [getattr(XendAPI, x) for x in XendAPI.__dict__]
+
+ return xen_api_success([x.api for x in _funcs()
+ if hasattr(x, 'api')])
+ list_all_methods.api = '_UNSUPPORTED_list_all_methods'
+
class XendAPIAsyncProxy:
""" A redirector for Async.Class.function calls to XendAPI
diff --git a/tools/python/xen/xm/main.py b/tools/python/xen/xm/main.py
index ea52f0244d..d59d948e90 100644
--- a/tools/python/xen/xm/main.py
+++ b/tools/python/xen/xm/main.py
@@ -549,6 +549,10 @@ class Shell(cmd.Cmd):
def __init__(self):
cmd.Cmd.__init__(self)
self.prompt = "xm> "
+ if serverType == SERVER_XEN_API:
+ res = server.xenapi._UNSUPPORTED_list_all_methods()
+ for f in res:
+ setattr(Shell, 'do_' + f, self.default)
def default(self, line):
words = shlex.split(line)
@@ -568,6 +572,16 @@ class Shell(cmd.Cmd):
print '*** Unknown command: %s' % words[0]
return False
+ def completedefault(self, text, line, begidx, endidx):
+ cmd = line.split(' ')[0]
+ clas, func = cmd.split('.')
+ if begidx != len(cmd) + 1 or \
+ func.startswith('get_by_') or \
+ func == 'get_all':
+ return []
+ uuids = server.xenapi_request('%s.get_all' % clas, ())
+ return [u + " " for u in uuids if u.startswith(text)]
+
def emptyline(self):
pass