':return: a directory name to use for the next host group results.'

def _next_group_name(self, group_name=''):

    if group_name:
        group_name = group_name.replace(os.path.sep, '_')
        if group_name.startswith('.'):
            group_name = ('_' + group_name[1:])
        group_name += '.'
    group_count_re = re.compile(('%sgroup(\\d+)' % re.escape(group_name)))
    query = models.HostQueueEntry.objects.filter(job=self.id).values('execution_subdir').distinct()
    subdirs = (entry['execution_subdir'] for entry in query)
    group_matches = (group_count_re.match(subdir) for subdir in subdirs)
    ids = [int(match.group(1)) for match in group_matches if match]
    if ids:
        next_id = (max(ids) + 1)
    else:
        next_id = 0
    return ('%sgroup%d' % (group_name, next_id))
