'Insert the domain ID into the ref, if required.
If the driver can\'t handle domains, then we need to insert the
domain_id into the entity being returned.  If the domain_id is
None that means we are running in a single backend mode, so to
remain backwardly compatible, we put in the default domain ID.'

def _insert_domain_id_if_needed(self, ref, driver, domain_id, conf):

    if (not driver.is_domain_aware()):
        if (domain_id is None):
            domain_id = conf.default_domain_id
        ref['domain_id'] = domain_id
