示例#1
0
def job_create(job_values):
    global DATA
    db_utils.validate_job_values(job_values)
    values = job_values.copy()
    job = {}

    metadata = []
    if 'job_metadata' in values:
        metadata = values['job_metadata']
        del values['job_metadata']

    if not 'retry_count' in values:
        values['retry_count'] = 0
    job['worker_id'] = None
    job['version_id'] = str(uuid.uuid4())

    job.update(values)
    item_id = values.get('id')
    job.update(_gen_base_attributes(item_id=item_id))

    DATA['jobs'][job['id']] = job

    for metadatum in metadata:
        job_meta_create(job['id'], metadatum)

    return job_get_by_id(job['id'])
示例#2
0
文件: api.py 项目: isethi/qonos
def job_create(job_values):
    global DATA
    db_utils.validate_job_values(job_values)
    values = job_values.copy()
    job = {}

    metadata = []
    if 'job_metadata' in values:
        metadata = values['job_metadata']
        del values['job_metadata']

    if not 'retry_count' in values:
        values['retry_count'] = 0
    job['worker_id'] = None

    job.update(values)
    item_id = values.get('id')
    job.update(_gen_base_attributes(item_id=item_id))

    DATA['jobs'][job['id']] = job

    for metadatum in metadata:
        job_meta_create(job['id'], metadatum)

    return job_get_by_id(job['id'])
示例#3
0
文件: api.py 项目: komawar/qonos
def job_create(job_values):
    global DATA
    db_utils.validate_job_values(job_values)
    values = job_values.copy()
    job = {}

    metadata = []
    if 'job_metadata' in values:
        metadata = values['job_metadata']
        del values['job_metadata']

    if not 'retry_count' in values:
        values['retry_count'] = 0
    job['worker_id'] = None

    now = timeutils.utcnow()

    job_timeout_seconds = _job_get_timeout(values['action'])
    if not 'timeout' in values:
        values['timeout'] = now + timedelta(seconds=job_timeout_seconds)
    values['hard_timeout'] = now + timedelta(seconds=job_timeout_seconds)
    job.update(values)
    job.update(_gen_base_attributes())

    DATA['jobs'][job['id']] = job

    for metadatum in metadata:
        job_meta_create(job['id'], metadatum)

    return job_get_by_id(job['id'])
示例#4
0
文件: api.py 项目: isethi/qonos
def job_create(job_values):
    db_utils.validate_job_values(job_values)
    values = job_values.copy()
    session = get_session()
    job_ref = models.Job()

    if 'job_metadata' in values:
        metadata = values['job_metadata']
        _set_job_metadata(job_ref, metadata)
        del values['job_metadata']

    job_ref.update(values)
    job_ref.save(session=session)

    return _job_get_by_id(job_ref['id'])
示例#5
0
def job_create(job_values):
    db_utils.validate_job_values(job_values)
    values = job_values.copy()
    session = get_session()
    job_ref = models.Job()

    if 'job_metadata' in values:
        metadata = values['job_metadata']
        _set_job_metadata(job_ref, metadata)
        del values['job_metadata']

    job_ref.update(values)
    job_ref.save(session=session)

    return _job_get_by_id(job_ref['id'])
示例#6
0
文件: api.py 项目: komawar/qonos
def job_create(job_values):
    db_utils.validate_job_values(job_values)
    values = job_values.copy()
    session = get_session()
    job_ref = models.Job()

    if 'job_metadata' in values:
        metadata = values['job_metadata']
        _set_job_metadata(job_ref, metadata)
        del values['job_metadata']

    now = timeutils.utcnow()

    job_timeout_seconds = _job_get_timeout(values['action'])
    if not 'timeout' in values:
        values['timeout'] = now + timedelta(seconds=job_timeout_seconds)
    values['hard_timeout'] = now + timedelta(seconds=job_timeout_seconds)
    job_ref.update(values)
    job_ref.save(session=session)

    return _job_get_by_id(job_ref['id'])