def test_specific_vlan_outside_pool(self): vlan_id = VLAN_MAX + 5 self.assertIsNone(ovs_db_v2.get_vlan_allocation(PHYS_NET, vlan_id)) ovs_db_v2.reserve_specific_vlan(self.session, PHYS_NET, vlan_id) self.assertTrue(ovs_db_v2.get_vlan_allocation(PHYS_NET, vlan_id).allocated) with self.assertRaises(q_exc.VlanIdInUse): ovs_db_v2.reserve_specific_vlan(self.session, PHYS_NET, vlan_id) ovs_db_v2.release_vlan(self.session, PHYS_NET, vlan_id, VLAN_RANGES) self.assertIsNone(ovs_db_v2.get_vlan_allocation(PHYS_NET, vlan_id))
def test_specific_vlan_inside_pool(self): vlan_id = VLAN_MIN + 5 self.assertFalse(ovs_db_v2.get_vlan_allocation(PHYS_NET, vlan_id).allocated) ovs_db_v2.reserve_specific_vlan(self.session, PHYS_NET, vlan_id) self.assertTrue(ovs_db_v2.get_vlan_allocation(PHYS_NET, vlan_id).allocated) with testtools.ExpectedException(q_exc.VlanIdInUse): ovs_db_v2.reserve_specific_vlan(self.session, PHYS_NET, vlan_id) ovs_db_v2.release_vlan(self.session, PHYS_NET, vlan_id, VLAN_RANGES) self.assertFalse(ovs_db_v2.get_vlan_allocation(PHYS_NET, vlan_id).allocated)
def test_specific_vlan_inside_pool(self): vlan_id = VLAN_MIN + 5 self.assertFalse( ovs_db_v2.get_vlan_allocation(PHYS_NET, vlan_id).allocated) ovs_db_v2.reserve_specific_vlan(self.session, PHYS_NET, vlan_id) self.assertTrue( ovs_db_v2.get_vlan_allocation(PHYS_NET, vlan_id).allocated) with testtools.ExpectedException(q_exc.VlanIdInUse): ovs_db_v2.reserve_specific_vlan(self.session, PHYS_NET, vlan_id) ovs_db_v2.release_vlan(self.session, PHYS_NET, vlan_id, VLAN_RANGES) self.assertFalse( ovs_db_v2.get_vlan_allocation(PHYS_NET, vlan_id).allocated)
def test_sync_vlan_allocations(self): self.assertIsNone(ovs_db_v2.get_vlan_allocation(PHYS_NET, VLAN_MIN - 1)) self.assertFalse(ovs_db_v2.get_vlan_allocation(PHYS_NET, VLAN_MIN).allocated) self.assertFalse(ovs_db_v2.get_vlan_allocation(PHYS_NET, VLAN_MIN + 1).allocated) self.assertFalse(ovs_db_v2.get_vlan_allocation(PHYS_NET, VLAN_MAX - 1).allocated) self.assertFalse(ovs_db_v2.get_vlan_allocation(PHYS_NET, VLAN_MAX).allocated) self.assertIsNone(ovs_db_v2.get_vlan_allocation(PHYS_NET, VLAN_MAX + 1)) ovs_db_v2.sync_vlan_allocations(UPDATED_VLAN_RANGES) self.assertIsNone(ovs_db_v2.get_vlan_allocation(PHYS_NET, VLAN_MIN + 5 - 1)) self.assertFalse(ovs_db_v2.get_vlan_allocation(PHYS_NET, VLAN_MIN + 5). allocated) self.assertFalse(ovs_db_v2.get_vlan_allocation(PHYS_NET, VLAN_MIN + 5 + 1). allocated) self.assertFalse(ovs_db_v2.get_vlan_allocation(PHYS_NET, VLAN_MAX + 5 - 1). allocated) self.assertFalse(ovs_db_v2.get_vlan_allocation(PHYS_NET, VLAN_MAX + 5). allocated) self.assertIsNone(ovs_db_v2.get_vlan_allocation(PHYS_NET, VLAN_MAX + 5 + 1)) self.assertIsNone(ovs_db_v2.get_vlan_allocation(PHYS_NET_2, VLAN_MIN + 20 - 1)) self.assertFalse(ovs_db_v2.get_vlan_allocation(PHYS_NET_2, VLAN_MIN + 20). allocated) self.assertFalse(ovs_db_v2.get_vlan_allocation(PHYS_NET_2, VLAN_MIN + 20 + 1). allocated) self.assertFalse(ovs_db_v2.get_vlan_allocation(PHYS_NET_2, VLAN_MAX + 20 - 1). allocated) self.assertFalse(ovs_db_v2.get_vlan_allocation(PHYS_NET_2, VLAN_MAX + 20). allocated) self.assertIsNone(ovs_db_v2.get_vlan_allocation(PHYS_NET_2, VLAN_MAX + 20 + 1)) ovs_db_v2.sync_vlan_allocations(VLAN_RANGES) self.assertIsNone(ovs_db_v2.get_vlan_allocation(PHYS_NET, VLAN_MIN - 1)) self.assertFalse(ovs_db_v2.get_vlan_allocation(PHYS_NET, VLAN_MIN).allocated) self.assertFalse(ovs_db_v2.get_vlan_allocation(PHYS_NET, VLAN_MIN + 1).allocated) self.assertFalse(ovs_db_v2.get_vlan_allocation(PHYS_NET, VLAN_MAX - 1).allocated) self.assertFalse(ovs_db_v2.get_vlan_allocation(PHYS_NET, VLAN_MAX).allocated) self.assertIsNone(ovs_db_v2.get_vlan_allocation(PHYS_NET, VLAN_MAX + 1)) self.assertIsNone(ovs_db_v2.get_vlan_allocation(PHYS_NET_2, VLAN_MIN + 20)) self.assertIsNone(ovs_db_v2.get_vlan_allocation(PHYS_NET_2, VLAN_MAX + 20))
def test_sync_vlan_allocations(self): self.assertIsNone(ovs_db_v2.get_vlan_allocation(PHYS_NET, VLAN_MIN - 1)) self.assertFalse(ovs_db_v2.get_vlan_allocation(PHYS_NET, VLAN_MIN).allocated) self.assertFalse(ovs_db_v2.get_vlan_allocation(PHYS_NET, VLAN_MIN + 1).allocated) self.assertFalse(ovs_db_v2.get_vlan_allocation(PHYS_NET, VLAN_MAX).allocated) self.assertIsNone(ovs_db_v2.get_vlan_allocation(PHYS_NET, VLAN_MAX + 1)) ovs_db_v2.sync_vlan_allocations(UPDATED_VLAN_RANGES) self.assertIsNone(ovs_db_v2.get_vlan_allocation(PHYS_NET, VLAN_MIN + 5 - 1)) self.assertFalse(ovs_db_v2.get_vlan_allocation(PHYS_NET, VLAN_MIN + 5). allocated) self.assertFalse(ovs_db_v2.get_vlan_allocation(PHYS_NET, VLAN_MIN + 5 + 1). allocated) self.assertFalse(ovs_db_v2.get_vlan_allocation(PHYS_NET, VLAN_MAX + 5 - 1). allocated) self.assertFalse(ovs_db_v2.get_vlan_allocation(PHYS_NET, VLAN_MAX + 5). allocated) self.assertIsNone(ovs_db_v2.get_vlan_allocation(PHYS_NET, VLAN_MAX + 5 + 1))