'Validate the address scope before associating.
Subnetpool can associate with an address scope if
- the tenant user is the owner of both the subnetpool and
address scope
- the admin is associating the subnetpool with the shared
address scope
- there is no prefix conflict with the existing subnetpools
associated with the address scope.
- the address family of the subnetpool and address scope
are the same'

def _validate_address_scope_id(self, context, address_scope_id, subnetpool_id, sp_prefixes, ip_version):

    if (not validators.is_attr_set(address_scope_id)):
        return
    if (not self.is_address_scope_owned_by_tenant(context, address_scope_id)):
        raise n_exc.IllegalSubnetPoolAssociationToAddressScope(subnetpool_id=subnetpool_id, address_scope_id=address_scope_id)
    as_ip_version = self.get_ip_version_for_address_scope(context, address_scope_id)
    if (ip_version != as_ip_version):
        raise n_exc.IllegalSubnetPoolIpVersionAssociationToAddressScope(subnetpool_id=subnetpool_id, address_scope_id=address_scope_id, ip_version=as_ip_version)
    subnetpools = subnetpool_obj.SubnetPool.get_objects(context, address_scope_id=address_scope_id)
    new_set = netaddr.IPSet(sp_prefixes)
    for sp in subnetpools:
        if (sp.id == subnetpool_id):
            continue
        sp_set = netaddr.IPSet(sp.prefixes)
        if sp_set.intersection(new_set):
            raise n_exc.AddressScopePrefixConflict()
