'Validates ip version for subnet_pool and requested subnet'

def _validate_ip_version_with_subnetpool(self, subnet, subnetpool):

    ip_version = subnet.get('ip_version')
    has_ip_version = validators.is_attr_set(ip_version)
    if (has_ip_version and (ip_version != subnetpool.ip_version)):
        args = {'req_ver': str(subnet['ip_version']), 'pool_ver': str(subnetpool.ip_version)}
        reason = (_('Cannot    allocate    IPv%(req_ver)s    subnet    from    IPv%(pool_ver)s    subnet    pool') % args)
        raise exc.BadRequest(resource='subnets', msg=reason)
