Commit 3417dfc7 authored by Yann Bordenave's avatar Yann Bordenave Committed by Antoine Millet
Browse files

Add helpplugin command handler

This patch adds a handler for the helpplugin command.

This patch comes with a patch for cc-cli and a patch for cc-node.
parent 5931e5fd
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
@@ -844,6 +844,31 @@ class CliHandler(RegisteredCCHandler):
                    errs.success(obj['id'], 'plugin uninstalled')
        return errs.get_dict()

    @listed
    def helpplugin(self, query, plugin, method):
        """ Get help about a plugin installed on the matching host.
        """
        objects = self.client.list(query, show=('r', ), method='plugin')
        errs = Reporter()
        for obj in objects:
            if obj['r'] not in ('host', 'hw'):
                errs.error(obj['id'], 'not a host')
            else:
                try:
                    node = self.server.get_client(obj['id'])
                except KeyError:
                    errs.error(obj['id'], 'node not connected')
                    continue

                try:
                    help = node.plugin_help(plugin, method)
                except RpcError as err:
                    errs.error(obj['id'], '%s (exc: %s)' % (err.message,
                                                            err.exception))
                else:
                    errs.success(obj['id'], 'ok.', output=help)
        return errs.get_dict()

    @listed
    def runplugin(self, query, plugin, method, batch=None, **kwargs):
        """ Execute a plugin method on matching nodes.
+5 −0
Original line number Diff line number Diff line
@@ -86,6 +86,11 @@ class HostClient(Client):
        return self.conn.call('script_run', sha1_hash, script, owner,
                              batch=batch, *args)

    def plugin_help(self, plugin, method):
        """ Get help about a plugin installed on matching host.
        """
        return self.conn.call('plugin_help', plugin, method)

    def plugin_run(self, plugin, method, owner, batch=None, **kwargs):
        """ Run a plugin method on the host.
        """