def _check_for_too_many_exclusions(exclude_instances, available_instances,
                                   delta, groups_members):
    """
        Check whether the amount of exluded instances will make it possible to
        scale down by the given delta.

        :param exclude_instances: A list of node instance IDs to exclude.
        :param available_instances: A list of all available instance IDs. For
                                    groups this should include both the group
                                    instance IDs and the member node instance
                                    IDs.
        :param delta: How much to scale by. This is expected to be negative.
        :param groups_members: A dict of group instances with their members,
                               e.g. produced by get_groups_with_members
        :return: A string detailing problems if there are any, or an empty
                 string if there are no problems.
    """
    if groups_members:
        excluded_groups = set()
        # For groups, we must add all group instances to the exclusions that
        # contain an excluded node instance as one of their members, AND we
        # must add all group instances that are excluded, as the
        # exclude_instances list could legitimately contain both
        for inst in exclude_instances:
            for group, members in groups_members.items():
                if inst in members or inst == group:
                    excluded_groups.add(group)
        planned_group_instances = len(groups_members) + delta
        if planned_group_instances < len(excluded_groups):
            return (
                'Instances from too many different groups were excluded. '
                'Target number of group instances was {group_count}, but '
                '{excluded_count} excluded groups.'.format(
                    group_count=planned_group_instances,
                    excluded_count=len(excluded_groups),
                )
            )
    else:
        planned_num_instances = len(available_instances) + delta
        if planned_num_instances < len(exclude_instances):
            return (
                'Target number of instances is less than excluded '
                'instance count. Target number of instances was '
                '{target}. Excluded instances were: '
                '{instances}. '.format(
                    target=planned_num_instances,
                    instances=', '.join(exclude_instances),
                )
            )

    # No problems found, return no error
    return ''