def _create_setup(self):
     self.admin_client = self.os_admin.network_client
     net_kwargs = {'tenant_id': self.client.tenant_id}
     for net_type in ['vxlan', 'gre']:
         net_kwargs['name'] = '-'.join([net_type, 'net'])
         net_kwargs['provider:network_type'] = net_type
         network = self.admin_client.create_network(**net_kwargs)[
             'network']
         self.networks.append(network)
         self.addCleanup(self.admin_client.delete_network, network['id'])
         subnet = self.create_subnet(network)
         self.create_router_interface(self.router['id'], subnet['id'])
         self.addCleanup(self.client.remove_router_interface_with_subnet_id,
                         self.router['id'], subnet['id'])
     # check that MTUs are different for 2 networks
     self.assertNotEqual(self.networks[0]['mtu'], self.networks[1]['mtu'])
     self.networks.sort(key=lambda net: net['mtu'])
     server1, fip1 = self.create_pingable_vm(self.networks[0],
                                             self.keypair, self.secgroup)
     server_ssh_client1 = ssh.Client(
         self.floating_ips[0]['floating_ip_address'],
         CONF.neutron_plugin_options.advanced_image_ssh_user,
         pkey=self.keypair['private_key'])
     server2, fip2 = self.create_pingable_vm(self.networks[1],
                                             self.keypair, self.secgroup)
     server_ssh_client2 = ssh.Client(
         self.floating_ips[0]['floating_ip_address'],
         CONF.neutron_plugin_options.advanced_image_ssh_user,
         pkey=self.keypair['private_key'])
     for fip in (fip1, fip2):
         self.check_connectivity(
             fip['floating_ip_address'],
             CONF.neutron_plugin_options.advanced_image_ssh_user,
             self.keypair['private_key'])
     return server_ssh_client1, fip1, server_ssh_client2, fip2
Exemple #2
0
 def check_servers_hostnames(self,
                             servers,
                             timeout=None,
                             log_errors=True,
                             external_port=None):
     """Compare hostnames of given servers with their names."""
     try:
         for server in servers:
             kwargs = {}
             if timeout:
                 kwargs['timeout'] = timeout
             try:
                 kwargs['port'] = external_port or (
                     server['port_forwarding_tcp']['external_port'])
             except KeyError:
                 pass
             ssh_client = ssh.Client(self.fip['floating_ip_address'],
                                     CONF.validation.image_ssh_user,
                                     pkey=self.keypair['private_key'],
                                     **kwargs)
             self.assertIn(server['name'], ssh_client.get_hostname())
     except (lib_exc.SSHTimeout, ssh_exc.AuthenticationException) as ssh_e:
         LOG.debug(ssh_e)
         if log_errors:
             self._log_console_output(servers)
             self._log_local_network_status()
         raise
     except AssertionError as assert_e:
         LOG.debug(assert_e)
         if log_errors:
             self._log_console_output(servers)
             self._log_local_network_status()
         raise
Exemple #3
0
 def _create_vms(self, hyper, avail_zone, num_servers=2):
     servers, fips, server_ssh_clients = ([], [], [])
     # Create the availability zone with default zone and
     # a specific mentioned hypervisor.
     az = avail_zone + ':' + hyper
     for i in range(num_servers):
         servers.append(
             self.create_server(flavor_ref=CONF.compute.flavor_ref,
                                image_ref=CONF.compute.image_ref,
                                key_name=self.keypair['name'],
                                networks=[{
                                    'uuid': self.network['id']
                                }],
                                security_groups=[{
                                    'name':
                                    self.secgroup['name']
                                }],
                                availability_zone=az))
     for i, server in enumerate(servers):
         waiters.wait_for_server_status(self.os_admin.servers_client,
                                        server['server']['id'],
                                        const.SERVER_STATUS_ACTIVE)
         port = self.client.list_ports(
             network_id=self.network['id'],
             device_id=server['server']['id'])['ports'][0]
         fip = self.create_floatingip(port=port,
                                      client=self.os_admin.network_client)
         fips.append(fip)
         server_ssh_clients.append(
             ssh.Client(fips[i]['floating_ip_address'],
                        CONF.validation.image_ssh_user,
                        pkey=self.keypair['private_key']))
     return servers, server_ssh_clients, fips
Exemple #4
0
    def _test_udp_port_forwarding(self, servers, timeout=None):
        def _message_received(server, ssh_client, expected_msg):
            self.nc_listen(ssh_client,
                           server['port_forwarding_udp']['internal_port'],
                           constants.PROTO_NAME_UDP, expected_msg, [server])
            received_msg = self.nc_client(
                self.fip['floating_ip_address'],
                server['port_forwarding_udp']['external_port'],
                constants.PROTO_NAME_UDP)
            return expected_msg in received_msg

        for server in servers:
            expected_msg = "%s-UDP-test" % server['name']
            ssh_client = ssh.Client(
                self.fip['floating_ip_address'],
                CONF.validation.image_ssh_user,
                pkey=self.keypair['private_key'],
                port=server['port_forwarding_tcp']['external_port'])
            wait_params = {
                'exception':
                RuntimeError(
                    "Timed out waiting for message from server {!r} ".format(
                        server['id']))
            }
            if timeout:
                wait_params['timeout'] = timeout
            utils.wait_until_true(
                lambda: _message_received(server, ssh_client, expected_msg),
                **wait_params)
Exemple #5
0
    def test_local_ip_connectivity(self):
        server1 = self._create_server(name='local_ip_vm1')
        server2 = self._create_server(name='local_ip_vm2')

        fip = self.create_and_associate_floatingip(server1['port']['id'])
        ssh_client = ssh.Client(
            fip['floating_ip_address'],
            CONF.validation.image_ssh_user,
            pkey=self.keypair['private_key'])

        servers = [server1['server'], server2['server']]

        # first check basic connectivity
        self.check_remote_connectivity(
            ssh_client,
            server2['port']['fixed_ips'][0]['ip_address'],
            servers=servers)

        local_ip = self.create_local_ip(network_id=self.network['id'])
        self.create_local_ip_association(local_ip['id'],
                                         fixed_port_id=server2['port']['id'])
        # check connectivity with local ip address
        self.check_remote_connectivity(
            ssh_client, local_ip['local_ip_address'],
            servers=servers, check_response_ip=False)

        # check basic connectivity after local ip association
        self.check_remote_connectivity(
            ssh_client,
            server2['port']['fixed_ips'][0]['ip_address'],
            servers=servers,
            check_response_ip=False)
    def _create_server_with_port_and_subport(self, vlan_network, vlan_tag):
        parent_port = self.create_port(
            self.network,
            security_groups=[self.secgroup['security_group']['id']])
        port_for_subport = self.create_port(
            vlan_network,
            security_groups=[self.secgroup['security_group']['id']],
            mac_address=parent_port['mac_address'])
        subport = {
            'port_id': port_for_subport['id'],
            'segmentation_type': 'vlan',
            'segmentation_id': vlan_tag
        }
        self.create_trunk(parent_port, [subport])

        server, fip = self._create_server_with_fip(parent_port['id'])

        server_ssh_client = ssh.Client(fip['floating_ip_address'],
                                       CONF.validation.image_ssh_user,
                                       pkey=self.keypair['private_key'])

        return {
            'server': server,
            'fip': fip,
            'ssh_client': server_ssh_client,
            'subport': port_for_subport,
        }
    def create_vm_testing_sec_grp(self, num_servers=2, security_groups=None,
                                  ports=None):
        """Create instance for security group testing

        :param num_servers (int): number of servers to spawn
        :param security_groups (list): list of security groups
        :param ports* (list): list of ports
        *Needs to be the same length as num_servers
        """
        servers, fips, server_ssh_clients = ([], [], [])
        for i in range(num_servers):
            server_args = {
                'flavor_ref': CONF.compute.flavor_ref,
                'image_ref': CONF.compute.image_ref,
                'key_name': self.keypair['name'],
                'networks': [{'uuid': self.network['id']}],
                'security_groups': security_groups
            }
            if ports is not None:
                server_args['networks'][0].update({'port': ports[i]['id']})
            servers.append(self.create_server(**server_args))
        for i, server in enumerate(servers):
            waiters.wait_for_server_status(
                self.os_primary.servers_client, server['server']['id'],
                const.SERVER_STATUS_ACTIVE)
            port = self.client.list_ports(
                network_id=self.network['id'], device_id=server['server'][
                    'id'])['ports'][0]
            fips.append(self.create_floatingip(port=port))
            server_ssh_clients.append(ssh.Client(
                fips[i]['floating_ip_address'], CONF.validation.image_ssh_user,
                pkey=self.keypair['private_key']))
        return server_ssh_clients, fips, servers
 def check_servers_hostnames(self, servers, log_errors=True):
     """Compare hostnames of given servers with their names."""
     try:
         for server in servers:
             kwargs = {}
             try:
                 kwargs['port'] = (
                     server['port_forwarding_tcp']['external_port'])
             except KeyError:
                 pass
             ssh_client = ssh.Client(
                 self.fip['floating_ip_address'],
                 CONF.validation.image_ssh_user,
                 pkey=self.keypair['private_key'],
                 **kwargs)
             self.assertIn(server['name'],
                           ssh_client.exec_command('hostname'))
     except lib_exc.SSHTimeout as ssh_e:
         LOG.debug(ssh_e)
         if log_errors:
             self._log_console_output(servers)
         raise
     except AssertionError as assert_e:
         LOG.debug(assert_e)
         if log_errors:
             self._log_console_output(servers)
         raise
    def test_connectivity_through_2_routers(self):
        ap1_net = self.create_network()
        ap2_net = self.create_network()
        wan_net = self.create_network()
        ap1_subnet = self.create_subnet(ap1_net,
                                        cidr="10.10.210.0/24",
                                        gateway="10.10.210.254")
        ap2_subnet = self.create_subnet(ap2_net,
                                        cidr="10.10.220.0/24",
                                        gateway="10.10.220.254")
        self.create_subnet(wan_net,
                           cidr="10.10.200.0/24",
                           gateway="10.10.200.254")

        ap1_rt = self.create_router(
            router_name=data_utils.rand_name("ap1_rt"),
            admin_state_up=True,
            external_network_id=CONF.network.public_network_id)
        ap2_rt = self.create_router(router_name=data_utils.rand_name("ap2_rt"),
                                    admin_state_up=True)

        ap1_internal_port = self.create_port(
            ap1_net, security_groups=[self.secgroup['id']])
        ap2_internal_port = self.create_port(
            ap2_net, security_groups=[self.secgroup['id']])
        ap1_wan_port = self.create_port(wan_net)
        ap2_wan_port = self.create_port(wan_net)

        self.client.add_router_interface_with_port_id(ap1_rt['id'],
                                                      ap1_wan_port['id'])
        self.client.add_router_interface_with_port_id(ap2_rt['id'],
                                                      ap2_wan_port['id'])
        self.create_router_interface(ap1_rt['id'], ap1_subnet['id'])
        self.create_router_interface(ap2_rt['id'], ap2_subnet['id'])

        self.client.update_router(
            ap1_rt['id'],
            routes=[{
                "destination": ap2_subnet['cidr'],
                "nexthop": ap2_wan_port['fixed_ips'][0]['ip_address']
            }])
        self.client.update_router(
            ap2_rt['id'],
            routes=[{
                "destination": ap1_subnet['cidr'],
                "nexthop": ap1_wan_port['fixed_ips'][0]['ip_address']
            }])

        servers = self._create_servers(ap1_internal_port, ap2_internal_port)

        ap1_fip = self.create_and_associate_floatingip(ap1_internal_port['id'])
        ap1_sshclient = ssh.Client(ap1_fip['floating_ip_address'],
                                   CONF.validation.image_ssh_user,
                                   pkey=self.keypair['private_key'])

        self.check_remote_connectivity(
            ap1_sshclient,
            ap2_internal_port['fixed_ips'][0]['ip_address'],
            servers=servers)
 def check_connectivity(self, host, ssh_user, ssh_key, servers=None):
     ssh_client = ssh.Client(host, ssh_user, pkey=ssh_key)
     try:
         ssh_client.test_connection_auth()
     except lib_exc.SSHTimeout as ssh_e:
         LOG.debug(ssh_e)
         self._log_console_output(servers)
         raise
 def _create_ssh_client(self, floating_ip, use_advanced_image=False):
     if use_advanced_image:
         username = CONF.neutron_plugin_options.advanced_image_ssh_user
     else:
         username = CONF.validation.image_ssh_user
     return ssh.Client(host=floating_ip['floating_ip_address'],
                       username=username,
                       pkey=self.keypair['private_key'])
    def _create_setup(self):
        self.admin_client = self.os_admin.network_client
        for test_net in self._get_network_params():
            test_net['tenant_id'] = self.client.tenant_id
            test_net['name'] = data_utils.rand_name('net')
            cidr = None if 'cidr' not in test_net else test_net.pop('cidr')
            network = self.admin_client.create_network(**test_net)[
                'network']
            self.networks.append(network)
            self.addCleanup(self.admin_client.delete_network, network['id'])
            subnet = self.create_subnet(network, cidr=cidr)
            self.create_router_interface(self.router['id'], subnet['id'])
            self.addCleanup(self.client.remove_router_interface_with_subnet_id,
                            self.router['id'], subnet['id'])

        # update network mtu
        net_mtu = self.admin_client.show_network(
            self.networks[0]['id'])['network']['mtu']
        self.admin_client.update_network(self.networks[0]['id'],
                                         mtu=(net_mtu - 1))
        self.networks[0]['mtu'] = (
            self.admin_client.show_network(
                self.networks[0]['id'])['network']['mtu'])

        # check that MTUs are different for 2 networks
        self.assertNotEqual(self.networks[0]['mtu'], self.networks[1]['mtu'])
        self.networks.sort(key=lambda net: net['mtu'])
        server1, fip1 = self.create_pingable_vm(self.networks[0],
                                                self.keypair, self.secgroup)
        server_ssh_client1 = ssh.Client(
            self.floating_ips[0]['floating_ip_address'],
            CONF.neutron_plugin_options.advanced_image_ssh_user,
            pkey=self.keypair['private_key'])
        server2, fip2 = self.create_pingable_vm(self.networks[1],
                                                self.keypair, self.secgroup)
        server_ssh_client2 = ssh.Client(
            self.floating_ips[0]['floating_ip_address'],
            CONF.neutron_plugin_options.advanced_image_ssh_user,
            pkey=self.keypair['private_key'])
        for fip in (fip1, fip2):
            self.check_connectivity(
                fip['floating_ip_address'],
                CONF.neutron_plugin_options.advanced_image_ssh_user,
                self.keypair['private_key'])
        return server_ssh_client1, fip1, server_ssh_client2, fip2
Exemple #13
0
 def test_ping_global_ip_from_vm_with_fip(self):
     self.setup_network_and_server()
     server_ssh_client = ssh.Client(self.fip['floating_ip_address'],
                                    CONF.validation.image_ssh_user,
                                    pkey=self.keypair['private_key'])
     self.check_remote_connectivity(
         server_ssh_client,
         CONF.neutron_plugin_options.global_ip_address,
         ping_count=1)
 def _check_fips_connectivity(self, mutable_fip, permanent_fip):
     for fip in [mutable_fip, permanent_fip]:
         fip['ssh_client'] = ssh.Client(fip['floating_ip_address'],
                                        CONF.validation.image_ssh_user,
                                        pkey=self.keypair['private_key'])
     self.check_remote_connectivity(permanent_fip['ssh_client'],
                                    mutable_fip['floating_ip_address'])
     self.check_remote_connectivity(mutable_fip['ssh_client'],
                                    permanent_fip['floating_ip_address'])
Exemple #15
0
    def test_snat_external_ip(self):
        """Check connectivity to an external IP"""
        gateway_external_ip = self._get_external_gateway()

        if not gateway_external_ip:
            raise self.skipTest("IPv4 gateway is not configured for public "
                                "network or public_network_id is not "
                                "configured")
        proxy = self._create_server()
        proxy_client = ssh.Client(proxy['fip']['floating_ip_address'],
                                  CONF.validation.image_ssh_user,
                                  pkey=self.keypair['private_key'])
        src_server = self._create_server(create_floating_ip=False)
        src_server_ip = src_server['port']['fixed_ips'][0]['ip_address']
        ssh_client = ssh.Client(src_server_ip,
                                CONF.validation.image_ssh_user,
                                pkey=self.keypair['private_key'],
                                proxy_client=proxy_client)
        self.check_remote_connectivity(ssh_client, gateway_external_ip)
Exemple #16
0
 def _prepare_unregistered(self, server, mcast_address):
     check_script = get_unregistered_script(
         group=mcast_address, result_file=self.unregistered_output_file)
     ssh_client = ssh.Client(server['fip']['floating_ip_address'],
                             self.username,
                             pkey=self.keypair['private_key'])
     self._check_cmd_installed_on_server(ssh_client, server['id'],
                                         'tcpdump')
     server['ssh_client'].execute_script(
         'echo "%s" > ~/unregistered_traffic_receiver.sh' % check_script)
    def _test_east_west(self):
        # The proxy VM is used to control the source VM when it doesn't
        # have a floating-ip.
        if self.src_has_fip:
            proxy = None
            proxy_client = None
        else:
            proxy = self._create_server()
            proxy_client = ssh.Client(proxy['fip']['floating_ip_address'],
                                      CONF.validation.image_ssh_user,
                                      pkey=self.keypair['private_key'])

        # Source VM
        if self.src_has_fip:
            src_server = self._create_server()
            src_server_ip = src_server['fip']['floating_ip_address']
        else:
            src_server = self._create_server(create_floating_ip=False)
            src_server_ip = src_server['port']['fixed_ips'][0]['ip_address']
        ssh_client = ssh.Client(src_server_ip,
                                CONF.validation.image_ssh_user,
                                pkey=self.keypair['private_key'],
                                proxy_client=proxy_client)

        # Destination VM
        if self.dest_has_fip:
            dest_server = self._create_server(network=self._dest_network)
        else:
            dest_server = self._create_server(create_floating_ip=False,
                                              network=self._dest_network)

        # Check connectivity
        self.check_remote_connectivity(
            ssh_client,
            dest_server['port']['fixed_ips'][0]['ip_address'],
            servers=[src_server, dest_server])
        if self.dest_has_fip:
            self.check_remote_connectivity(
                ssh_client,
                dest_server['fip']['floating_ip_address'],
                servers=[src_server, dest_server])
    def test_dns_domain_and_name(self):
        """Test the ability to ping a VM's hostname from another VM.

        1) Create two VMs on the same network, giving each a name
        2) SSH in to the first VM:
          2.1) ping the other VM's internal IP
          2.2) ping the other VM's hostname
        """
        network = self.create_network(dns_domain='starwars.')
        self.setup_network_and_server(network=network, server_name='luke')
        self.create_pingable_secgroup_rule(
            secgroup_id=self.security_groups[-1]['id'])
        self.check_connectivity(self.fip['floating_ip_address'],
                                CONF.validation.image_ssh_user,
                                self.keypair['private_key'])

        leia = self.create_server(
            flavor_ref=CONF.compute.flavor_ref,
            image_ref=CONF.compute.image_ref,
            key_name=self.keypair['name'],
            networks=[{'uuid': self.network['id']}],
            security_groups=[
                {'name': self.security_groups[-1]['name']}],
            name='leia')
        self.wait_for_server_active(leia['server'])

        ssh_client = ssh.Client(
            self.fip['floating_ip_address'],
            CONF.validation.image_ssh_user,
            pkey=self.keypair['private_key'])

        self.assertIn('luke', ssh_client.exec_command('hostname'))

        leia_port = self.client.list_ports(
            network_id=self.network['id'],
            device_id=leia['server']['id'])['ports'][0]

        # Ping with a higher timeout because spawning 2 VMs in some
        # environment can put significant load on the deployment, resulting
        # in very long boot times.
        self.check_remote_connectivity(
            ssh_client, leia_port['fixed_ips'][0]['ip_address'],
            timeout=CONF.validation.ping_timeout * 10,
            servers=[self.server, leia])

        resolv_conf = ssh_client.exec_command('cat /etc/resolv.conf')
        self.assertIn('openstackgate.local', resolv_conf)
        self.assertNotIn('starwars', resolv_conf)

        self.check_remote_connectivity(ssh_client, 'leia',
                                       servers=[self.server, leia])
        self.check_remote_connectivity(ssh_client, 'leia.openstackgate.local',
                                       servers=[self.server, leia])
Exemple #19
0
 def _prepare_receiver(self, server, mcast_address):
     check_script = get_receiver_script(
         group=mcast_address,
         port=self.multicast_port,
         hello_message=self.hello_message,
         ack_message=server['id'],
         result_file=self.receiver_output_file)
     ssh_client = ssh.Client(server['fip']['floating_ip_address'],
                             self.username,
                             pkey=self.keypair['private_key'])
     self._check_cmd_installed_on_server(ssh_client, server, PYTHON3_BIN)
     server['ssh_client'].execute_script(
         'echo "%s" > /tmp/multicast_traffic_receiver.py' % check_script)
Exemple #20
0
 def _prepare_unregistered(self, server, mcast_address):
     ssh_client = ssh.Client(server['fip']['floating_ip_address'],
                             self.username,
                             pkey=self.keypair['private_key'])
     ip_command = ip.IPCommand(ssh_client=ssh_client)
     addresses = ip_command.list_addresses(port=server['port'])
     port_iface = ip.get_port_device_name(addresses, server['port'])
     check_script = get_unregistered_script(
         interface=port_iface,
         group=mcast_address,
         result_file=self.unregistered_output_file)
     self._check_cmd_installed_on_server(ssh_client, server, 'tcpdump')
     server['ssh_client'].execute_script(
         'echo "%s" > /tmp/unregistered_traffic_receiver.sh' % check_script)
Exemple #21
0
    def _test_ipv6_hotplug(self, ra_mode, address_mode):
        ipv6_networks = [self.create_network() for _ in range(2)]
        for net in ipv6_networks:
            subnet = self.create_subnet(
                network=net, ip_version=6,
                ipv6_ra_mode=ra_mode, ipv6_address_mode=address_mode)
            self.create_router_interface(self.router['id'], subnet['id'])

        server_kwargs = {
            'flavor_ref': CONF.compute.flavor_ref,
            'image_ref': CONF.compute.image_ref,
            'key_name': self.keypair['name'],
            'networks': [
                {'uuid': self.network['id']},
                {'uuid': ipv6_networks[0]['id']}],
            'security_groups': [{'name': self.secgroup['name']}],
        }
        vm = self.create_server(**server_kwargs)['server']
        self.wait_for_server_active(vm)
        self.wait_for_guest_os_ready(vm)
        ipv4_port = self.client.list_ports(
            network_id=self.network['id'],
            device_id=vm['id'])['ports'][0]
        fip = self.create_floatingip(port=ipv4_port)
        ssh_client = ssh.Client(
            fip['floating_ip_address'], CONF.validation.image_ssh_user,
            pkey=self.keypair['private_key'])

        ipv6_port = self.client.list_ports(
            network_id=ipv6_networks[0]['id'],
            device_id=vm['id'])['ports'][0]
        self._test_ipv6_address_configured(ssh_client, vm, ipv6_port)

        # Now remove this port IPv6 port from the VM and attach new one
        self.delete_interface(vm['id'], ipv6_port['id'])

        # And plug VM to the second IPv6 network
        ipv6_port = self.create_port(ipv6_networks[1])
        # Add NetworkManager profile with ipv6 eui64 format to guest OS
        configure_eth_connection_profile_NM(ssh_client)
        self.create_interface(vm['id'], ipv6_port['id'])
        ip.wait_for_interface_status(
            self.os_primary.interfaces_client, vm['id'],
            ipv6_port['id'], lib_constants.PORT_STATUS_ACTIVE,
            ssh_client=ssh_client, mac_address=ipv6_port['mac_address'])
        self._test_ipv6_address_configured(ssh_client, vm, ipv6_port)
Exemple #22
0
    def test_extra_dhcp_opts(self):
        """This test case tests DHCP extra options configured for Neutron port.

        Test is checking just extra option "15" which is domain-name
        according to the RFC 2132:
        https://tools.ietf.org/html/rfc2132#section-5.3

        To test that option, there is spawned VM connected to the port with
        configured extra_dhcp_opts and test asserts that search domain name is
        configured inside VM in /etc/resolv.conf file
        """

        test_domain = "test.domain"
        extra_dhcp_opts = [
            {'opt_name': 'domain-name',
             'opt_value': '"%s"' % test_domain}]
        port = self.create_port(
            network=self.network, name=self.rand_name,
            security_groups=[self.security_group['id']],
            extra_dhcp_opts=extra_dhcp_opts)
        floating_ip = self.create_floatingip(port=port)

        server = self.create_server(
            flavor_ref=CONF.compute.flavor_ref,
            image_ref=CONF.compute.image_ref,
            key_name=self.keypair['name'],
            networks=[{'port': port['id']}])
        self.wait_for_server_active(server['server'])
        self.wait_for_guest_os_ready(server['server'])

        try:
            ssh_client = ssh.Client(
                floating_ip['floating_ip_address'],
                CONF.validation.image_ssh_user,
                pkey=self.keypair['private_key'])
            vm_resolv_conf = ssh_client.exec_command(
                "cat /etc/resolv.conf")
            self.assertIn(test_domain, vm_resolv_conf)
        except (lib_exc.SSHTimeout,
                ssh_exc.AuthenticationException,
                AssertionError) as error:
            LOG.debug(error)
            self._log_console_output([server])
            self._log_local_network_status()
            raise
Exemple #23
0
 def _create_server(self):
     name = data_utils.rand_name("maclearning-server")
     server = self.create_server(flavor_ref=self.flavor_ref,
                                 image_ref=self.image_ref,
                                 key_name=self.keypair['name'],
                                 name=name,
                                 networks=[{
                                     'uuid': self.network['id']
                                 }],
                                 config_drive='True')['server']
     self.wait_for_server_active(server)
     self.wait_for_guest_os_ready(server)
     server['port'] = self.client.list_ports(
         network_id=self.network['id'], device_id=server['id'])['ports'][0]
     server['fip'] = self.create_floatingip(port=server['port'])
     server['ssh_client'] = ssh.Client(server['fip']['floating_ip_address'],
                                       self.username,
                                       pkey=self.keypair['private_key'])
     return server
Exemple #24
0
 def check_connectivity(self,
                        host,
                        ssh_user,
                        ssh_key,
                        servers=None,
                        ssh_timeout=None):
     # Set MTU on cirros VM for QOS
     ssh_client = ssh.Client(host,
                             ssh_user,
                             pkey=ssh_key,
                             timeout=ssh_timeout)
     try:
         ssh_client.test_connection_auth()
         ssh_client.exec_command("set -eu -o pipefail; PATH=$PATH:/sbin; "
                                 "sudo ip link set dev eth0 mtu 1400")
     except tempest_exc.SSHTimeout as ssh_e:
         LOG.debug(ssh_e)
         self._log_console_output(servers)
         self._log_local_network_status()
         raise
Exemple #25
0
 def check_connectivity(self,
                        host,
                        ssh_user=None,
                        ssh_key=None,
                        servers=None,
                        ssh_timeout=None,
                        ssh_client=None):
     # Either ssh_client or ssh_user+ssh_key is mandatory.
     if ssh_client is None:
         ssh_client = ssh.Client(host,
                                 ssh_user,
                                 pkey=ssh_key,
                                 timeout=ssh_timeout)
     try:
         ssh_client.test_connection_auth()
     except (lib_exc.SSHTimeout, ssh_exc.AuthenticationException) as ssh_e:
         LOG.debug(ssh_e)
         self._log_console_output(servers)
         self._log_local_network_status()
         raise
Exemple #26
0
 def _create_server(self):
     name = data_utils.rand_name("multicast-server")
     server = self.create_server(flavor_ref=self.flavor_ref,
                                 image_ref=self.image_ref,
                                 key_name=self.keypair['name'],
                                 name=name,
                                 networks=[{
                                     'uuid': self.network['id']
                                 }],
                                 security_groups=[{
                                     'name':
                                     self.secgroup['security_group']['name']
                                 }])['server']
     self.wait_for_server_active(server)
     port = self.client.list_ports(network_id=self.network['id'],
                                   device_id=server['id'])['ports'][0]
     server['fip'] = self.create_floatingip(port=port)
     server['ssh_client'] = ssh.Client(server['fip']['floating_ip_address'],
                                       self.username,
                                       pkey=self.keypair['private_key'])
     self._check_cmd_installed_on_server(server['ssh_client'], server['id'],
                                         PYTHON3_BIN)
     return server
Exemple #27
0
    def test_connectivity_router_east_west_traffic(self):
        """This case is intended to test router east west taffic

        The case can be used in various scenarios: legacy/distributed router,
        same/different host.
        """
        net_1 = self.create_network()
        net_2 = self.create_network()
        subnet_1 = self.create_subnet(net_1, cidr="10.10.1.0/24")
        subnet_2 = self.create_subnet(net_2, cidr="10.10.2.0/24")

        router = self.create_router(
            router_name=data_utils.rand_name("east_west_traffic_router"),
            admin_state_up=True,
            external_network_id=CONF.network.public_network_id)
        self._wait_for_router_ha_active(router['id'])

        internal_port_1 = self.create_port(
            net_1, security_groups=[self.secgroup['id']])
        internal_port_2 = self.create_port(
            net_2, security_groups=[self.secgroup['id']])

        self.create_router_interface(router['id'], subnet_1['id'])
        self.create_router_interface(router['id'], subnet_2['id'])

        servers = self._create_servers(internal_port_1, internal_port_2)

        fip = self.create_and_associate_floatingip(
            internal_port_1['id'])
        sshclient = ssh.Client(
            fip['floating_ip_address'], CONF.validation.image_ssh_user,
            pkey=self.keypair['private_key'])

        self.check_remote_connectivity(
            sshclient, internal_port_2['fixed_ips'][0]['ip_address'],
            ping_count=10, servers=servers)
Exemple #28
0
    def test_connectivity_dvr_and_no_dvr_routers_in_same_subnet(self):
        """This test case tests connectivity between vm and 2 routers.

        Subnet is connected to dvr and non-dvr routers in the same time, test
        ensures that connectivity from VM to both routers is working.

        Test scenario: (NOTE: 10.1.0.0/24 private CIDR is used as an example)
        +----------------+                  +------------+
        | Non-dvr router |                  | DVR router |
        |                |                  |            |
        |    10.1.0.1    |                  |  10.1.0.x  |
        +-------+--------+                  +-----+------+
                |                                 |
                |         10.1.0.0/24             |
                +----------------+----------------+
                                 |
                               +-+-+
                               |VM |
                               +---+

        where:
        10.1.0.1 - is subnet's gateway IP address,
        10.1.0.x - is any other IP address taken from subnet's range

        Test ensures that both 10.1.0.1 and 10.1.0.x IP addresses are
        reachable from VM.
        """
        ext_network = self.client.show_network(self.external_network_id)
        for ext_subnetid in ext_network['network']['subnets']:
            ext_subnet = self.os_admin.network_client.show_subnet(ext_subnetid)
            ext_cidr = ext_subnet['subnet']['cidr']
            if ext_subnet['subnet']['ip_version'] == constants.IP_VERSION_4:
                break
        else:
            self.fail('No IPv4 subnet was found in external network %s' %
                      ext_network['network']['id'])

        subnet_cidr = ip_utils.find_valid_cidr(used_cidr=ext_cidr)
        gw_ip = netaddr.IPAddress(subnet_cidr.first + 1)

        network = self.create_network()
        subnet = self.create_subnet(
            network, cidr=str(subnet_cidr), gateway=str(gw_ip))

        non_dvr_router = self.create_router_by_client(
            tenant_id=self.client.tenant_id,
            is_admin=True,
            router_name=data_utils.rand_name("nondvr-2-routers-same-network"),
            admin_state_up=True,
            distributed=False)
        self.create_router_interface(non_dvr_router['id'], subnet['id'])

        dvr_router = self.create_router_by_client(
            tenant_id=self.client.tenant_id,
            is_admin=True,
            router_name=data_utils.rand_name("dvr-2-rotuers-same-network"),
            admin_state_up=True,
            distributed=True)
        dvr_router_port = self.create_port(network)
        self.client.add_router_interface_with_port_id(
            dvr_router['id'], dvr_router_port['id'])

        vm = self.create_server(
            flavor_ref=CONF.compute.flavor_ref,
            image_ref=CONF.compute.image_ref,
            key_name=self.keypair['name'],
            networks=[{'uuid': network['id']}],
            security_groups=[{'name': self.secgroup['name']}])
        self.wait_for_server_active(vm['server'])
        self.wait_for_guest_os_ready(vm['server'])

        vm_port = self.client.list_ports(
            network_id=network['id'], device_id=vm['server']['id'])['ports'][0]
        fip = self.create_and_associate_floatingip(vm_port['id'])

        sshclient = ssh.Client(
            fip['floating_ip_address'], CONF.validation.image_ssh_user,
            pkey=self.keypair['private_key'])

        self.check_remote_connectivity(
            sshclient, str(gw_ip), ping_count=10, servers=[vm])
        self.check_remote_connectivity(
            sshclient, dvr_router_port['fixed_ips'][0]['ip_address'],
            ping_count=10, servers=[vm])
 def _create_ssh_client(self, ip_addr):
     return ssh.Client(ip_addr,
                       CONF.validation.image_ssh_user,
                       pkey=self.keypair['private_key'])
 def _create_ssh_client(self):
     return ssh.Client(self.fip['floating_ip_address'],
                       CONF.validation.image_ssh_user,
                       pkey=self.keypair['private_key'])