Пример #1
0
    def test_specific_vlan_id_outside_pool(self):
        vlan_id = VLAN_MAX + 5
        self.assertIsNone(ovs_db_v2.get_vlan_id(vlan_id))
        ovs_db_v2.reserve_specific_vlan_id(vlan_id)
        self.assertTrue(ovs_db_v2.get_vlan_id(vlan_id).vlan_used)

        with self.assertRaises(q_exc.VlanIdInUse):
            ovs_db_v2.reserve_specific_vlan_id(vlan_id)

        ovs_db_v2.release_vlan_id(vlan_id)
        self.assertIsNone(ovs_db_v2.get_vlan_id(vlan_id))
Пример #2
0
    def test_specific_vlan_id_inside_pool(self):
        session = db.get_session()
        vlan_id = VLAN_MIN + 5
        self.assertFalse(ovs_db_v2.get_vlan_id(vlan_id).vlan_used)
        ovs_db_v2.reserve_specific_vlan_id(vlan_id, session)
        self.assertTrue(ovs_db_v2.get_vlan_id(vlan_id).vlan_used)

        with self.assertRaises(q_exc.VlanIdInUse):
            ovs_db_v2.reserve_specific_vlan_id(vlan_id, session)

        ovs_db_v2.release_vlan_id(vlan_id)
        self.assertFalse(ovs_db_v2.get_vlan_id(vlan_id).vlan_used)
Пример #3
0
    def test_update_vlan_id_pool(self):
        self.assertIsNone(ovs_db_v2.get_vlan_id(VLAN_MIN - 1))
        self.assertFalse(ovs_db_v2.get_vlan_id(VLAN_MIN).vlan_used)
        self.assertFalse(ovs_db_v2.get_vlan_id(VLAN_MIN + 1).vlan_used)
        self.assertFalse(ovs_db_v2.get_vlan_id(VLAN_MAX).vlan_used)
        self.assertIsNone(ovs_db_v2.get_vlan_id(VLAN_MAX + 1))

        cfg.CONF.set_override('vlan_min', VLAN_MIN + 5, group='OVS')
        cfg.CONF.set_override('vlan_max', VLAN_MAX + 5, group='OVS')
        ovs_db_v2.update_vlan_id_pool()

        self.assertIsNone(ovs_db_v2.get_vlan_id(VLAN_MIN + 5 - 1))
        self.assertFalse(ovs_db_v2.get_vlan_id(VLAN_MIN + 5).vlan_used)
        self.assertFalse(ovs_db_v2.get_vlan_id(VLAN_MIN + 5 + 1).vlan_used)
        self.assertFalse(ovs_db_v2.get_vlan_id(VLAN_MAX + 5).vlan_used)
        self.assertIsNone(ovs_db_v2.get_vlan_id(VLAN_MAX + 5 + 1))