Exemple #1
0
def io_config():
    if utils.needs_user():
        return flask.redirect(flask.url_for('setup'))
    if ('logged_in' not in flask.session) or (not flask.session['logged_in']):
        return flask.redirect(flask.url_for('login'))

    error = None
    if flask.request.method == 'POST':
        if "delete" in flask.request.form:
            io_id = int(flask.request.form['id'])
            utils.delete_io(io_id)
            flask.flash('IO Deleted')
        else:
            io_type = int(flask.request.form['type'])
            bus = int(flask.request.form['bus'])
            addr = int(flask.request.form['addr'], 16)
            if "edit" in flask.request.form:
                io_id = int(flask.request.form['edit'])
                utils.modify_io(io_id, io_type, bus, addr)
                flask.flash('IO Edited')
            else:
                utils.create_io(io_type, bus, addr)
                flask.flash('IO Created')

    ios = utils.get_ios()
    return flask.render_template(
        'io_config.j2',
        error=error,
        ios=ios,
        smbio=smbio)
Exemple #2
0
def io_config():
    if utils.needs_user():
        return flask.redirect(flask.url_for('setup'))
    if ('logged_in' not in flask.session) or (not flask.session['logged_in']):
        return flask.redirect(flask.url_for('login'))

    error = None
    if flask.request.method == 'POST':
        if "delete" in flask.request.form:
            io_id = int(flask.request.form['id'])
            utils.delete_io(io_id)
            flask.flash('IO Deleted')
        else:
            io_type = int(flask.request.form['type'])
            bus = int(flask.request.form['bus'])
            addr = int(flask.request.form['addr'], 16)
            if "edit" in flask.request.form:
                io_id = int(flask.request.form['edit'])
                utils.modify_io(io_id, io_type, bus, addr)
                flask.flash('IO Edited')
            else:
                utils.create_io(io_type, bus, addr)
                flask.flash('IO Created')

    ios = utils.get_ios()
    return flask.render_template('io_config.j2',
                                 error=error,
                                 ios=ios,
                                 smbio=smbio)
Exemple #3
0
def interface_config():
    if utils.needs_user():
        return flask.redirect(flask.url_for('setup'))
    if ('logged_in' not in flask.session) or (not flask.session['logged_in']):
        return flask.redirect(flask.url_for('login'))

    error = None
    if flask.request.method == 'POST':
        if "delete" in flask.request.form:
            interface_id = int(flask.request.form['id'])
            utils.delete_interface(interface_id)
            flask.flash('Interface Deleted')
        else:
            interface_type = int(flask.request.form['type'])
            io_id = int(flask.request.form['io_id'])
            slot = int(flask.request.form['slot'])
            datamap = smbio.INTERFACEDATAMAP[interface_type]
            data = {}
            for key in datamap:
                data[key] = flask.request.form[key]
            if "edit" in flask.request.form:
                interface_id = int(flask.request.form['edit'])
                utils.modify_interface(
                    interface_id, interface_type, io_id, slot, data)
                flask.flash('Interface Edited')
            else:
                utils.create_interface(interface_type, io_id, slot, data)
                flask.flash('Interface Created')

    interfaces = utils.get_interfaces()
    ios = utils.get_ios()
    return flask.render_template(
        'interface_config.j2',
        error=error,
        interfaces=interfaces,
        ios=ios,
        smbio=smbio)
Exemple #4
0
def interface_config():
    if utils.needs_user():
        return flask.redirect(flask.url_for('setup'))
    if ('logged_in' not in flask.session) or (not flask.session['logged_in']):
        return flask.redirect(flask.url_for('login'))

    error = None
    if flask.request.method == 'POST':
        if "delete" in flask.request.form:
            interface_id = int(flask.request.form['id'])
            utils.delete_interface(interface_id)
            flask.flash('Interface Deleted')
        else:
            interface_type = int(flask.request.form['type'])
            io_id = int(flask.request.form['io_id'])
            slot = int(flask.request.form['slot'])
            datamap = smbio.INTERFACEDATAMAP[interface_type]
            data = {}
            for key in datamap:
                data[key] = flask.request.form[key]
            if "edit" in flask.request.form:
                interface_id = int(flask.request.form['edit'])
                utils.modify_interface(interface_id, interface_type, io_id,
                                       slot, data)
                flask.flash('Interface Edited')
            else:
                utils.create_interface(interface_type, io_id, slot, data)
                flask.flash('Interface Created')

    interfaces = utils.get_interfaces()
    ios = utils.get_ios()
    return flask.render_template('interface_config.j2',
                                 error=error,
                                 interfaces=interfaces,
                                 ios=ios,
                                 smbio=smbio)