def _get_available_instances_list(available_instances, groups_members):
    """
        Get a string of available instances, given a list of instance IDs
        and a group membership list.
        This string will be formatted for providing helpful feedback to a
        user, e.g. regarding available instances when they have selected a
        non-existent instance.

        :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.
                                    This will be ignored if groups_members
                                    contains anything.
        :param groups_members: A dict of group instances with their members,
                               e.g. produced by get_groups_with_members
        :return: A user-friendly string listing what instances are valid for
                 selection based on the provided inputs.
    """
    if groups_members:
        return 'Groups and member instances were: {groups}'.format(
            groups='; '.join(
                '{group}: {members}'.format(
                    group=group,
                    members=', '.join(members)
                )
                for group, members in groups_members.items()
            ),
        )
    else:
        return 'Available instances were: {instances}'.format(
            instances=', '.join(available_instances),
        )