def setup_ssh_client(self): ssh_client = self.ssh_client if ssh_client is None: self.ssh_client = ssh_client = ssh.ssh_proxy_client() or False if ssh_client: tobiko.setup_fixture(ssh_client) return ssh_client
def iter_ssh_clients(): ssh_client = ssh.ssh_proxy_client() if isinstance(ssh_client, ssh.SSHClientFixture): yield ssh_client nodes = topology.list_openstack_nodes() for node in nodes: if isinstance(node.ssh_client, ssh.SSHClientFixture): yield node.ssh_client
def ssh_client(self) -> ssh.SSHClientType: ssh_client = ssh.ssh_proxy_client() if isinstance(ssh_client, ssh.SSHClientFixture): return ssh_client nodes = topology.list_openstack_nodes() for node in nodes: if isinstance(node.ssh_client, ssh.SSHClientFixture): return ssh_client tobiko.skip_test('No such SSH server host to connect to')
def ssh_client(self) -> ssh.SSHClientFixture: ssh_client = ssh.ssh_proxy_client() if isinstance(ssh_client, ssh.SSHClientFixture): return ssh_client nodes = topology.list_openstack_nodes() for node in nodes: if isinstance(node.ssh_client, ssh.SSHClientFixture): return node.ssh_client return self.server.ssh_client
def ssh_process(command, environment=None, current_dir=None, timeout=None, shell=None, stdin=None, stdout=None, stderr=None, ssh_client=None, sudo=None, network_namespace=None): if ssh_client is None: ssh_client = ssh.ssh_proxy_client() if ssh_client: return SSHShellProcessFixture( command=command, environment=environment, current_dir=current_dir, timeout=timeout, shell=shell, stdin=stdin, stdout=stdout, stderr=stderr, ssh_client=ssh_client, sudo=sudo, network_namespace=network_namespace) else: return _local.local_process( command=command, environment=environment, current_dir=current_dir, timeout=timeout, shell=shell, stdin=stdin, stdout=stdout, stderr=stderr, sudo=sudo, network_namespace=network_namespace)
def process(command=None, environment=None, timeout=None, shell=None, stdin=None, stdout=None, stderr=None, ssh_client=None, sudo=None, **kwargs): kwargs.update(command=command, environment=environment, timeout=timeout, shell=shell, stdin=stdin, stdout=stdout, stderr=stderr, sudo=sudo) try: from tobiko.shell.sh import _ssh from tobiko.shell import ssh except ImportError: if ssh_client: raise else: if ssh_client is None: ssh_client = ssh.ssh_proxy_client() if ssh_client: return _ssh.ssh_process(ssh_client=ssh_client, **kwargs) from tobiko.shell.sh import _local return _local.local_process(**kwargs)
def process(command=None, environment=None, timeout: tobiko.Seconds = None, shell=None, stdin=None, stdout=None, stderr=None, ssh_client=None, sudo=None, **kwargs): kwargs.update(command=command, environment=environment, timeout=timeout, shell=shell, stdin=stdin, stdout=stdout, stderr=stderr, sudo=sudo) if timeout is not None: if timeout < 0.: raise ValueError("Invalid timeout for executing process: " "{!r}".format(timeout)) try: from tobiko.shell.sh import _ssh from tobiko.shell import ssh except ImportError: if ssh_client: raise else: if ssh_client is None: ssh_client = ssh.ssh_proxy_client() if ssh_client: return _ssh.ssh_process(ssh_client=ssh_client, **kwargs) from tobiko.shell.sh import _local return _local.local_process(**kwargs)
def test_list_ip_addresses_with_proxy_ssh_client(self): ssh_client = ssh.ssh_proxy_client() if ssh_client is None: self.skip('SSH proxy server not configured') self.test_list_ip_addresses(ssh_client=ssh_client)
def test_proxy_hostname(self): ssh_client = ssh.ssh_proxy_client() if ssh_client is None: self.skip('SSH proxy server not configured') self.test_remote_hostname(ssh_client=ssh_client)
def discover_ssh_proxy_jump_node(self): ssh_client = ssh.ssh_proxy_client() if ssh_client is not None: self.add_node(ssh_client=ssh_client, group='proxy_jump')
def test_ssh_proxy_hostname(self): ssh_client = ssh.ssh_proxy_client() if ssh_client is None: tobiko.skip_test('SSH proxy server is not configured') self.test_ssh_hostname(ssh_client=ssh_client)
def ssh_client(self): host = tobiko.tobiko_config().neutron.nameservers_host if host is None: return ssh.ssh_proxy_client() else: return ssh.ssh_client(host)
def test_list_namespaces_with_proxy_ssh_client(self): ssh_client = ssh.ssh_proxy_client() if ssh_client is None: self.skipTest('SSH proxy server not configured') self.test_list_namespaces(ssh_client=ssh_client)
def expected_shell(self) -> typing.Optional[str]: if ssh.ssh_proxy_client() is None: return LOCAL_EXPECTED_SHELL else: return SSH_EXPECTED_SHELL