Exemple #1
0
    def test_vlan_pool(self):
        vlan_ids = set()
        for x in moves.xrange(VLAN_MIN, VLAN_MAX + 1):
            (physical_network, seg_type,
             vlan_id, m_ip) = n1kv_db_v2.reserve_vlan(self.session, self.net_p)
            self.assertEqual(physical_network, PHYS_NET)
            self.assertThat(vlan_id, matchers.GreaterThan(VLAN_MIN - 1))
            self.assertThat(vlan_id, matchers.LessThan(VLAN_MAX + 1))
            vlan_ids.add(vlan_id)

        self.assertRaises(n_exc.NoNetworkAvailable,
                          n1kv_db_v2.reserve_vlan,
                          self.session,
                          self.net_p)

        n1kv_db_v2.release_vlan(self.session, PHYS_NET, vlan_ids.pop())
        physical_network, seg_type, vlan_id, m_ip = (n1kv_db_v2.reserve_vlan(
                                                     self.session, self.net_p))
        self.assertEqual(physical_network, PHYS_NET)
        self.assertThat(vlan_id, matchers.GreaterThan(VLAN_MIN - 1))
        self.assertThat(vlan_id, matchers.LessThan(VLAN_MAX + 1))
        vlan_ids.add(vlan_id)

        for vlan_id in vlan_ids:
            n1kv_db_v2.release_vlan(self.session, PHYS_NET, vlan_id)
Exemple #2
0
    def test_vlan_pool(self):
        vlan_ids = set()
        p = _create_test_network_profile_if_not_there(self.session)
        for x in xrange(VLAN_MIN, VLAN_MAX + 1):
            (physical_network, seg_type,
             vlan_id, m_ip) = n1kv_db_v2.reserve_vlan(self.session, p)
            self.assertEqual(physical_network, PHYS_NET)
            self.assertThat(vlan_id, matchers.GreaterThan(VLAN_MIN - 1))
            self.assertThat(vlan_id, matchers.LessThan(VLAN_MAX + 1))
            vlan_ids.add(vlan_id)

        self.assertRaises(q_exc.NoNetworkAvailable,
                          n1kv_db_v2.reserve_vlan,
                          self.session,
                          p)

        n1kv_db_v2.release_vlan(self.session, PHYS_NET, vlan_ids.pop(),
                                VLAN_RANGES)
        physical_network, seg_type, vlan_id, m_ip = (n1kv_db_v2.reserve_vlan(
                                                     self.session, p))
        self.assertEqual(physical_network, PHYS_NET)
        self.assertThat(vlan_id, matchers.GreaterThan(VLAN_MIN - 1))
        self.assertThat(vlan_id, matchers.LessThan(VLAN_MAX + 1))
        vlan_ids.add(vlan_id)

        for vlan_id in vlan_ids:
            n1kv_db_v2.release_vlan(self.session, PHYS_NET, vlan_id,
                                    VLAN_RANGES)
Exemple #3
0
    def test_vlan_pool(self):
        vlan_ids = set()
        p = _create_test_network_profile_if_not_there(self.session)
        for x in xrange(VLAN_MIN, VLAN_MAX + 1):
            (physical_network, seg_type, vlan_id,
             m_ip) = n1kv_db_v2.reserve_vlan(self.session, p)
            self.assertEqual(physical_network, PHYS_NET)
            self.assertThat(vlan_id, matchers.GreaterThan(VLAN_MIN - 1))
            self.assertThat(vlan_id, matchers.LessThan(VLAN_MAX + 1))
            vlan_ids.add(vlan_id)

        self.assertRaises(q_exc.NoNetworkAvailable, n1kv_db_v2.reserve_vlan,
                          self.session, p)

        n1kv_db_v2.release_vlan(self.session, PHYS_NET, vlan_ids.pop(),
                                VLAN_RANGES)
        physical_network, seg_type, vlan_id, m_ip = (n1kv_db_v2.reserve_vlan(
            self.session, p))
        self.assertEqual(physical_network, PHYS_NET)
        self.assertThat(vlan_id, matchers.GreaterThan(VLAN_MIN - 1))
        self.assertThat(vlan_id, matchers.LessThan(VLAN_MAX + 1))
        vlan_ids.add(vlan_id)

        for vlan_id in vlan_ids:
            n1kv_db_v2.release_vlan(self.session, PHYS_NET, vlan_id,
                                    VLAN_RANGES)
    def test_vlan_pool(self):
        vlan_ids = set()
        for x in moves.xrange(VLAN_MIN, VLAN_MAX + 1):
            (physical_network, seg_type,
             vlan_id, m_ip) = n1kv_db_v2.reserve_vlan(self.session, self.net_p)
            self.assertEqual(physical_network, PHYS_NET)
            self.assertThat(vlan_id, matchers.GreaterThan(VLAN_MIN - 1))
            self.assertThat(vlan_id, matchers.LessThan(VLAN_MAX + 1))
            vlan_ids.add(vlan_id)

        self.assertRaises(n_exc.NoNetworkAvailable,
                          n1kv_db_v2.reserve_vlan,
                          self.session,
                          self.net_p)

        n1kv_db_v2.release_vlan(self.session, PHYS_NET, vlan_ids.pop())
        physical_network, seg_type, vlan_id, m_ip = (n1kv_db_v2.reserve_vlan(
                                                     self.session, self.net_p))
        self.assertEqual(physical_network, PHYS_NET)
        self.assertThat(vlan_id, matchers.GreaterThan(VLAN_MIN - 1))
        self.assertThat(vlan_id, matchers.LessThan(VLAN_MAX + 1))
        vlan_ids.add(vlan_id)

        for vlan_id in vlan_ids:
            n1kv_db_v2.release_vlan(self.session, PHYS_NET, vlan_id)
Exemple #5
0
    def test_specific_vlan_inside_pool(self):
        vlan_id = VLAN_MIN + 5
        self.assertFalse(n1kv_db_v2.get_vlan_allocation(self.session, PHYS_NET, vlan_id).allocated)
        n1kv_db_v2.reserve_specific_vlan(self.session, PHYS_NET, vlan_id)
        self.assertTrue(n1kv_db_v2.get_vlan_allocation(self.session, PHYS_NET, vlan_id).allocated)

        self.assertRaises(n_exc.VlanIdInUse, n1kv_db_v2.reserve_specific_vlan, self.session, PHYS_NET, vlan_id)

        n1kv_db_v2.release_vlan(self.session, PHYS_NET, vlan_id)
        self.assertFalse(n1kv_db_v2.get_vlan_allocation(self.session, PHYS_NET, vlan_id).allocated)
Exemple #6
0
    def test_specific_vlan_outside_pool(self):
        vlan_id = VLAN_MAX + 5
        self.assertRaises(c_exc.VlanIDNotFound, n1kv_db_v2.get_vlan_allocation,
                          self.session, PHYS_NET, vlan_id)
        n1kv_db_v2.reserve_specific_vlan(self.session, PHYS_NET, vlan_id)
        self.assertTrue(
            n1kv_db_v2.get_vlan_allocation(self.session, PHYS_NET,
                                           vlan_id).allocated)

        self.assertRaises(q_exc.VlanIdInUse, n1kv_db_v2.reserve_specific_vlan,
                          self.session, PHYS_NET, vlan_id)

        n1kv_db_v2.release_vlan(self.session, PHYS_NET, vlan_id, VLAN_RANGES)
        self.assertRaises(c_exc.VlanIDNotFound, n1kv_db_v2.get_vlan_allocation,
                          self.session, PHYS_NET, vlan_id)
Exemple #7
0
    def test_specific_vlan_inside_pool(self):
        vlan_id = VLAN_MIN + 5
        self.assertFalse(
            n1kv_db_v2.get_vlan_allocation(self.session, PHYS_NET,
                                           vlan_id).allocated)
        n1kv_db_v2.reserve_specific_vlan(self.session, PHYS_NET, vlan_id)
        self.assertTrue(
            n1kv_db_v2.get_vlan_allocation(self.session, PHYS_NET,
                                           vlan_id).allocated)

        self.assertRaises(n_exc.VlanIdInUse, n1kv_db_v2.reserve_specific_vlan,
                          self.session, PHYS_NET, vlan_id)

        n1kv_db_v2.release_vlan(self.session, PHYS_NET, vlan_id)
        self.assertFalse(
            n1kv_db_v2.get_vlan_allocation(self.session, PHYS_NET,
                                           vlan_id).allocated)
Exemple #8
0
    def test_specific_vlan_outside_pool(self):
        vlan_id = VLAN_MAX + 5
        self.assertRaises(c_exc.VlanIDNotFound,
                          n1kv_db_v2.get_vlan_allocation,
                          self.session,
                          PHYS_NET,
                          vlan_id)
        n1kv_db_v2.reserve_specific_vlan(self.session, PHYS_NET, vlan_id)
        self.assertTrue(n1kv_db_v2.get_vlan_allocation(self.session, PHYS_NET,
                                                       vlan_id).allocated)

        self.assertRaises(q_exc.VlanIdInUse,
                          n1kv_db_v2.reserve_specific_vlan,
                          self.session,
                          PHYS_NET,
                          vlan_id)

        n1kv_db_v2.release_vlan(self.session, PHYS_NET, vlan_id, VLAN_RANGES)
        self.assertRaises(c_exc.VlanIDNotFound,
                          n1kv_db_v2.get_vlan_allocation,
                          self.session,
                          PHYS_NET,
                          vlan_id)
Exemple #9
0
    def delete_network(self, context, id):
        """
        Delete a network.

        :param context: neutron api request context
        :param id: UUID representing the network to delete
        """
        session = context.session
        with session.begin(subtransactions=True):
            binding = n1kv_db_v2.get_network_binding(session, id)
            network = self.get_network(context, id)
            super(N1kvNeutronPluginV2, self).delete_network(context, id)
            if binding.network_type == c_const.NETWORK_TYPE_VXLAN:
                n1kv_db_v2.release_vxlan(session, binding.segmentation_id,
                                         self.vxlan_id_ranges)
            elif binding.network_type == c_const.NETWORK_TYPE_VLAN:
                n1kv_db_v2.release_vlan(session, binding.physical_network,
                                        binding.segmentation_id,
                                        self.network_vlan_ranges)
                # the network_binding record is deleted via cascade from
                # the network record, so explicit removal is not necessary
        if self.agent_vsm:
            self._send_delete_network_request(network)
        LOG.debug(_("Deleted network: %s"), id)
    def delete_network(self, context, id):
        """
        Delete a network.

        :param context: neutron api request context
        :param id: UUID representing the network to delete
        """
        session = context.session
        with session.begin(subtransactions=True):
            binding = n1kv_db_v2.get_network_binding(session, id)
            network = self.get_network(context, id)
            super(N1kvNeutronPluginV2, self).delete_network(context, id)
            if binding.network_type == c_const.NETWORK_TYPE_VXLAN:
                n1kv_db_v2.release_vxlan(session, binding.segmentation_id,
                                         self.vxlan_id_ranges)
            elif binding.network_type == c_const.NETWORK_TYPE_VLAN:
                n1kv_db_v2.release_vlan(session, binding.physical_network,
                                        binding.segmentation_id,
                                        self.network_vlan_ranges)
                # the network_binding record is deleted via cascade from
                # the network record, so explicit removal is not necessary
        if self.agent_vsm:
            self._send_delete_network_request(network)
        LOG.debug(_("Deleted network: %s"), id)