def devices(): form = DeviceCommandForm() if form.validate_on_submit(): with open ('devices.yaml') as f: devices = yaml.load(f) for i in devices: if i['Ip'] == form.ipaddress.data: dev=i return render_template('devices.html',dev=dev,form=form) return render_template('devices.html',form=form)
def devices(): form = DeviceCommandForm() if form.validate_on_submit(): cursor = mysql.sql_connect() sql = '''SELECT switches.id,`boot`,`hardware`,`mac`,`serial_number`,vendor.vendor,model.name,model.all_ports,INET_NTOA(ip_address.ip),`software_version` FROM `switches` INNER JOIN `vendor` ON switches.id_vendor=vendor.id INNER JOIN `ip_address` ON switches.id_ip=ip_address.id INNER JOIN `model` ON switches.id_model=model.id WHERE INET_NTOA(ip_address.ip) LIKE "%{0}%" OR `mac` LIKE"%{0}%" OR model.name LIKE "%{0}%" '''.format( form.ipaddress.data) cursor[0].execute(sql) result = cursor[0].fetchall() return render_template('devices_result.html', device=result, form=form) return render_template('devices_request.html', form=form)
def devices(): form = DeviceCommandForm() if form.validate_on_submit(): with open ('devices.yaml') as f: devices = yaml.load(f) dev=[] for i in devices: for k in i.values() : if form.ipaddress.data in k: dev.append(i) return render_template('devices_result.html',device=dev,form=form) return render_template('devices_request.html',form=form)