Пример #1
0
def copytonodes(nodespec, srcfile, destfile, verbose=False, user=None):
    nodes = expand(nodespec)

    if len(nodes) == 0:
        print "Need at least one node to run on"
        sys.exit(1)

    if verbose:
        print "Copying from %s to %s" % (srcfile, destfile)

    for node in nodes:
        nc = NodeConnection(node, user)
        nc.connect(verbose=verbose)
        nc.exec_command(cmd)
        nc.print_output()
Пример #2
0
def runonnodes(nodespec, cmd, dshbak=False, verbose=False, user=None):
    nodes = expand(nodespec)

    if len(nodes) == 0:
        print "Need at least one node to run on"
        sys.exit(1)

    for node in nodes:
        nc = NodeConnection(node, user)
        nc.connect(verbose=verbose)
        nc.exec_command(cmd)
        if not dshbak:
            print "--------------- %s ---------------" % (node)
            nc.print_output()
        else:
            nc.print_output(str(node) + ": ")
Пример #3
0
def runonnodes(nodespec, cmd, dshbak=False, verbose=False,
               user=None, password=None, output=False,
               sudo=False):
    nodes = expand(nodespec)

    if len(nodes) == 0:
        print "Need at least one node to run on"
        sys.exit(1)

    for node in nodes:
        nc = NodeConnection(node, user, password)
        nc.connect(verbose=verbose)
        if sudo is False:
            nc.exec_command(cmd)
        else:
            nc.exec_sudo_command(cmd)
        if not dshbak:
            print "--------------- %s ---------------" % (node)
            outbuf = nc.print_output(output=output)
        else:
            outbuf = nc.print_output(str(node) + ": ", output=output)
    if output == True:
        return outbuf