def _ConnectSettings(self): """Increase ServerAliveCountMax and ServerAliveInterval. Wait 2 min before dropping the SSH connection. """ return remote_access.CompileSSHConnectSettings( ServerAliveInterval=15, ServerAliveCountMax=8)
def __init__(self, image_path, port=None, tempdir=None, debug_level=logging.DEBUG): """Initializes VMWrapper with a VM image path. Args: image_path: Path to the VM image. port: SSH port of the VM. tempdir: Temporary working directory. debug_level: Debug level for logging. """ self.image_path = image_path self.tempdir = tempdir self._tempdir_obj = None if not self.tempdir: self._tempdir_obj = osutils.TempDir(prefix='vm_wrapper', sudo_rm=True) self.tempdir = self._tempdir_obj.tempdir self.kvm_pid_path = os.path.join(self.tempdir, 'kvm.pid') self.port = (remote_access.GetUnusedPort() if port is None else remote_access.NormalizePort(port)) self.debug_level = debug_level self.ssh_settings = remote_access.CompileSSHConnectSettings( ConnectTimeout=self.SSH_CONNECT_TIMEOUT) self.agent = remote_access.RemoteAccess( remote_access.LOCALHOST, self.tempdir, self.port, debug_level=self.debug_level, interactive=False) self.device_addr = 'ssh://%s:%d' % (remote_access.LOCALHOST, self.port)
def __init__(self, board, gdb_args, inf_cmd, inf_args, remote, pid, remote_process_name, cgdb_flag, ping, binary): self.board = board self.sysroot = None self.prompt = '(gdb) ' self.inf_cmd = inf_cmd self.run_as_root = False self.gdb_args = gdb_args self.inf_args = inf_args self.remote = remote.hostname if remote else None self.pid = pid self.remote_process_name = remote_process_name # Port used for sending ssh commands to DUT. self.remote_port = remote.port if remote else None # Port for communicating between gdb & gdbserver. self.gdbserver_port = remote_access.GetUnusedPort() self.ssh_settings = remote_access.CompileSSHConnectSettings( **self._EXTRA_SSH_SETTINGS) self.cgdb = cgdb_flag self.framework = 'auto' self.qemu = None self.device = None self.cross_gdb = None self.ping = ping self.binary = binary self.in_chroot = None self.chrome_path = None self.sdk_path = None
def _ConnectSettings(self): """Generates the correct SSH connect settings based on our state.""" kwargs = {'NumberOfPasswordPrompts': 2} if self.known_hosts: # Use the default known_hosts and our current key check setting. kwargs['UserKnownHostsFile'] = None kwargs['StrictHostKeyChecking'] = self.host_key_checking return remote_access.CompileSSHConnectSettings(**kwargs)
def testNoneSettingOmitted(self): """Tests that a None value will omit a default setting from the output.""" self.assertIn('-oProtocol=2', remote_access.CompileSSHConnectSettings()) self.assertNotIn( '-oProtocol=2', remote_access.CompileSSHConnectSettings(Protocol=None))
def testCustomSettingIncluded(self): """Tests that a custom setting will be included in the output.""" self.assertIn( '-oNumberOfPasswordPrompts=100', remote_access.CompileSSHConnectSettings(NumberOfPasswordPrompts=100))