def remote_service_for_test(test_case, address, command):
    """
    Start a remote process (via SSH) for a test and register a cleanup function
    to stop it when the test finishes.

    :param TestCase test_case: The test case instance on which to register
        cleanup operations.
    :param bytes address: The IPv4 address of the node on which to run
        ``command``.
    :param list command: The command line arguments to run remotely via SSH.
    :returns: A ``RemoteService`` instance.
    """
    service = RemoteService(
        address=address,
        process=run_SSH(
            port=22,
            user='******',
            node=address,
            command=command,
            input=b"",
            key=None,
            background=True
        )
    )
    test_case.addCleanup(close, service.process)
    return service
def run(node, command, input=""):
    """
    Synchronously run a command (list of bytes) on a node's address (bytes)
    with optional input (bytes).
    """
    #print "Running", command, "on", node
    result = run_SSH(22, "root", node, command, input)
    #print "Output from", node + ":", result, "(%s)" % (command,)
    return result
def run(node, command, input=""):
    """
    Synchronously run a command (list of bytes) on a node's address (bytes)
    with optional input (bytes).
    """
    #print "Running", command, "on", node
    result = run_SSH(22, "root", node, command, input)
    #print "Output from", node + ":", result, "(%s)" % (command,)
    return result
def remote_service_for_test(test_case, address, command):
    """
    Start a remote process (via SSH) for a test and register a cleanup function
    to stop it when the test finishes.

    :param TestCase test_case: The test case instance on which to register
        cleanup operations.
    :param bytes address: The IPv4 address of the node on which to run
        ``command``.
    :param list command: The command line arguments to run remotely via SSH.
    :returns: A ``RemoteService`` instance.
    """
    service = RemoteService(address=address,
                            process=run_SSH(port=22,
                                            user='******',
                                            node=address,
                                            command=command,
                                            input=b"",
                                            key=None,
                                            background=True))
    test_case.addCleanup(close, service.process)
    return service