コード例 #1
0
    def test_get_parent_port_by_host_ip_multiple(self):
        cls = nested_vif.NestedPodVIFDriver
        m_driver = mock.Mock(
            spec=cls, nodes_subnets_driver=node_subnets.ConfigNodesSubnets())
        os_net = self.useFixture(k_fix.MockNetworkClient()).client

        node_subnet_id1 = 'node_subnet_id1'
        node_subnet_id2 = 'node_subnet_id2'
        node_subnet_id3 = 'node_subnet_id3'
        oslo_cfg.CONF.set_override('worker_nodes_subnets',
                                   [node_subnet_id3, node_subnet_id2],
                                   group='pod_vif_nested')

        node_fixed_ip = mock.sentinel.node_fixed_ip

        ports = [
            mock.Mock(fixed_ips=[{'subnet_id': node_subnet_id1}]),
            mock.Mock(fixed_ips=[{'subnet_id': node_subnet_id2}]),
        ]
        os_net.ports.return_value = (p for p in ports)

        self.assertEqual(ports[1], cls._get_parent_port_by_host_ip(
            m_driver, node_fixed_ip))
        fixed_ips = ['ip_address=%s' % str(node_fixed_ip)]
        os_net.ports.assert_called_with(fixed_ips=fixed_ips)
コード例 #2
0
    def test_get_project_not_set(self):
        cfg.CONF.set_override('worker_nodes_subnets',
                              None,
                              group='pod_vif_nested')
        driver = node_subnets.ConfigNodesSubnets()

        self.assertEqual([], driver.get_nodes_subnets())
コード例 #3
0
    def test_get_nodes_subnets_alias(self):
        subnet = 'subnet1'
        cfg.CONF.set_override('worker_nodes_subnet',
                              subnet,
                              group='pod_vif_nested')
        driver = node_subnets.ConfigNodesSubnets()

        self.assertEqual([subnet], driver.get_nodes_subnets())
コード例 #4
0
    def test_get_nodes_subnets(self):
        subnets = ['subnet1', 'subnet2']
        cfg.CONF.set_override('worker_nodes_subnets',
                              subnets,
                              group='pod_vif_nested')
        driver = node_subnets.ConfigNodesSubnets()

        self.assertEqual(subnets, driver.get_nodes_subnets())
コード例 #5
0
    def test_get_project_not_set_raise(self):
        cfg.CONF.set_override('worker_nodes_subnets',
                              None,
                              group='pod_vif_nested')
        driver = node_subnets.ConfigNodesSubnets()

        self.assertRaises(cfg.RequiredOptError,
                          driver.get_nodes_subnets,
                          raise_on_empty=True)
コード例 #6
0
 def test_get_parent_port_by_host_ip_subnet_id_not_configured(self):
     cls = nested_vif.NestedPodVIFDriver
     m_driver = mock.Mock(
         spec=cls, nodes_subnets_driver=node_subnets.ConfigNodesSubnets())
     self.useFixture(k_fix.MockNetworkClient()).client
     oslo_cfg.CONF.set_override('worker_nodes_subnets',
                                '',
                                group='pod_vif_nested')
     node_fixed_ip = mock.sentinel.node_fixed_ip
     self.assertRaises(oslo_cfg.RequiredOptError,
                       cls._get_parent_port_by_host_ip,
                       m_driver, node_fixed_ip)
コード例 #7
0
    def test_get_parent_port_by_host_ip_trunk_not_found(self):
        cls = nested_vif.NestedPodVIFDriver
        m_driver = mock.Mock(
            spec=cls, nodes_subnets_driver=node_subnets.ConfigNodesSubnets())
        os_net = self.useFixture(k_fix.MockNetworkClient()).client

        node_subnet_id = 'node_subnet_id'

        oslo_cfg.CONF.set_override('worker_nodes_subnets',
                                   [node_subnet_id],
                                   group='pod_vif_nested')

        node_fixed_ip = mock.sentinel.node_fixed_ip

        ports = (p for p in [])
        os_net.ports.return_value = ports

        self.assertRaises(kl_exc.NoResourceException,
                          cls._get_parent_port_by_host_ip, m_driver,
                          node_fixed_ip)
        fixed_ips = ['ip_address=%s' % str(node_fixed_ip)]
        os_net.ports.assert_called_once_with(fixed_ips=fixed_ips)
コード例 #8
0
 def test_delete_node(self):
     driver = node_subnets.ConfigNodesSubnets()
     self.assertFalse(driver.delete_node('node'))