def release_segment(self, session, segment):
        physical_network = segment[api.PHYSICAL_NETWORK]
        vlan_id = segment[api.SEGMENTATION_ID]

        ranges = self.network_vlan_ranges.get(physical_network, [])
        inside = any(lo <= vlan_id <= hi for lo, hi in ranges)

        with session.begin(subtransactions=True):
            query = (session.query(VlanAllocation).
                     filter_by(physical_network=physical_network,
                               vlan_id=vlan_id))
            if inside:
                count = query.update({"allocated": False})
                if count:
                    LOG.debug("Releasing vlan %(vlan_id)s on physical "
                              "network %(physical_network)s to pool",
                              {'vlan_id': vlan_id,
                               'physical_network': physical_network})
            else:
                count = query.delete()
                if count:
                    LOG.debug("Releasing vlan %(vlan_id)s on physical "
                              "network %(physical_network)s outside pool",
                              {'vlan_id': vlan_id,
                               'physical_network': physical_network})

        if not count:
            LOG.warning(_LW("No vlan_id %(vlan_id)s found on physical "
                            "network %(physical_network)s"),
                        {'vlan_id': vlan_id,
                         'physical_network': physical_network})
dataset/ETHPy150Open openstack/neutron/neutron/plugins/ml2/drivers/type_vlan.py/VlanTypeDriver.release_segment/original