WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] Added tab completion for methods and obje

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] Added tab completion for methods and object references to xm shell.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Mon, 26 Feb 2007 03:50:27 -0800
Delivery-date: Mon, 26 Feb 2007 04:21:00 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# 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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] Added tab completion for methods and object references to xm shell., Xen patchbot-unstable <=