def get_conflicting_domains(
        desired_domains, hmc_access_mode, adapter, partition,
        all_crypto_config, all_partitions):
    """
    Internal function that determines those domains from the desired domains
    on a particular adapter that cannot be attached to a particular partition
    in the desired mode because they are already attached to other partitions
    in a mode that prevents that.
    """
    conflicting_domains = {}
    if adapter.uri in all_crypto_config:
        domains_dict = all_crypto_config[adapter.uri]
        for di in desired_domains:
            if di in domains_dict:
                # The domain is already attached to some
                # partition(s) in some access mode
                for am, p_uri in domains_dict[di]:
                    if am == 'control':
                        # An attachment in control mode does not
                        # prevent additional attachments
                        continue
                    if p_uri == partition.uri and \
                            am == hmc_access_mode:
                        # This is our target partition, and the
                        # domain is already attached in the desired
                        # mode.
                        continue
                    p = all_partitions[p_uri]
                    conflicting_domains[di] = (am, p.name)
    return conflicting_domains