Beispiel #1
0
def run(hosts, command, users=None, sudo=False, raw=False):
    assert hosts
    errors = 0
    for host in hosts:
        lines = run_command(host=host, command=command, users=users, sudo=sudo)
        if lines is None:
            log.error("Command: '{}'\nFailed on host: '{}'".format(
                command, host))
            errors += 1
            continue
        host_colon = (host + ":").ljust(16)
        if lines == "":
            if not raw:
                print("{} '{}'".format(host_colon, command))
            continue
        cmd = command
        lines = lines.replace("\r", "")
        for line in lines.split("\n"):
            if raw:
                print(line)
            elif cmd:
                print("{} '{}' -> '{}'".format(host_colon, cmd, line))
                fill = " " * (len(cmd) + 7)
                cmd = None
            else:
                print("{}{}'{}'".format(host_colon, fill, line))
    return errors
Beispiel #2
0
def run(hosts, command, users=None, sudo=False):
    assert hosts
    for host in hosts:
        lines = run_command(host=host, command=command, users=users, sudo=sudo)
        if lines is None:
            sys.exit("Command: '{}'\nFailed on host: '{}'".format(command, host))
        host_colon = (host + ":").ljust(16)
        if lines == "":
            print("{} '{}'".format(host_colon, command))
            continue
        cmd = command
        for line in lines.split("\n"):
            if cmd:
                print("{} '{}' -> '{}'".format(host_colon, cmd, line))
                fill = " " * (len(cmd) + 7)
                cmd = None
            else:
                print("{}{}'{}'".format(host_colon, fill, line))
Beispiel #3
0
def run(hosts, command, users=None, sudo=False):
    assert hosts
    for host in hosts:
        lines = run_command(host=host, command=command, users=users, sudo=sudo)
        if lines is None:
            sys.exit("Command: '{}'\nFailed on host: '{}'".format(command, host))
        host_colon = (host + ":").ljust(16)
        if lines == "":
            print("{} '{}'".format(host_colon, command))
            continue
        cmd = command
        for line in lines.split("\n"):
            if cmd:
                print("{} '{}' -> '{}'".format(host_colon, cmd, line))
                fill = " " * (len(cmd) + 7)
                cmd = None
            else:
                print("{}{}'{}'".format(host_colon, fill, line))