Ejemplo n.º 1
0
def verify_and_get_env(db_session, environment_id, request):
    environment = db_session.query(models.Environment).get(environment_id)
    if not environment:
        LOG.info(_('Environment with id {0} not found').format(environment_id))
        raise exc.HTTPNotFound

    if environment.tenant_id != request.context.tenant:
        LOG.info(_('User is not authorized to access this tenant resources.'))
        raise exc.HTTPUnauthorized
    return environment
Ejemplo n.º 2
0
def verify_and_get_deployment(db_session, environment_id, deployment_id):
    deployment = db_session.query(models.Deployment).get(deployment_id)
    if not deployment:
        LOG.info(_('Deployment with id {0} not found').format(deployment_id))
        raise exc.HTTPNotFound
    if deployment.environment_id != environment_id:
        LOG.info(
            _('Deployment with id {0} not found'
              ' in environment {1}').format(deployment_id, environment_id))
        raise exc.HTTPBadRequest

    _patch_description(deployment.description)
    return deployment