def teste_test_vlanids(self): """test vlanid methods""" l2network_db.create_vlanids() vlanids = l2network_db.get_all_vlanids() self.assertTrue(len(vlanids) > 0) vlanid = l2network_db.reserve_vlanid() used = l2network_db.is_vlanid_used(vlanid) self.assertTrue(used) used = l2network_db.release_vlanid(vlanid) self.assertFalse(used)
def test_vlanids(self): l2network_db.create_vlanids() vlanids = l2network_db.get_all_vlanids() self.assertGreater(len(vlanids), 0) vlanid = l2network_db.reserve_vlanid() used = l2network_db.is_vlanid_used(vlanid) self.assertTrue(used) used = l2network_db.release_vlanid(vlanid) self.assertFalse(used) self.teardown_vlanbinding() self.teardown_network()
def create_network(self, context, network): new_network = super(LinuxBridgePluginV2, self).create_network(context, network) try: vlan_id = cdb.reserve_vlanid() cdb.add_vlan_binding(vlan_id, new_network['id']) except: super(LinuxBridgePluginV2, self).delete_network(context, new_network['id']) raise return new_network
def create_network(self, context, network): net = super(LinuxBridgePluginV2, self).create_network(context, network) try: vlan_id = network["network"].get("provider:vlan_id") if vlan_id not in (None, attributes.ATTR_NOT_SPECIFIED): self._enforce_provider_set_auth(context, net) cdb.reserve_specific_vlanid(int(vlan_id)) else: vlan_id = cdb.reserve_vlanid() cdb.add_vlan_binding(vlan_id, net["id"]) self._extend_network_dict(context, net) except: super(LinuxBridgePluginV2, self).delete_network(context, net["id"]) raise return net
def _get_vlan_for_tenant(self, tenant_id, **kwargs): """Get an available VLAN ID""" try: return cdb.reserve_vlanid() except: raise Exception("Failed to reserve VLAN ID for network")