def should_retry_command(run_command_result):
    """Returns True when the command that produces the given output
    should be retried.

    Retry when:
        - the error is a "No route to host" error;
        - the error is a "Connection refused" error.

    This method takes as input the output of the run_command() method:
    (out, err, retcode).
    """
    retry_error_messages = [
        "No route to host",
        "Connection refused",
    ]
    error = ''.join(run_command_result[1])
    return any(
        message in error for message in retry_error_messages)