Пример #1
0
def create_step(uid):
    '''
    Create a sign-off step
    '''
    logger.info('Creating step %s', uid)

    step = SignoffStep()

    step.uid = uid
    step.policy = pickle.dumps(request.json['policy'])
    if step.policy_data['method'] == 'balrog':
        step.state = get_balrog_signoff_state(step.policy_data['definition'])
    else:
        step.state = 'running'

    db.session.add(step)

    try:
        db.session.commit()
    except IntegrityError as e:
        logger.error('Attempt to create duplicate step %s', uid)
        return {
            'error_title': 'Step with that uid already exists',
            'error_message': str(e),
        }, 409  # Conflict

    logger.info('Created step %s, policy %s', uid, request.json['policy'])
    return {}
Пример #2
0
def get_step_status(uid):
    '''
    Get the current status of a sign-off step, including who has signed
    '''
    logger.info('Getting step status %s', uid)

    try:
        step = db.session.query(SignoffStep).filter(
            SignoffStep.uid == uid).one()
    except NoResultFound:
        logger.error('Step %s not found', uid)
        abort(404)

    if step.policy_data['method'] == 'balrog':
        # Once a step is complete there is nothing we need to know from Balrog,
        # so we can avoid talking to it altogether.
        if step.state == SigningStatus.running:
            step.state = get_balrog_signoff_state(
                step.policy_data['definition'])

    return signoffstep_to_status(step)