Ejemplo n.º 1
0
def do_task_result(fname, task_id, result_type, path, score, summary):
    """
    Report task result

    result_type -- 'Pass'|'Warn'|'Fail'|'Panic'

    return 0 on success, error message otherwise
    """
    global results
    try:
        log.info(
                "%s(task_id=%r, result_type=%r, path=%r, score=%r, summary=%r)",
                fname, task_id, result_type, path, score, summary)
        rec_args = get_recipe_args(task_id=task_id)
        if not rec_args:
            raise no_task(task_id=task_id)
        ix = 'task%s_res' % task_id
        result = rec_args.get(ix, "Pass")
        if RESULT_TYPE_.count(result) == 0 \
            or (RESULT_TYPE_.count(result_type) > 0 \
                    and RESULT_TYPE_.index(result) < RESULT_TYPE_.index(result_type)):
            rec_args[ix]=result_type
        result_id = "%s%s%.2d" % (task_id, time.strftime("%H%M%S"), randint(0, 99))
        add_result(task_id, result_id)
        results.result(task_id, result_type, path, score, summary, result_id)
        log.info("%s.RETURN: %s", fname, result_id)
        misc.log_flush(log)
        return result_id
    except:
        log.error("%s", misc.format_exc())
        results.result(task_id, result_type, path, score, summary, "ERROR")
        raise
Ejemplo n.º 2
0
def do_task_result(fname, task_id, result_type, path, score, summary):
    """
    Report task result

    result_type -- 'Pass'|'Warn'|'Fail'|'Panic'

    return 0 on success, error message otherwise
    """
    global results
    try:
        log.info(
            "%s(task_id=%r, result_type=%r, path=%r, score=%r, summary=%r)",
            fname, task_id, result_type, path, score, summary)
        rec_args = get_recipe_args(task_id=task_id)
        if not rec_args:
            raise no_task(task_id=task_id)
        ix = 'task%s_res' % task_id
        result = rec_args.get(ix, "Pass")
        if RESULT_TYPE_.count(result) == 0 \
            or (RESULT_TYPE_.count(result_type) > 0 \
                    and RESULT_TYPE_.index(result) < RESULT_TYPE_.index(result_type)):
            rec_args[ix] = result_type
        result_id = "%s%s%.2d" % (task_id, time.strftime("%H%M%S"),
                                  randint(0, 99))
        add_result(task_id, result_id)
        results.result(task_id, result_type, path, score, summary, result_id)
        log.info("%s.RETURN: %s", fname, result_id)
        misc.log_flush(log)
        return result_id
    except:
        log.error("%s", misc.format_exc())
        results.result(task_id, result_type, path, score, summary, "ERROR")
        raise
Ejemplo n.º 3
0
def do_task_start(fname, task_id, kill_time):
    global results
    results.start(task_id, kill_time)
    log.info("%s(task_id=%r, kill_time=%r)", fname, task_id, kill_time)
    # Fail on start, to check start repeating.
    task_starter.check()
    rec_args = get_recipe_args(task_id=task_id)
    if not rec_args:
        raise no_task(task_id=task_id)
    rec_args['task%s_stat' % task_id] = 'Running'
    misc.log_flush(log)
    return 0
Ejemplo n.º 4
0
def do_task_start(fname, task_id, kill_time):
    global results
    results.start(task_id, kill_time)
    log.info("%s(task_id=%r, kill_time=%r)", fname, task_id, kill_time)
    # Fail on start, to check start repeating.
    task_starter.check()
    rec_args = get_recipe_args(task_id=task_id)
    if not rec_args:
        raise no_task(task_id=task_id)
    rec_args['task%s_stat' % task_id]='Running'
    misc.log_flush(log)
    return 0
Ejemplo n.º 5
0
 def task_finished(self, task, rc, evt=None):
     if self.rebooting:
         # If we're in the middle of a reboot, we don't want the task
         # to be marked as "done", because we need to start it up again
         # after the reboot
         log.info("Task %s has finished, not marking it as done due to reboot.",
                  task.task_id)
     else:
         self.generate_evt(evt or event.end(task.task_id, rc))
         self.remove_task(task)
         task.set_controller()
         master = self.get_master(task.task_id)
         if master:
             master.set_done(True, rc)
             log.info("Task %s has finished. Marking it as done.", task.task_id)
     log_flush(log)
Ejemplo n.º 6
0
def do_task_stop(fname, task_id, stop_type, msg):
    """
    Stop a task

    stop_type -- 'Stop'|'Abort'|'Cancel'

    return 0 on success, error message otherwise
    """
    global results
    results.stop(task_id, stop_type, msg)
    log.info("%s(task_id=%r, stop_type=%r, msg=%r)", fname, task_id, stop_type,
             msg)
    rec_args = get_recipe_args(task_id=task_id)
    if not rec_args:
        raise no_task(task_id=task_id)
    rec_args['task%s_stat' % task_id] = STOP_TYPE[stop_type]
    misc.log_flush(log)
    return 0
Ejemplo n.º 7
0
def do_task_stop(fname, task_id, stop_type, msg):
    """
    Stop a task

    stop_type -- 'Stop'|'Abort'|'Cancel'

    return 0 on success, error message otherwise
    """
    global results
    results.stop(task_id, stop_type, msg)
    log.info("%s(task_id=%r, stop_type=%r, msg=%r)", fname, task_id, stop_type,
            msg)
    rec_args = get_recipe_args(task_id=task_id)
    if not rec_args:
        raise no_task(task_id=task_id)
    rec_args['task%s_stat' % task_id]=STOP_TYPE[stop_type]
    misc.log_flush(log)
    return 0
Ejemplo n.º 8
0
def close(log):
    global runtime, results
    runtime.close()
    results.close()
    log.info("runtime closed.")
    misc.log_flush(log)
Ejemplo n.º 9
0
def close(log):
    global runtime, results
    runtime.close()
    results.close()
    log.info("runtime closed.")
    misc.log_flush(log)