示例#1
0
文件: plugin.py 项目: decanio/broctl
 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])
示例#2
0
 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)
示例#3
0
 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)
示例#4
0
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
示例#5
0
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)))
示例#6
0
 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])
示例#7
0
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)))