def execute(self, node, cmd): """Executes a command on the host for the given *node* of type `Node`_. Returns a tuple ``(success, output)`` in which ``success`` is True if the command ran successfully and ``output`` is the combined stdout/stderr output.""" result = execute.executeCmdsParallel([(node, cmd)])[0] return (result[1], result[2])
def executeParallel(self, cmds): """Executes a set of commands in parallel on multiple hosts. ``cmds`` is a list of tuples ``(node, cmd)``, in which the *node* is a `Node`_ instance and *cmd* is a string with the command to execute for it. The method returns a list of tuples ``(node, success, output)``, in which ``success`` is True if the command ran successfully and ``output`` is the combined stdout/stderr output for the corresponding ``node``.""" return execute.executeCmdsParallel(cmds)
def executeCmd(nodes, cmd): hadError = False for (node, success, output) in execute.executeCmdsParallel([(n, cmd) for n in nodes]): out = output and "\n> ".join(output) or "" util.output("[%s] %s\n> %s" % (node.name, (success and " " or "error"), out)) if not success: hadError = True return not hadError
def executeCmd(nodes, cmd): for (node, success, output) in execute.executeCmdsParallel([(n, cmd) for n in nodes]): util.output("[%s] %s\n> %s" % (node.name, (success and " " or "error"), "\n> ".join(output)))
def execute(self, node, cmd): """Executes a command on the host for the given *node* of type `Node`_. Returns a tuple ``(success, output)`` in which ``success`` is True if the command ran successfully and ``output`` is the combined stdout/stderr output.""" return execute.executeCmdsParallel([node, cmd])