Ejemplo n.º 1
0
def _create_or_update_task(id, body_dict):
    """Verifies the incoming keys are correct and creates the task record"""
    keys = ['task', 'instance_uuid', 'recurrence']
    for key in keys:
        if key not in body_dict:
            raise Exception("Missing key %s in body" % key)
    task = db.task_create_or_update(id, body_dict)
    return task
Ejemplo n.º 2
0
def _create_or_update_task(id, body_dict):
    """Verifies the incoming keys are correct and creates the task record"""
    keys = ['task', 'instance_uuid', 'recurrence']
    for key in keys:
        if key not in body_dict:
            raise Exception("Missing key %s in body" % key)

    # Validate values
    cronspec.parse(body_dict['recurrence'])

    values = {
        'deleted': False,
        'uuid': id,
        'instance_uuid': body_dict['instance_uuid'],
        'cron_schedule': body_dict['recurrence'],
        'action_id': actions.actions_by_name[body_dict['task']].id,
    }
    task_dict = _make_task_dict(db.task_create_or_update(id, values))
    _update_crontab()
    return task_dict