Added tab completion for methods and object references to xm shell.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
This commit is contained in:
Ewan Mellor committed 2007-02-25 21:52:54 +00:00
1 parent 5baa3458c5
commit bc26603f4b
2 files changed
+23 -1

No files matched your search

+9 -1
View File
@@ -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
+14
View File
@@ -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
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.