[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] Expose the method-listing call as host.list_methods.
# HG changeset patch # User Ewan Mellor <ewan@xxxxxxxxxxxxx> # Date 1175708540 -3600 # Node ID 5dcb272de7e4f159d5c91c22c0dce9819d31aadb # Parent 4de1e743a5a83add228c18ef0cfcc87c040c7e80 Expose the method-listing call as host.list_methods. Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx> --- docs/xen-api/xenapi-datamodel.tex | 21 ++++++++++++++++++ tools/libxen/include/xen_host.h | 7 ++++++ tools/libxen/src/xen_host.c | 12 ++++++++++ tools/libxen/test/test_bindings.c | 43 ++++++++++++++++++++++++++++++++++++++ tools/python/xen/xend/XendAPI.py | 18 +++++++-------- tools/python/xen/xm/main.py | 2 - 6 files changed, 92 insertions(+), 11 deletions(-) diff -r 4de1e743a5a8 -r 5dcb272de7e4 docs/xen-api/xenapi-datamodel.tex --- a/docs/xen-api/xenapi-datamodel.tex Wed Apr 04 15:00:57 2007 +0100 +++ b/docs/xen-api/xenapi-datamodel.tex Wed Apr 04 18:42:20 2007 +0100 @@ -4952,6 +4952,27 @@ dmesg string \vspace{0.3cm} \vspace{0.3cm} \vspace{0.3cm} +\subsubsection{RPC name:~list\_methods} + +{\bf Overview:} +List all supported methods. + + \noindent {\bf Signature:} +\begin{verbatim} (string Set) list_methods (session_id s)\end{verbatim} + + +\vspace{0.3cm} + + \noindent {\bf Return Type:} +{\tt +string Set +} + + +The name of every supported method. +\vspace{0.3cm} +\vspace{0.3cm} +\vspace{0.3cm} \subsubsection{RPC name:~get\_all} {\bf Overview:} diff -r 4de1e743a5a8 -r 5dcb272de7e4 tools/libxen/include/xen_host.h --- a/tools/libxen/include/xen_host.h Wed Apr 04 15:00:57 2007 +0100 +++ b/tools/libxen/include/xen_host.h Wed Apr 04 18:42:20 2007 +0100 @@ -436,6 +436,13 @@ xen_host_dmesg(xen_session *session, cha /** + * List all supported methods. + */ +extern bool +xen_host_list_methods(xen_session *session, struct xen_string_set **result); + + +/** * Return a list of all the hosts known to the system. */ extern bool diff -r 4de1e743a5a8 -r 5dcb272de7e4 tools/libxen/src/xen_host.c --- a/tools/libxen/src/xen_host.c Wed Apr 04 15:00:57 2007 +0100 +++ b/tools/libxen/src/xen_host.c Wed Apr 04 18:42:20 2007 +0100 @@ -740,6 +740,18 @@ xen_host_dmesg(xen_session *session, cha bool +xen_host_list_methods(xen_session *session, struct xen_string_set **result) +{ + + abstract_type result_type = abstract_type_string_set; + + *result = NULL; + xen_call_(session, "host.list_methods", NULL, 0, &result_type, result); + return session->ok; +} + + +bool xen_host_get_all(xen_session *session, struct xen_host_set **result) { diff -r 4de1e743a5a8 -r 5dcb272de7e4 tools/libxen/test/test_bindings.c --- a/tools/libxen/test/test_bindings.c Wed Apr 04 15:00:57 2007 +0100 +++ b/tools/libxen/test/test_bindings.c Wed Apr 04 18:42:20 2007 +0100 @@ -64,6 +64,7 @@ typedef struct static xen_vm create_new_vm(xen_session *session, bool hvm); static void print_session_info(xen_session *session); +static void print_methods(xen_session *session); static void print_vm_power_state(xen_session *session, xen_vm vm); static void print_vm_metrics(xen_session *session, xen_vm vm); @@ -159,6 +160,14 @@ int main(int argc, char **argv) xen_session_login_with_password(call_func, NULL, username, password); print_session_info(session); + if (!session->ok) + { + /* Error has been logged, just clean up. */ + CLEANUP; + return 1; + } + + print_methods(session); if (!session->ok) { /* Error has been logged, just clean up. */ @@ -644,6 +653,40 @@ static void print_session_info(xen_sessi } +static int pstrcmp(const void *p1, const void *p2) +{ + return strcmp(*(char **)p1, *(char **)p2); +} + + +/** + * Print the list of supported methods. + */ +static void print_methods(xen_session *session) +{ + xen_string_set *methods; + + if (!xen_host_list_methods(session, &methods)) + { + print_error(session); + goto done; + } + + printf("%zd.\n", methods->size); + qsort(methods->contents, methods->size, sizeof(char *), pstrcmp); + + printf("Supported methods:\n"); + for (size_t i = 0; i < methods->size; i++) + { + printf(" %s\n", methods->contents[i]); + } + fflush(stdout); + +done: + xen_string_set_free(methods); +} + + /** * Print the metrics for the given VM. */ diff -r 4de1e743a5a8 -r 5dcb272de7e4 tools/python/xen/xend/XendAPI.py --- a/tools/python/xen/xend/XendAPI.py Wed Apr 04 15:00:57 2007 +0100 +++ b/tools/python/xen/xend/XendAPI.py Wed Apr 04 18:42:20 2007 +0100 @@ -886,7 +886,8 @@ class XendAPI(object): ('get_log', 'String'), ('send_debug_keys', None)] - host_funcs = [('get_by_name_label', 'Set(host)')] + host_funcs = [('get_by_name_label', None), + ('list_methods', None)] # attributes def host_get_name_label(self, session, host_ref): @@ -1010,6 +1011,12 @@ class XendAPI(object): return xen_api_success((XendNode.instance().uuid,)) return xen_api_success([]) + def host_list_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')]) # Xen API: Class host_CPU # ---------------------------------------------------------------- @@ -2611,15 +2618,6 @@ class XendAPI(object): 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 but wraps the call for use with the XendTaskManager. diff -r 4de1e743a5a8 -r 5dcb272de7e4 tools/python/xen/xm/main.py --- a/tools/python/xen/xm/main.py Wed Apr 04 15:00:57 2007 +0100 +++ b/tools/python/xen/xm/main.py Wed Apr 04 18:42:20 2007 +0100 @@ -591,7 +591,7 @@ class Shell(cmd.Cmd): self.prompt = "xm> " if serverType == SERVER_XEN_API: try: - res = server.xenapi._UNSUPPORTED_list_all_methods() + res = server.xenapi.host.list_methods() for f in res: setattr(Shell, 'do_' + f + ' ', self.default) except: _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |