def _rebuild_availability_ranges(self, session):
        # List all currently allocated addresses, and prevent further
        # allocations with a write-intent lock.
        # NOTE: because of this driver's logic the write intent lock is
        # probably unnecessary as this routine is called when the availability
        # ranges for a subnet are exhausted and no further address can be
        # allocated.
        # TODO(salv-orlando): devise, if possible, a more efficient solution
        # for building the IPSet to ensure decent performances even with very
        # large subnets.
        allocations = netaddr.IPSet(
            [netaddr.IPAddress(allocation['ip_address']) for
             allocation in self.subnet_manager.list_allocations(
                 session)])

        # MEH MEH
        # There should be no need to set a write intent lock on the allocation
        # pool table. Indeed it is not important for the correctness of this
        # operation if the allocation pools are updated by another operation,
        # which will result in the generation of new availability ranges.
        # NOTE: it might be argued that an allocation pool update should in
        # theory preempt rebuilding the availability range. This is an option
        # to consider for future developments.
        LOG.debug("Rebuilding availability ranges for subnet %s",
                  self.subnet_manager.neutron_id)

        for pool in self.subnet_manager.list_pools(session):
            # Create a set of all addresses in the pool
            poolset = netaddr.IPSet(netaddr.IPRange(pool['first_ip'],
                                                    pool['last_ip']))
            # Use set difference to find free addresses in the pool
            available = poolset - allocations
            # Write the ranges to the db
            for ip_range in available.iter_ipranges():
                av_range = self.subnet_manager.create_range(
                    session,
                    pool['id'],
                    netaddr.IPAddress(ip_range.first).format(),
                    netaddr.IPAddress(ip_range.last).format())
                session.add(av_range)
Check if requested scopes are within a scope of the refresh token.
dataset/ETHPy150Open openstack/neutron/neutron/ipam/drivers/neutrondb_ipam/driver.py/NeutronDbSubnet._rebuild_availability_ranges--crossover with--dataset/ETHPy150Open idan/oauthlib/oauthlib/oauth2/rfc6749/request_validator.py/RequestValidator.is_within_original_scope