예제 #1
0
    def test_specific_segmentationId_outside_pool(self):
        vlan_id = VLAN_MAX + 5
        self.assertIsNone(mlnx_db.get_network_state(PHYS_NET, vlan_id))
        mlnx_db.reserve_specific_network(self.session, PHYS_NET, vlan_id)
        self.assertTrue(mlnx_db.get_network_state(PHYS_NET, vlan_id).allocated)

        self.assertRaises(q_exc.VlanIdInUse, mlnx_db.reserve_specific_network,
                          self.session, PHYS_NET, vlan_id)

        mlnx_db.release_network(self.session, PHYS_NET, vlan_id, VLAN_RANGES)
        self.assertIsNone(mlnx_db.get_network_state(PHYS_NET, vlan_id))
    def test_specific_segmentationId_outside_pool(self):
        vlan_id = VLAN_MAX + 5
        self.assertIsNone(mlnx_db.get_network_state(PHYS_NET, vlan_id))
        mlnx_db.reserve_specific_network(self.session, PHYS_NET, vlan_id)
        self.assertTrue(mlnx_db.get_network_state(PHYS_NET,
                                                vlan_id).allocated)

        with self.assertRaises(q_exc.VlanIdInUse):
            mlnx_db.reserve_specific_network(self.session, PHYS_NET, vlan_id)

        mlnx_db.release_network(self.session, PHYS_NET, vlan_id, VLAN_RANGES)
        self.assertIsNone(mlnx_db.get_network_state(PHYS_NET, vlan_id))
예제 #3
0
 def delete_network(self, context, net_id):
     LOG.debug(_("delete network"))
     session = context.session
     with session.begin(subtransactions=True):
         binding = db.get_network_binding(session, net_id)
         super(MellanoxEswitchPlugin, self).delete_network(context, net_id)
         if binding.segmentation_id != constants.LOCAL_VLAN_ID:
             db.release_network(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
     self.notifier.network_delete(context, net_id)
 def delete_network(self, context, net_id):
     LOG.debug(_("delete network"))
     session = context.session
     with session.begin(subtransactions=True):
         binding = db.get_network_binding(session, net_id)
         result = super(MellanoxEswitchPlugin, self).delete_network(context,net_id)
         if binding.segmentation_id != constants.LOCAL_VLAN_ID:
             db.release_network(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_rpc:
         self.notifier.network_delete(self.rpc_context, net_id)
예제 #5
0
    def test_segmentationId_pool(self):
        vlan_ids = set()
        for x in xrange(VLAN_MIN, VLAN_MAX + 1):
            physical_network, vlan_id = mlnx_db.reserve_network(self.session)
            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, mlnx_db.reserve_network,
                          self.session)
        for vlan_id in vlan_ids:
            mlnx_db.release_network(self.session, PHYS_NET, vlan_id,
                                    VLAN_RANGES)
    def test_segmentationId_pool(self):
        vlan_ids = set()
        for x in xrange(VLAN_MIN, VLAN_MAX + 1):
            physical_network, vlan_id = mlnx_db.reserve_network(self.session)
            self.assertEqual(physical_network, PHYS_NET)
            self.assertGreaterEqual(vlan_id, VLAN_MIN)
            self.assertLessEqual(vlan_id, VLAN_MAX)
            vlan_ids.add(vlan_id)

        with self.assertRaises(q_exc.NoNetworkAvailable):
            physical_network, vlan_id = mlnx_db.reserve_network(self.session)

        for vlan_id in vlan_ids:
            mlnx_db.release_network(self.session, PHYS_NET, vlan_id, VLAN_RANGES)
예제 #7
0
    def test_segmentationId_pool(self):
        vlan_ids = set()
        for x in xrange(VLAN_MIN, VLAN_MAX + 1):
            physical_network, vlan_id = mlnx_db.reserve_network(self.session)
            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,
                          mlnx_db.reserve_network,
                          self.session)
        for vlan_id in vlan_ids:
            mlnx_db.release_network(self.session, PHYS_NET,
                                    vlan_id, VLAN_RANGES)
예제 #8
0
    def test_specific_segmentationId_inside_pool(self):
        vlan_id = VLAN_MIN + 5
        self.assertFalse(mlnx_db.get_network_state(PHYS_NET,
                                                   vlan_id).allocated)
        mlnx_db.reserve_specific_network(self.session, PHYS_NET, vlan_id)
        self.assertTrue(mlnx_db.get_network_state(PHYS_NET,
                                                  vlan_id).allocated)

        self.assertRaises(q_exc.VlanIdInUse,
                          mlnx_db.reserve_specific_network,
                          self.session,
                          PHYS_NET,
                          vlan_id)

        mlnx_db.release_network(self.session, PHYS_NET, vlan_id, VLAN_RANGES)
        self.assertFalse(mlnx_db.get_network_state(PHYS_NET,
                                                   vlan_id).allocated)