[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] Added tab completion for methods and object references to xm shell.



# HG changeset patch
# User Ewan Mellor <ewan@xxxxxxxxxxxxx>
# Date 1172440374 0
# Node ID 02f32a4df8db8164bd9cbcb990bf4c591aa1d2ad
# Parent  f3aa6e34aeb14b7ed5907adc7e0571d3a2171913
Added tab completion for methods and object references to xm shell.

Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>
---
 tools/python/xen/xend/XendAPI.py |   10 +++++++++-
 tools/python/xen/xm/main.py      |   14 ++++++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)

diff -r f3aa6e34aeb1 -r 02f32a4df8db tools/python/xen/xend/XendAPI.py
--- a/tools/python/xen/xend/XendAPI.py  Sun Feb 25 17:20:51 2007 +0000
+++ b/tools/python/xen/xend/XendAPI.py  Sun Feb 25 21:52:54 2007 +0000
@@ -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 -r f3aa6e34aeb1 -r 02f32a4df8db tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py       Sun Feb 25 17:20:51 2007 +0000
+++ b/tools/python/xen/xm/main.py       Sun Feb 25 21:52:54 2007 +0000
@@ -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)
@@ -567,6 +571,16 @@ class Shell(cmd.Cmd):
             else:
                 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

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.