'Run a command on the remote host and look for regexp
in stdout or stderr to determine if the command was
successul or not.
Args:
command: the command line string
timeout: time limit in seconds before attempting to
kill the running process. The run() function
will take a few seconds longer than \'timeout\'
to complete if it has to kill the process.
ignore_status: do not raise an exception, no matter
what the exit code of the command is.
stdout_ok_regexp: regexp that should be in stdout
if the command was successul.
stdout_err_regexp: regexp that should be in stdout
if the command failed.
stderr_ok_regexp: regexp that should be in stderr
if the command was successul.
stderr_err_regexp: regexp that should be in stderr
if the command failed.
Returns:
if the command was successul, raises an exception
otherwise.
Raises:
AutoservRunError:
- the exit code of the command execution was not 0.
- If stderr_err_regexp is found in stderr,
- If stdout_err_regexp is found in stdout,
- If stderr_ok_regexp is not found in stderr.
- If stdout_ok_regexp is not found in stdout,'

def run_grep(self, command, timeout=30, ignore_status=False, stdout_ok_regexp=None, stdout_err_regexp=None, stderr_ok_regexp=None, stderr_err_regexp=None, connect_timeout=30):

    result = self.run(command, timeout, ignore_status=True, connect_timeout=connect_timeout)
    for (regexp, stream) in ((stderr_err_regexp, result.stderr), (stdout_err_regexp, result.stdout)):
        if (regexp and stream):
            err_re = re.compile(regexp)
            if err_re.search(stream):
                raise error.AutoservRunError(('%s    failed,    found    error    pattern:    "%s"' % (command, regexp)), result)
    for (regexp, stream) in ((stderr_ok_regexp, result.stderr), (stdout_ok_regexp, result.stdout)):
        if (regexp and stream):
            ok_re = re.compile(regexp)
            if ok_re.search(stream):
                if ok_re.search(stream):
                    return
    if ((not ignore_status) and (result.exit_status > 0)):
        raise error.AutoservRunError('command    execution    error', result)
