Пример #1
0
def revoke_auth_token(manager_id):
    """Revokes the Manager's existing authentication tokens.

    Only allowed by owners of the Manager.
    """

    manager_oid = str2id(manager_id)

    csrf = request.form.get('csrf', '')
    if not flask_wtf.csrf.validate_csrf(csrf):
        log.warning(
            'User %s tried to generate authentication token for Manager %s without '
            'valid CSRF token!', current_user.user_id, manager_oid)
        raise wz_exceptions.PreconditionFailed()

    if not current_flamenco.manager_manager.user_is_owner(
            mngr_doc_id=manager_oid):
        log.warning(
            'User %s wants to generate authentication token of manager %s, '
            'but user is not owner of that Manager. Request denied.',
            current_user.user_id, manager_oid)
        raise wz_exceptions.Forbidden()

    current_flamenco.manager_manager.revoke_auth_token(manager_oid)
    return '', 204
Пример #2
0
def archive(project, job_id):
    """Redirects to the actual job archive.

    This is done via a redirect, so that templates that offer a download link do not
    need to know the eventual storage backend link. This makes them render faster,
    and only requires communication with the storage backend when needed.
    """

    from pillar.api.file_storage_backends import default_storage_backend

    from . import ARCHIVE_JOB_STATES
    from .sdk import Job

    api = pillar_api()
    job = Job.find(job_id, api=api)

    if job['status'] not in ARCHIVE_JOB_STATES:
        raise wz_exceptions.PreconditionFailed('Job is not archived')

    archive_blob_name = job.archive_blob_name
    if not archive_blob_name:
        raise wz_exceptions.NotFound('Job has no archive')

    bucket = default_storage_backend(project._id)
    blob = bucket.get_blob(archive_blob_name)
    archive_url = blob.get_url(is_public=False)

    return redirect(archive_url, code=303)
Пример #3
0
 def serve_microservice(self, name):
     if not self.endpoints:
         raise exceptions.PreconditionFailed('Not deployed yed!')
     try:
         return self.endpoints[name]['func']()
     except Exception as e:
         logging.exception('EXC!', exc_info=e)
         return exceptions.InternalServerError('\n'.join(e.args))
Пример #4
0
def edit_rna_overrides(project, job_id):
    """Allows editing RNA overrides of this job."""
    from .sdk import Job

    api = pillar_api()
    job = Job.find(job_id, api=api)

    if job['job_type'] not in blender_render.job_types():
        raise wz_exceptions.PreconditionFailed('Job is not a Blender job')

    override_lines = job.settings.rna_overrides or []

    return render_template(
        'flamenco/jobs/edit_rna_overrides.html',
        job=job,
        job_id=job_id,
        project=project,
        override_lines=override_lines,
        override_text='\n'.join(override_lines),
        already_has_overrides=job.settings.rna_overrides is not None,
        close_url=url_for('flamenco.jobs.perproject.view_job',
                          project_url=project.url,
                          job_id=job._id),
    )