'Construct an AgentTask instance for the given active HostQueueEntry,
if one can currently run it.
:param queue_entry: a HostQueueEntry
:return: an AgentTask to run the queue entry'

def _get_agent_task_for_queue_entry(self, queue_entry):

    task_entries = queue_entry.job.get_group_entries(queue_entry)
    self._check_for_duplicate_host_entries(task_entries)
    if (queue_entry.status in (models.HostQueueEntry.Status.STARTING, models.HostQueueEntry.Status.RUNNING)):
        if queue_entry.is_hostless():
            return HostlessQueueTask(queue_entry=queue_entry)
        return QueueTask(queue_entries=task_entries)
    if (queue_entry.status == models.HostQueueEntry.Status.GATHERING):
        return GatherLogsTask(queue_entries=task_entries)
    if (queue_entry.status == models.HostQueueEntry.Status.PARSING):
        return FinalReparseTask(queue_entries=task_entries)
    if (queue_entry.status == models.HostQueueEntry.Status.ARCHIVING):
        return ArchiveResultsTask(queue_entries=task_entries)
    raise host_scheduler.SchedulerError(('_get_agent_task_for_queue_entry    got    entry    with    invalid    status    %s:    %s' % (queue_entry.status, queue_entry)))
