def create_server_handler(): form = ServerForm() if request.method == 'POST' and form.validate(): server = Server(form.serial_number.data, form.assets_number.data, form.groups.data, form.desc.data, form.ext_address.data, form.int_address.data, form.ipmi_address.data, form.other_address.data, form.idc.data.id, form.rack.data, form.manufacturer.data, form.model.data, form.cpu_info.data, form.disk_info.data, form.memory_info.data) db.session.add(server) db.session.commit() flash(u'Create server successfully', 'success') return redirect(url_for('dashboard.list_server_handler')) else: return render_template('dashboard/server_manager.html', form=form, action='create')
def create_server_handler(): form = ServerForm() if request.method == 'POST' and form.validate(): server = Server( form.serial_number.data, form.assets_number.data, form.groups.data, form.desc.data, form.ext_address.data, form.int_address.data, form.ipmi_address.data, form.other_address.data, form.idc.data.id, form.rack.data, form.manufacturer.data, form.model.data, form.cpu_info.data, form.disk_info.data, form.memory_info.data) db.session.add(server) db.session.commit() flash(u'Create server successfully', 'success') return redirect(url_for('dashboard.list_server_handler')) else: return render_template('dashboard/server_manager.html', form=form, action='create')
def edit_server_handler(server_id): server = Server.query.filter_by(id=server_id).first() form = ServerForm(id=server.id, serial_number=server.serial_number, assets_number=server.assets_number, desc=server.desc, ext_address=server.ext_address, int_address=server.int_address, ipmi_address=server.ipmi_address, other_address=server.other_address, idc=server.idc, rack=server.rack, manufacturer=server.manufacturer, model=server.model, cpu_info=server.cpu_info, disk_info=server.disk_info, memory_info=server.memory_info, groups=server.groups) if request.method == 'POST' and form.validate(): if form.serial_number.data != server.serial_number: server.serial_number = form.serial_number.data if form.assets_number.data != server.dashboard_number: server.dashboard_number = form.assets_number.data server.set_groups(form.groups.data) if form.desc.data != server.desc: server.desc = form.desc.data if form.ext_address.data != server.ext_address: server.ext_address = form.ext_address.data if form.int_address != server.int_address: server.int_address = form.int_address.data if form.ipmi_address != server.ipmi_address: server.ipmi_address = form.ipmi_address.data if form.other_address != server.other_address: server.other_address = form.other_address.data if form.idc.data.id != server.idc: server.idc = form.idc.data.id if form.rack.data != server.rack: server.rack = form.rack.data if form.manufacturer.data != server.manufacturer: server.manufacturer = form.manufacturer.data if form.model.data != server.model: server.model = form.model.data if form.cpu_info.data != server.cpu_info: server.cpu_info = form.cpu_info.data if form.disk_info.data != server.disk_info: server.disk_info = form.disk_info.data if form.memory_info.data != server.memory_info: server.memory_info = form.memory_info.data db.session.commit() flash(u'Edit server successfully', 'success') return redirect(url_for('dashboard.list_server_handler')) else: return render_template('dashboard/server_manager.html', form=form, action='edit')
def edit_server_handler(server_id): server = Server.query.filter_by(id=server_id).first() form = ServerForm(id=server.id, serial_number=server.serial_number, assets_number=server.assets_number, desc=server.desc, ext_address=server.ext_address, int_address=server.int_address, ipmi_address=server.ipmi_address, other_address=server.other_address, idc_id=server.idc, rack=server.rack, manufacturer=server.manufacturer, model=server.model, cpu_info=server.cpu_info, disk_info=server.disk_info, memory_info=server.memory_info, groups=server.groups) if request.method == 'POST' and form.validate(): if form.serial_number.data != server.serial_number: server.serial_number = form.serial_number.data if form.assets_number.data != server.assets_number: server.assets_number = form.assets_number.data server.set_groups(form.groups.data) if form.desc.data != server.desc: server.desc = form.desc.data if form.ext_address.data != server.ext_address: server.ext_address = form.ext_address.data if form.int_address != server.int_address: server.int_address = form.int_address.data if form.ipmi_address != server.ipmi_address: server.ipmi_address = form.ipmi_address.data if form.other_address != server.other_address: server.other_address = form.other_address.data if form.idc.data.id != server.idc: server.idc = form.idc.data.id if form.rack.data != server.rack: server.rack = form.rack.data if form.manufacturer.data != server.manufacturer: server.manufacturer = form.manufacturer.data if form.model.data != server.model: server.model = form.model.data if form.cpu_info.data != server.cpu_info: server.cpu_info = form.cpu_info.data if form.disk_info.data != server.disk_info: server.disk_info = form.disk_info.data if form.memory_info.data != server.memory_info: server.memory_info = form.memory_info.data db.session.commit() flash(u'Edit server successfully', 'success') return redirect(url_for('assets.list_server_handler')) else: return render_template('assets/server.html', form=form, action='edit')