Пример #1
0
    def insert_job(self, tag, job, commit = None):
        job.machine_idx = self.lookup_machine(job.machine)
        if not job.machine_idx:
            job.machine_idx = self.insert_machine(job, commit=commit)
        else:
            self.update_machine_information(job, commit=commit)

        afe_job_id = utils.get_afe_job_id(tag)

        data = {'tag':tag,
                'label': job.label,
                'username': job.user,
                'machine_idx': job.machine_idx,
                'queued_time': job.queued_time,
                'started_time': job.started_time,
                'finished_time': job.finished_time,
                'afe_job_id': afe_job_id}
        is_update = hasattr(job, 'index')
        if is_update:
            self.update('tko_jobs', data, {'job_idx': job.index}, commit=commit)
        else:
            self.insert('tko_jobs', data, commit=commit)
            job.index = self.get_last_autonumber_value()
        self.update_job_keyvals(job, commit=commit)
        for test in job.tests:
            self.insert_test(job, test, commit=commit)
Пример #2
0
    def insert_job(self, tag, job, commit=None):
        job.machine_idx = self.lookup_machine(job.machine)
        if not job.machine_idx:
            job.machine_idx = self.insert_machine(job, commit=commit)
        else:
            self.update_machine_information(job, commit=commit)

        afe_job_id = utils.get_afe_job_id(tag)

        data = {
            'tag': tag,
            'label': job.label,
            'username': job.user,
            'machine_idx': job.machine_idx,
            'queued_time': job.queued_time,
            'started_time': job.started_time,
            'finished_time': job.finished_time,
            'afe_job_id': afe_job_id
        }
        is_update = hasattr(job, 'index')
        if is_update:
            self.update('tko_jobs',
                        data, {'job_idx': job.index},
                        commit=commit)
        else:
            self.insert('tko_jobs', data, commit=commit)
            job.index = self.get_last_autonumber_value()
        self.update_job_keyvals(job, commit=commit)
        for test in job.tests:
            self.insert_test(job, test, commit=commit)
    def set_afe_job_id_and_tag(self, pb_job, tag):
        """Sets the pb job's afe_job_id and tag field.

        :param
        pb_job: the pb job that will have it's fields set.
        tag: used to set pb_job.tag and pb_job.afe_job_id.
        """
        pb_job.tag = tag
        pb_job.afe_job_id = utils.get_afe_job_id(tag)
Пример #4
0
    def set_afe_job_id_and_tag(self, pb_job, tag):
        """Sets the pb job's afe_job_id and tag field.

        @param
        pb_job: the pb job that will have it's fields set.
        tag: used to set pb_job.tag and pb_job.afe_job_id.
        """
        pb_job.tag = tag
        pb_job.afe_job_id = utils.get_afe_job_id(tag)
Пример #5
0
def insert_job(jobname, job):
    # write the job into the database
    machine = tko_models_utils.machine_create(job.machine,
                                              job.machine_group,
                                              job.machine_owner)

    # Update back machine index, used by some legacy code
    machine.save()
    job.machine_idx = machine.pk

    afe_job_id = utils.get_afe_job_id(jobname)
    if not afe_job_id:
        afe_job_id = None

    tko_job_data = {
        'tag': jobname,
        'label': job.label,
        'machine': machine,
        'queued_time': job.queued_time,
        'started_time': job.started_time,
        'finished_time': job.finished_time,
        'afe_job_id': afe_job_id
    }

    job_already_exists = hasattr(job, 'index')
    if job_already_exists:
        tko_models.Job.objects.filter(pk=job.index).update(**tko_job_data)
        tko_job = tko_models.Job.objects.get(pk=job.index)
    else:
        tko_job = tko_models.Job.objects.create(**tko_job_data)

    # Update back the index of the job object, used by some legacy code
    tko_job.save()
    job.index = tko_job.pk

    # update job keyvals
    for key, value in job.keyval_dict.iteritems():
        # We find or create using job and key only
        job_keyval, created = tko_models.JobKeyval.objects.get_or_create(
            job=tko_job,
            key=key)
        # and now we have to update with value
        job_keyval.value = value
        job_keyval.save()

    # now insert the tests
    for test in job.tests:
        insert_test(job, test, tko_job, machine)
Пример #6
0
def insert_job(jobname, job):
    # write the job into the database
    machine = tko_models_utils.machine_create(job.machine, job.machine_group,
                                              job.machine_owner)

    # Update back machine index, used by some legacy code
    machine.save()
    job.machine_idx = machine.pk

    afe_job_id = utils.get_afe_job_id(jobname)
    if not afe_job_id:
        afe_job_id = None

    tko_job_data = {
        'tag': jobname,
        'label': job.label,
        'machine': machine,
        'queued_time': job.queued_time,
        'started_time': job.started_time,
        'finished_time': job.finished_time,
        'afe_job_id': afe_job_id
    }

    job_already_exists = hasattr(job, 'index')
    if job_already_exists:
        tko_models.Job.objects.filter(pk=job.index).update(**tko_job_data)
        tko_job = tko_models.Job.objects.get(pk=job.index)
    else:
        tko_job = tko_models.Job.objects.create(**tko_job_data)

    # Update back the index of the job object, used by some legacy code
    tko_job.save()
    job.index = tko_job.pk

    # update job keyvals
    for key, value in job.keyval_dict.items():
        # We find or create using job and key only
        job_keyval, created = tko_models.JobKeyval.objects.get_or_create(
            job=tko_job, key=key)
        # and now we have to update with value
        job_keyval.value = value
        job_keyval.save()

    # now insert the tests
    for test in job.tests:
        insert_test(job, test, tko_job, machine)