Example #1
0
def add_idc():
    form = IdcAddForm()
    if form.validate_on_submit():
        idc = Idc()
        load_data_to_model(idc, form).save()
        return redirect(url_for('idc.idc_manager'))
    return render_template('cmdb/add_idc.html', form=form)
Example #2
0
def add_tag():
    form = TagForm()
    if form.validate_on_submit():
        tag = Tag()
        load_data_to_model(tag, form)
        tag.save()
        return redirect(url_for('tag.tag_manager'))
    return render_template('cmdb/add_tag.html', form=form)
Example #3
0
def edit_idc(idc_id):
    form = IdcEditForm()
    idc = Idc.query.get_or_404(idc_id)
    if form.validate_on_submit():
        load_data_to_model(idc, form).save()
        return redirect(url_for('idc.idc_manager'))
    load_data_to_form(idc, form)
    return render_template('cmdb/edit_idc.html', form=form, idc=idc)
Example #4
0
def edit_server(server_id):
    form = ServerEditForm()
    form.idc_id.choices = [(idc.id, idc.name) for idc in Idc.query.all()]
    server = Server.query.get_or_404(server_id)
    if form.validate_on_submit():
        load_data_to_model(server, form).save()
        return redirect(url_for('server.server_manager'))
    form = load_data_to_form(server, form)
    form.idc_id.data = server.idc_id
    return render_template('cmdb/edit_server.html', form=form, server=server)
Example #5
0
def edit_db(db_id):
    form = DatabaseEditForm()
    form.tag_id.choices = [(tag.id, tag.name) for tag in Tag.query.all()]
    form.host_id.choices = [(host.id, host.hostname)
                            for host in Host.query.all()]
    db = Database.query.get_or_404(db_id)
    if form.validate_on_submit():
        load_data_to_model(db, form).save()
        return redirect(url_for('db.db_manager'))
    form = load_data_to_form(db, form)
    form.tag_id.data = db.tag_id
    form.host_id.data = db.host_id
    return render_template('cmdb/edit_db.html', form=form, db=db)
Example #6
0
def edit_host(host_id):
    form = HostEditForm()
    host = Host.query.get_or_404(host_id)
    form.tag_id.choices = [(tag.id, tag.name) for tag in Tag.query.all()]
    form.server_id.choices = [(server.id, server.name)
                              for server in Server.query.all()]
    if form.validate_on_submit():
        load_data_to_model(host, form).save()
        return redirect(url_for('host.host_manager'))
    form = load_data_to_form(host, form)
    form.tag_id.data = host.tag_id
    form.server_id.data = host.server_id
    return render_template('cmdb/edit_host.html', form=form, host=host)
Example #7
0
def edit_tag(tag_id):
    tag = Tag.query.get_or_404(tag_id)
    form = TagForm()
    if form.validate_on_submit():
        tag = load_data_to_model(tag, form)
        tag.save()
        return redirect(url_for('tag.tag_manager'))
    form = load_data_to_form(tag, form)
    return render_template('cmdb/edit_tag.html', form=form, tag=tag)
Example #8
0
def add_server():
    form = ServerAddForm()
    form.idc.choices = [(str(idc.id), idc.name) for idc in Idc.query.all()]
    if form.validate_on_submit():
        server = Server()
        server = load_data_to_model(server, form, except_fields=['idc'])
        server.idc = Idc.query.get_or_404(form.idc.data)
        server.save()
        return redirect(url_for('server.server_manager'))
    return render_template('cmdb/add_server.html', form=form)
Example #9
0
def add_host():
    form = HostAddForm()
    form.tag_id.choices = [(tag.id, tag.name) for tag in Tag.query.all()]
    form.server_id.choices = [(server.id, server.name)
                              for server in Server.query.all()]
    if form.validate_on_submit():
        host = Host()
        host = load_data_to_model(host, form, except_fields=[''])
        host.save()
        return redirect(url_for('host.host_manager'))
    return render_template('cmdb/add_host.html', form=form)
Example #10
0
def add_db():
    form = DatabaseAddForm()
    form.tag_id.choices = [(tag.id, tag.name) for tag in Tag.query.all()]
    form.host_id.choices = [(host.id, host.hostname)
                            for host in Host.query.all()]
    if form.validate_on_submit():
        db = Database()
        db = load_data_to_model(db, form)
        db.save()
        return redirect(url_for('db.db_manager'))
    print(form.errors)
    return render_template('cmdb/add_db.html', form=form)