Exemplo n.º 1
0
def overcloud_ssh_client(hostname=None,
                         ip_version=None,
                         network_name=None,
                         server=None,
                         host_config=None):
    if host_config is None:
        host_config = overcloud_host_config(hostname=hostname,
                                            ip_version=ip_version,
                                            network_name=network_name,
                                            server=server)
    return ssh.ssh_client(host=hostname, host_config=host_config)
Exemplo n.º 2
0
 def _ssh_client(self,
                 address,
                 username=None,
                 port=None,
                 key_filename=None,
                 **ssh_parameters):
     username = username or self.config.conf.username
     port = port or self.config.conf.port
     key_filename = key_filename or self.config.conf.key_file
     return ssh.ssh_client(host=str(address),
                           username=username,
                           key_filename=key_filename,
                           **ssh_parameters)
Exemplo n.º 3
0
    def _request(self, client_stack, server_ip_address, protocol, server_port):
        """Perform a request on a server.

        Returns the response in case of success, throws an RequestException
        otherwise.
        """
        if ':' in server_ip_address:
            # Add square brackets around IPv6 address to please curl
            server_ip_address = "[{}]".format(server_ip_address)
        cmd = "curl {} {}://{}:{}/id".format(CURL_OPTIONS, protocol.lower(),
                                             server_ip_address, server_port)

        ssh_client = ssh.ssh_client(
            client_stack.floating_ip_address,
            username=client_stack.image_fixture.username)

        ret = sh.ssh_execute(ssh_client, cmd)
        if ret.exit_status != 0:
            raise RequestException(command=cmd, error=ret.stderr)

        return ret.stdout
Exemplo n.º 4
0
def overcloud_ssh_client(hostname, ip_version=None, network_name=None):
    host_config = overcloud_host_config(hostname=hostname,
                                        ip_version=ip_version,
                                        network_name=network_name)
    return ssh.ssh_client(host=hostname, host_config=host_config)
Exemplo n.º 5
0
Arquivo: _nova.py Projeto: 4383/tobiko
 def ssh_client(self):
     return ssh.ssh_client(host=self.ip_address,
                           username=self.username,
                           password=self.password,
                           proxy_jump=self.peer_stack.ssh_client)
Exemplo n.º 6
0
Arquivo: _nova.py Projeto: 4383/tobiko
 def ssh_client(self):
     return ssh.ssh_client(host=self.ip_address,
                           username=self.username,
                           password=self.password)
Exemplo n.º 7
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)
Exemplo n.º 8
0
    def test_ssh_traffic(self):
        """SSH every member server to get its hostname using a load balancer
        """
        username: typing.Optional[str] = None
        password: typing.Optional[str] = None
        missing_replies = set()

        for member_server in [
                self.listener_stack.server_stack,
                self.listener_stack.other_server_stack
        ]:
            ssh_client = member_server.ssh_client
            hostname = sh.get_hostname(ssh_client=ssh_client)
            missing_replies.add(hostname)
            if username is None:
                username = member_server.username
            else:
                self.assertEqual(
                    username, member_server.username,
                    "Not all member servers have the same "
                    "username to login with")
            if password is None:
                password = member_server.password
            else:
                self.assertEqual(
                    password, member_server.password,
                    "Not all member servers have the same "
                    "password to login with")

        # Get SSH client to the load balancer virtual IP
        ssh_client = ssh.ssh_client(
            host=self.loadbalancer_stack.floating_ip_address,
            port=self.listener_stack.lb_port,
            username=username,
            password=password)

        replies = []
        for attempt in tobiko.retry(timeout=120.):
            LOG.debug(f"SSH to member server by using the load balancer "
                      f"(login='******', attempt={attempt})...")

            with ssh_client:  # disconnect after every loop
                hostname = sh.ssh_hostname(ssh_client=ssh_client)
            try:
                missing_replies.remove(hostname)
            except KeyError:
                self.assertIn(hostname, replies,
                              f"Unexpected hostname reached: {hostname}")
            replies.append(hostname)
            if missing_replies:
                LOG.debug('Reached member server(s):\n'
                          f'{pretty_replies(replies)}')
                if attempt.is_last:
                    self.fail('Unreached member server(s): {missing_replies}')
                else:
                    LOG.debug('Waiting for reaching remaining server(s)... '
                              f'{missing_replies}')
            else:
                LOG.debug('All member servers reached:\n'
                          f'{pretty_replies(replies)}')
                break
        else:
            raise RuntimeError('Broken retry loop')
Exemplo n.º 9
0
 def ssh_client(self):
     return ssh.ssh_client(host=self.server_public_ip,
                           username=self.ssh_username,
                           password=self.ssh_password,
                           proxy_client=self.ssh_proxy_client)
Exemplo n.º 10
0
def undercloud_ssh_client():
    host_config = undercloud_host_config()
    return ssh.ssh_client(host='undercloud-0', host_config=host_config)
Exemplo n.º 11
0
def undercloud_ssh_client() -> ssh.SSHClientFixture:
    host_config = undercloud_host_config()
    if not host_config.hostname:
        raise NoSuchUndercloudHostname('No such undercloud hostname')
    return ssh.ssh_client(host=host_config.hostname, host_config=host_config)