'Note: This function is based on paramiko\'s exec_command()
method.
:param timeout: How long to wait (in seconds) for the command to
finish (optional).
:type timeout: ``float``'

def run(self, cmd, timeout=None):

    extra = {'_cmd': cmd}
    self.logger.debug('Executing    command', extra=extra)
    bufsize = (-1)
    transport = self.client.get_transport()
    chan = transport.open_session()
    start_time = time.time()
    chan.exec_command(cmd)
    stdout = StringIO()
    stderr = StringIO()
    stdin = chan.makefile('wb', bufsize)
    stdin.close()
    exit_status_ready = chan.exit_status_ready()
    if exit_status_ready:
        stdout.write(self._consume_stdout(chan).getvalue())
        stderr.write(self._consume_stderr(chan).getvalue())
    while (not exit_status_ready):
        current_time = time.time()
        elapsed_time = (current_time - start_time)
        if (timeout and (elapsed_time > timeout)):
            chan.close()
            raise SSHCommandTimeoutError(cmd=cmd, timeout=timeout)
        stdout.write(self._consume_stdout(chan).getvalue())
        stderr.write(self._consume_stderr(chan).getvalue())
        exit_status_ready = chan.exit_status_ready()
        if exit_status_ready:
            break
        time.sleep(self.SLEEP_DELAY)
    status = chan.recv_exit_status()
    stdout = stdout.getvalue()
    stderr = stderr.getvalue()
    extra = {'_status': status, '_stdout': stdout, '_stderr': stderr}
    self.logger.debug('Command    finished', extra=extra)
    return [stdout, stderr, status]
