Exemple #1
0
def environment(environment_id):
    session = get_db_session()
    environ = session.query(Environment).get(environment_id)
    helper = FabricHelper(environ.execute_path)
    error_message = None
    form = JobForm()
    if not environ:
        abort(404)
    if form.validate_on_submit():
        not_found_tasks = helper.get_tasks(
            form.tasks.data.split(' ')).get('not_found')
        if len(not_found_tasks) == 0:
            job = Job()
            job.name = form.name.data
            job.description = form.description.data
            job.tasks = form.tasks.data
            job.environment = environ
            session.commit()
            return redirect(
                url_for('environment', environment_id=environment_id))
        error_message = 'tasks [{0}] not found.'.format(
            ','.join(not_found_tasks))
    form.environment_id.data = environ.id
    return render_template('environment.html',
                           form=form,
                           environ=environ,
                           environ_doc=helper.doc,
                           error_message=error_message)
Exemple #2
0
def environment(environment_id):
    session = get_db_session()
    environ = session.query(Environment).get(environment_id)
    helper = FabricHelper(environ.execute_path)
    error_message = None
    form = JobForm()
    if not environ:
        abort(404)
    if form.validate_on_submit():
        not_found_tasks = helper.get_tasks(form.tasks.data.split(' ')).get('not_found')
        if len(not_found_tasks) == 0:
            job = Job()
            job.name = form.name.data
            job.description = form.description.data
            job.tasks = form.tasks.data
            job.environment = environ
            session.commit()
            return redirect(url_for('environment', environment_id=environment_id))
        error_message = 'tasks [{0}] not found.'.format(','.join(not_found_tasks))
    form.environment_id.data = environ.id
    return render_template('environment.html', form=form,
      environ=environ, environ_doc=helper.doc, error_message=error_message)
Exemple #3
0
def create_jobset():
    form = JobSetForm()
    form.job_id.choices = Job.choices()
    session = get_db_session()
    if form.validate_on_submit():
        jobset = Jobset()
        jobset.title = form.title.data
        jobset.description = form.description.data
        session.add(jobset)
        for id in form.job_id.data:
            j = session.query(Job).get(id)
            jsl = JobsetJobList()
            jsl.jobset = jobset
            jsl.job = j
            session.add(jsl)
        session.commit()
        return redirect(url_for('jobsets'))
    return render_template('create_jobset.html', form=form, job_list=session.query(Job).all())