Exemple #1
0
    def _WaitUntilReady(self, retries=_ATTACH_MAX_RETRIES):
        logging.info('Connecting to Fuchsia using SSH.')
        loglistener_path = os.path.join(common.SDK_ROOT, 'tools',
                                        'loglistener')
        instance_id = boot_data.GetNodeName(self._output_dir)
        process = subprocess.Popen([loglistener_path, instance_id],
                                   stdout=subprocess.PIPE,
                                   stderr=subprocess.STDOUT,
                                   stdin=open(os.devnull))
        with LoglistenerReader(process) as loglistener_reader:
            for retry in xrange(retries + 1):
                if retry > 2:
                    # Log loglistener output after 2 failed SSH connection attempt.
                    loglistener_reader.dump_logs()

                host, port = self._GetEndpoint()
                if remote_cmd.RunSsh(self._GetSshConfigPath(), host, port,
                                     ['true'], True) == 0:
                    logging.info('Connected!')
                    self._started = True
                    return True
                time.sleep(_ATTACH_RETRY_INTERVAL)
            logging.error('Timeout limit reached.')

        raise FuchsiaTargetException('Couldn\'t connect using SSH.')
Exemple #2
0
  def _WaitUntilReady(self, retries=_ATTACH_MAX_RETRIES):
    logging.info('Connecting to Fuchsia using SSH.')

    try:
      for retry in xrange(retries + 1):
        if retry == 2 and self._system_logs_reader:
          # Log system logs after 2 failed SSH connection attempt.
          self._system_logs_reader.RedirectTo(sys.stdout);

        host, port = self._GetEndpoint()
        if remote_cmd.RunSsh(self._GetSshConfigPath(), host, port, ['true'],
                             True) == 0:
          logging.info('Connected!')
          self._started = True
          return True
        time.sleep(_ATTACH_RETRY_INTERVAL)
    finally:
      # Redirect logs to /dev/null. run_package.py will use SSH+dlog to get
      # logs from the machine to console.
      if self._system_logs_reader:
        self._system_logs_reader.RedirectTo(open('/dev/null', 'w'));

    logging.error('Timeout limit reached.')

    raise FuchsiaTargetException('Couldn\'t connect using SSH.')
Exemple #3
0
    def RunCommand(self, command, silent=False):
        """Executes a remote command and waits for it to finish executing.

    Returns the exit code of the command."""

        self._AssertStarted()
        host, port = self._GetEndpoint()
        return remote_cmd.RunSsh(self._GetSshConfigPath(), host, port, command,
                                 silent)
Exemple #4
0
    def RunCommand(self, command, silent=False):
        """Executes a remote command and waits for it to finish executing.

    Returns the exit code of the command."""

        self._AssertIsStarted()
        logging.debug('running \'%s\'.' % ' '.join(command))
        host, port = self._GetEndpoint()
        return remote_cmd.RunSsh(self._GetSshConfigPath(), host, port, command,
                                 silent)
Exemple #5
0
 def _WaitUntilReady(self, retries=_ATTACH_MAX_RETRIES):
     logging.debug('Connecting to Fuchsia using SSH.')
     for _ in xrange(retries + 1):
         host, port = self._GetEndpoint()
         if remote_cmd.RunSsh(self._GetSshConfigPath(), host, port,
                              ['true'], True) == 0:
             logging.debug('Connected!')
             self._started = True
             return True
         time.sleep(_ATTACH_RETRY_INTERVAL)
     sys.stderr.write(' timeout limit reached.\n')
     raise FuchsiaTargetException('Couldn\'t connect using SSH.')
Exemple #6
0
 def _Attach(self):
     self._vlogger.write('Trying to connect over SSH...')
     self._vlogger.flush()
     for _ in xrange(_ATTACH_MAX_RETRIES):
         host, port = self._GetEndpoint()
         if remote_cmd.RunSsh(self._ssh_config_path, host, port, ['echo'],
                              True) == 0:
             self._vlogger.write(' connected!\n')
             self._vlogger.flush()
             self._started = True
             return
         self._vlogger.write('.')
         self._vlogger.flush()
         time.sleep(_ATTACH_RETRY_INTERVAL)
     sys.stderr.write(' timeout limit reached.\n')
     raise Exception('Couldn\'t connect to QEMU using SSH.')