'Create a job row in the test database.
:param hosts - A list of explicit host ids for this job to be
scheduled on.
:param metahosts - A list of label ids for each host that this job
should be scheduled on (meta host scheduling).
:param priority - The job priority (integer).
:param active - bool, mark this job as running or not in the database?
:param synchronous - bool, if True use synch_count=2 otherwise use
synch_count=1.
:param atomic_group - An atomic group id for this job to schedule on
or None if atomic scheduling is not required.  Each metahost
becomes a request to schedule an entire atomic group.
This does not support creating an active atomic group job.
:param hostless - if True, this job is intended to be hostless (in that
case, hosts, metahosts, and atomic_group must all be empty)
:return: A Django frontend.afe.models.Job instance.'

def _create_job(self, hosts=[], metahosts=[], priority=0, active=False, synchronous=False, atomic_group=None, hostless=False, drone_set=None, control_file='control', parameterized_job=None):

    if (not drone_set):
        drone_set = (models.DroneSet.default_drone_set_name() and models.DroneSet.get_default())
    assert (not (atomic_group and active))
    synch_count = ((synchronous and 2) or 1)
    created_on = datetime.datetime(2008, 1, 1)
    status = models.HostQueueEntry.Status.QUEUED
    if active:
        status = models.HostQueueEntry.Status.RUNNING
    job = models.Job.objects.create(name='test', owner='autotest_system', priority=priority, synch_count=synch_count, created_on=created_on, reboot_before=model_attributes.RebootBefore.NEVER, drone_set=drone_set, control_file=control_file, parameterized_job=parameterized_job)
    for host_id in hosts:
        models.HostQueueEntry.objects.create(job=job, host_id=host_id, status=status, atomic_group_id=atomic_group)
        models.IneligibleHostQueue.objects.create(job=job, host_id=host_id)
    for label_id in metahosts:
        models.HostQueueEntry.objects.create(job=job, meta_host_id=label_id, status=status, atomic_group_id=atomic_group)
    if (atomic_group and (not (metahosts or hosts))):
        models.HostQueueEntry.objects.create(job=job, status=status, atomic_group_id=atomic_group)
    if hostless:
        assert (not (hosts or metahosts or atomic_group))
        models.HostQueueEntry.objects.create(job=job, status=status)
    return job
