'Return eligible subnets
If no eligible subnets are found, determine why and potentially raise
an appropriate error.'

def _ipam_get_subnets(self, context, network_id, host, service_type=None, fixed_configured=False):

    subnets = self._find_candidate_subnets(context, network_id, host, service_type, fixed_configured)
    if subnets:
        subnet_dicts = [self._make_subnet_dict(subnet, context=context) for subnet in subnets]
        return sorted(subnet_dicts, key=(lambda subnet: (not subnet.get('service_types'))))
    query = self._query_subnets_on_network(context, network_id)
    if self.is_host_set(host):
        s_query = query.filter(models_v2.Subnet.segment_id.isnot(None))
        if (s_query.limit(1).count() != 0):
            raise segment_exc.HostNotConnectedToAnySegment(host=host, network_id=network_id)
    if (not query.limit(1).count()):
        return []
    query = self._query_filter_service_subnets(query, service_type)
    if query.limit(1).count():
        raise ipam_exceptions.DeferIpam()
    raise ipam_exceptions.IpAddressGenerationFailureNoMatchingSubnet()
