'Return the subnetpool id for this request
:param subnet: The subnet dict from the request'

def _get_subnetpool_id(self, context, subnet):

    use_default_subnetpool = subnet.get('use_default_subnetpool')
    if (use_default_subnetpool == constants.ATTR_NOT_SPECIFIED):
        use_default_subnetpool = False
    subnetpool_id = subnet.get('subnetpool_id')
    if (subnetpool_id == constants.ATTR_NOT_SPECIFIED):
        subnetpool_id = None
    if (use_default_subnetpool and subnetpool_id):
        msg = _('subnetpool_id    and    use_default_subnetpool    cannot    both    be    specified')
        raise exc.BadRequest(resource='subnets', msg=msg)
    if subnetpool_id:
        return subnetpool_id
    if (not use_default_subnetpool):
        return
    cidr = subnet.get('cidr')
    if validators.is_attr_set(cidr):
        ip_version = netaddr.IPNetwork(cidr).version
    else:
        ip_version = subnet.get('ip_version')
        if (not validators.is_attr_set(ip_version)):
            msg = _('ip_version    must    be    specified    in    the    absence    of    cidr    and    subnetpool_id')
            raise exc.BadRequest(resource='subnets', msg=msg)
    if ((ip_version == 6) and cfg.CONF.ipv6_pd_enabled):
        return constants.IPV6_PD_POOL_ID
    subnetpool = self.get_default_subnetpool(context, ip_version)
    if subnetpool:
        return subnetpool['id']
    msg = (_('No    default    subnetpool    found    for    IPv%s') % ip_version)
    raise exc.BadRequest(resource='subnets', msg=msg)
