From: Thierry Parmentelat Date: Fri, 8 Jan 2016 12:06:17 +0000 (+0100) Subject: sfi introspect X-Git-Tag: sfa-3.1-21~39 X-Git-Url: http://git.onelab.eu/?p=sfa.git;a=commitdiff_plain;h=bcafcbf0f80ffcb32da8eb6579d6c291c6e4e36c sfi introspect --- diff --git a/sfa/client/sfi.py b/sfa/client/sfi.py index 1cecff1f..3588e3eb 100644 --- a/sfa/client/sfi.py +++ b/sfa/client/sfi.py @@ -434,7 +434,7 @@ class Sfi: action="store_true", dest="version_local", default=False, help="display version of the local client") - if canonical in ("version", "trusted"): + if canonical in ("version", "trusted", "introspect"): parser.add_option("-R","--registry_interface", action="store_true", dest="registry_interface", default=False, help="target the registry interface instead of slice interface") @@ -1831,3 +1831,31 @@ $ sfi m -b http://mymanifold.foo.com:7080/ print("Certificate:\n{}\n\n".format(trusted_cert)) # xxx should analyze result return 0 + + @declare_command("", "") + def introspect(self, options, args): + """ + If remote server supports XML-RPC instrospection API, allows + to list supported methods + """ + if options.registry_interface: + server = self.registry() + else: + server = self.sliceapi() + results = server.serverproxy.system.listMethods() + # at first sight a list here means it's fine, + # and a dict suggests an error (no support for introspection?) + if isinstance(results, list): + results = [ name for name in results if 'system.' not in name ] + results.sort() + print("== methods supported at {}".format(server.url)) + if 'Discover' in results: + print("== has support for 'Discover' - most likely a v3") + else: + print("== has no support for 'Discover' - most likely a v2") + for name in results: + print(name) + else: + print("Got return of type {}, expected a list".format(type(results))) + print("This suggests the remote end does not support introspection") + print(results)