예제 #1
0
 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
예제 #2
0
    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
예제 #3
0
    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')
예제 #4
0
    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
예제 #5
0
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)
예제 #6
0
파일: _process.py 프로젝트: 4383/tobiko
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)
예제 #7
0
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)
예제 #8
0
 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)
예제 #9
0
 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)
예제 #10
0
 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')
예제 #11
0
 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)
예제 #12
0
 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)
예제 #13
0
 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)
예제 #14
0
 def expected_shell(self) -> typing.Optional[str]:
     if ssh.ssh_proxy_client() is None:
         return LOCAL_EXPECTED_SHELL
     else:
         return SSH_EXPECTED_SHELL