Example #1
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(n_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)
Example #2
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(n_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))
Example #3
0
    def test_sync_segmentationIdAllocation(self):
        self.assertIsNone(mlnx_db.get_network_state(PHYS_NET,
                                                    VLAN_MIN - 1))
        self.assertFalse(mlnx_db.get_network_state(PHYS_NET,
                                                   VLAN_MIN).allocated)
        self.assertFalse(mlnx_db.get_network_state(PHYS_NET,
                                                   VLAN_MIN + 1).allocated)
        self.assertFalse(mlnx_db.get_network_state(PHYS_NET,
                                                   VLAN_MAX - 1).allocated)
        self.assertFalse(mlnx_db.get_network_state(PHYS_NET,
                                                   VLAN_MAX).allocated)
        self.assertIsNone(mlnx_db.get_network_state(PHYS_NET,
                                                    VLAN_MAX + 1))

        mlnx_db.sync_network_states(UPDATED_VLAN_RANGES)

        self.assertIsNone(mlnx_db.get_network_state(PHYS_NET,
                                                    VLAN_MIN + 5 - 1))
        self.assertFalse(mlnx_db.get_network_state(PHYS_NET,
                                                   VLAN_MIN + 5).allocated)
        self.assertFalse(mlnx_db.get_network_state(PHYS_NET,
                                                   VLAN_MIN + 5 + 1).allocated)
        self.assertFalse(mlnx_db.get_network_state(PHYS_NET,
                                                   VLAN_MAX + 5 - 1).allocated)
        self.assertFalse(mlnx_db.get_network_state(PHYS_NET,
                                                   VLAN_MAX + 5).allocated)
        self.assertIsNone(mlnx_db.get_network_state(PHYS_NET,
                                                    VLAN_MAX + 5 + 1))

        self.assertIsNone(mlnx_db.get_network_state(PHYS_NET_2,
                                                    VLAN_MIN + 20 - 1))
        self.assertFalse(mlnx_db.get_network_state(PHYS_NET_2,
                                                   VLAN_MIN + 20).allocated)
        self.assertFalse(
            mlnx_db.get_network_state(PHYS_NET_2,
                                      VLAN_MIN + 20 + 1).allocated)
        self.assertFalse(
            mlnx_db.get_network_state(PHYS_NET_2,
                                      VLAN_MAX + 20 - 1).allocated)
        self.assertFalse(mlnx_db.get_network_state(PHYS_NET_2,
                                                   VLAN_MAX + 20).allocated)
        self.assertIsNone(mlnx_db.get_network_state(PHYS_NET_2,
                                                    VLAN_MAX + 20 + 1))

        mlnx_db.sync_network_states(VLAN_RANGES)

        self.assertIsNone(mlnx_db.get_network_state(PHYS_NET,
                                                    VLAN_MIN - 1))
        self.assertFalse(mlnx_db.get_network_state(PHYS_NET,
                                                   VLAN_MIN).allocated)
        self.assertFalse(mlnx_db.get_network_state(PHYS_NET,
                                                   VLAN_MIN + 1).allocated)
        self.assertFalse(mlnx_db.get_network_state(PHYS_NET,
                                                   VLAN_MAX - 1).allocated)
        self.assertFalse(mlnx_db.get_network_state(PHYS_NET,
                                                   VLAN_MAX).allocated)
        self.assertIsNone(mlnx_db.get_network_state(PHYS_NET,
                                                    VLAN_MAX + 1))

        self.assertIsNone(mlnx_db.get_network_state(PHYS_NET_2,
                                                    VLAN_MIN + 20))
        self.assertIsNone(mlnx_db.get_network_state(PHYS_NET_2,
                                                    VLAN_MAX + 20))
Example #4
0
    def test_sync_segmentationIdAllocation(self):
        self.assertIsNone(mlnx_db.get_network_state(PHYS_NET, VLAN_MIN - 1))
        self.assertFalse(
            mlnx_db.get_network_state(PHYS_NET, VLAN_MIN).allocated)
        self.assertFalse(
            mlnx_db.get_network_state(PHYS_NET, VLAN_MIN + 1).allocated)
        self.assertFalse(
            mlnx_db.get_network_state(PHYS_NET, VLAN_MAX - 1).allocated)
        self.assertFalse(
            mlnx_db.get_network_state(PHYS_NET, VLAN_MAX).allocated)
        self.assertIsNone(mlnx_db.get_network_state(PHYS_NET, VLAN_MAX + 1))

        mlnx_db.sync_network_states(UPDATED_VLAN_RANGES)

        self.assertIsNone(mlnx_db.get_network_state(PHYS_NET,
                                                    VLAN_MIN + 5 - 1))
        self.assertFalse(
            mlnx_db.get_network_state(PHYS_NET, VLAN_MIN + 5).allocated)
        self.assertFalse(
            mlnx_db.get_network_state(PHYS_NET, VLAN_MIN + 5 + 1).allocated)
        self.assertFalse(
            mlnx_db.get_network_state(PHYS_NET, VLAN_MAX + 5 - 1).allocated)
        self.assertFalse(
            mlnx_db.get_network_state(PHYS_NET, VLAN_MAX + 5).allocated)
        self.assertIsNone(mlnx_db.get_network_state(PHYS_NET,
                                                    VLAN_MAX + 5 + 1))

        self.assertIsNone(
            mlnx_db.get_network_state(PHYS_NET_2, VLAN_MIN + 20 - 1))
        self.assertFalse(
            mlnx_db.get_network_state(PHYS_NET_2, VLAN_MIN + 20).allocated)
        self.assertFalse(
            mlnx_db.get_network_state(PHYS_NET_2, VLAN_MIN + 20 + 1).allocated)
        self.assertFalse(
            mlnx_db.get_network_state(PHYS_NET_2, VLAN_MAX + 20 - 1).allocated)
        self.assertFalse(
            mlnx_db.get_network_state(PHYS_NET_2, VLAN_MAX + 20).allocated)
        self.assertIsNone(
            mlnx_db.get_network_state(PHYS_NET_2, VLAN_MAX + 20 + 1))

        mlnx_db.sync_network_states(VLAN_RANGES)

        self.assertIsNone(mlnx_db.get_network_state(PHYS_NET, VLAN_MIN - 1))
        self.assertFalse(
            mlnx_db.get_network_state(PHYS_NET, VLAN_MIN).allocated)
        self.assertFalse(
            mlnx_db.get_network_state(PHYS_NET, VLAN_MIN + 1).allocated)
        self.assertFalse(
            mlnx_db.get_network_state(PHYS_NET, VLAN_MAX - 1).allocated)
        self.assertFalse(
            mlnx_db.get_network_state(PHYS_NET, VLAN_MAX).allocated)
        self.assertIsNone(mlnx_db.get_network_state(PHYS_NET, VLAN_MAX + 1))

        self.assertIsNone(mlnx_db.get_network_state(PHYS_NET_2, VLAN_MIN + 20))
        self.assertIsNone(mlnx_db.get_network_state(PHYS_NET_2, VLAN_MAX + 20))