'Enforce regular project hierarchy constraints.
Called when is_domain is false. The project must contain a valid
domain_id and parent_id. The goal of this method is to check
that the domain_id specified is consistent with the domain of its
parent.
:raises keystone.exception.ValidationError: If one of the constraints
was not satisfied.
:raises keystone.exception.DomainNotFound: In case the domain is not
found.'

def _assert_regular_project_constraints(self, project_ref):

    domain = self.get_domain(project_ref['domain_id'])
    parent_ref = self.get_project(project_ref['parent_id'])
    if parent_ref['is_domain']:
        if (parent_ref['id'] != domain['id']):
            raise exception.ValidationError(message=(_("Cannot    create    project,    since    its    parent    (%(domain_id)s)    is    acting    as    a    domain,    but    project's    specified    parent_id    (%(parent_id)s)    does    not    match    this    domain_id.") % {'domain_id': domain['id'], 'parent_id': parent_ref['id']}))
    else:
        parent_domain_id = parent_ref.get('domain_id')
        if (parent_domain_id != domain['id']):
            raise exception.ValidationError(message=(_('Cannot    create    project,    since    it    specifies    its    owner    as    domain    %(domain_id)s,    but    specifies    a    parent    in    a    different    domain    (%(parent_domain_id)s).') % {'domain_id': domain['id'], 'parent_domain_id': parent_domain_id}))
