Ejemplo n.º 1
0
 def setup_fixture(self):
     for node in topology.list_openstack_nodes():
         network_namespaces = ip.list_network_namespaces(
             ignore_errors=True, ssh_client=node.ssh_client)
         if network_namespaces:
             self.network_namespace = network_namespaces[0]
             self.ssh_client = node.ssh_client
Ejemplo n.º 2
0
 def setup_fixture(self):
     for node in topology.list_openstack_nodes():
         network_namespaces = ip.list_network_namespaces(
             ssh_client=node.ssh_client)
         if network_namespaces:
             self.network_namespace = network_namespaces.first
             self.ssh_client = node.ssh_client
Ejemplo n.º 3
0
 def test_list_namespaces(self, **execute_params):
     if not os.path.isfile('/bin/ip'):
         self.skipTest("'bin/ip' command not found")
     namespaces = ip.list_network_namespaces(**execute_params)
     self.assertIsInstance(namespaces, list)
     for namespace in namespaces:
         self.assertIsInstance(namespace, str)
         self.test_list_ip_addresses(network_namespace=namespace)
Ejemplo n.º 4
0
 def test_network_namespaces(self):
     for node in self.topology.nodes:
         namespaces_ips = {}
         namespaces = ip.list_network_namespaces(ssh_client=node.ssh_client)
         for namespace in namespaces:
             ips = ip.list_ip_addresses(ssh_client=node.ssh_client,
                                        network_namespace=namespace)
             other_ips = namespaces_ips.setdefault(namespace, ips)
             if ips is not other_ips:
                 tobiko.fail(f"Duplicate network namespace {namespace} in "
                             f"node {node.name}: {other_ips}, {ips}")
Ejemplo n.º 5
0
 def test_network_namespaces(self):
     for node in self.topology.nodes:
         namespaces_ips = {}
         namespaces = ip.list_network_namespaces(ssh_client=node.ssh_client)
         for namespace in namespaces:
             ips = ip.list_ip_addresses(ssh_client=node.ssh_client,
                                        network_namespace=namespace)
             other_ips = namespaces_ips.setdefault(namespace, ips)
             if ips is not other_ips:
                 tobiko.fail("Duplicate network namespace {!r} in node "
                             "{!r}: {!r}, {!r}", namespace, node.name,
                             other_ips, ips)
Ejemplo n.º 6
0
 def _get_router_ips_from_namespaces(self, hostname):
     agent_host = topology.get_openstack_node(hostname=hostname)
     router_namespaces = ["qrouter-%s" % self.router['id']]
     if self.router.get('distributed'):
         router_namespaces.append("snat-%s" % self.router['id'])
     host_namespaces = ip.list_network_namespaces(
         ssh_client=agent_host.ssh_client)
     ips = []
     for router_namespace in router_namespaces:
         self.assertIn(router_namespace, host_namespaces)
         ips += ip.list_ip_addresses(
             scope='global', network_namespace=router_namespace,
             ssh_client=agent_host.ssh_client)
     return ips
Ejemplo n.º 7
0
    def test_router_not_created_on_compute_if_no_instance_connected(self):
        '''Test that no router namespace is created for DVR on compute node

        Namespace should be only created if there is VM with router that is set
        as a default gateway. Need to verify that there will be no namespace
        created on the compute node where VM is connected to the external
        network. The same network is used as the default gateway for the router
        '''

        router_namespace = f'qrouter-{self.router_stack.gateway_details["id"]}'
        cirros_hypervisor = topology.get_openstack_node(
                hostname=self.server_stack.hypervisor_host)
        namespaces = ip.list_network_namespaces(
            ssh_client=cirros_hypervisor.ssh_client)
        self.assertNotIn(router_namespace, namespaces)
Ejemplo n.º 8
0
 def _check_routers_namespace_on_host(self, hostname, state="master"):
     router_namespace = "qrouter-%s" % self.router['id']
     agent_host = topology.get_openstack_node(hostname=hostname)
     namespaces = ip.list_network_namespaces(
         ssh_client=agent_host.ssh_client)
     self.assertIn(router_namespace, namespaces)
     namespace_ips = ip.list_ip_addresses(
         scope='global',
         network_namespace=router_namespace,
         ssh_client=agent_host.ssh_client)
     missing_ips = set(self.router_ips) - set(namespace_ips)
     if state == "master":
         self.assertFalse(missing_ips)
     else:
         self.assertTrue(missing_ips)
Ejemplo n.º 9
0
def test_ovs_namespaces_are_absent(
        group: typing.Pattern[str] = OPENSTACK_NODE_GROUP,
        namespace: typing.Pattern[str] = OVS_NAMESPACE):
    nodes = topology.list_openstack_nodes(group=group)

    namespaces: typing.Dict[str,
                            typing.List[str]] = (collections.defaultdict(list))
    for node in nodes:
        for node_namespace in ip.list_network_namespaces(
                ssh_client=node.ssh_client, sudo=True):
            if namespace.match(node_namespace):
                namespaces[node.name].append(node_namespace)
    namespaces = dict(namespaces)

    test_case = tobiko.get_test_case()
    test_case.assertEqual(
        {}, dict(namespaces),
        f"OVS namespace(s) found on OpenStack nodes: {namespaces}")
Ejemplo n.º 10
0
 def test_list_namespaces(self, **execute_params):
     namespaces = ip.list_network_namespaces(**execute_params)
     self.assertIsInstance(namespaces, list)
     for namespace in namespaces:
         self.assertIsInstance(namespace, six.string_types)
         self.test_list_ip_addresses(network_namespace=namespace)