diff options
-rw-r--r-- | tools/python/xen/xend/XendAPI.py | 10 | ||||
-rw-r--r-- | tools/python/xen/xm/main.py | 14 |
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 |