Mar-28-2020, 01:21 PM
FLASK Error - Please help
I am trying to run a script but while when I comment out add VLAN, the add interface works, when I comment out add interface.py then add vlan works. But when I enable both and try to run add vlan I get this error.
I have show commands that also do the same thing when I introduce one of the below sections. What am I doing wrong?
example error:
I am trying to run a script but while when I comment out add VLAN, the add interface works, when I comment out add interface.py then add vlan works. But when I enable both and try to run add vlan I get this error.
I have show commands that also do the same thing when I introduce one of the below sections. What am I doing wrong?
example error:
Error:File "/home/app.py", line 48, in addvlan
addvlan = router('cisco_ios', result['hostname'], result['username'], result['password'], result['port'], result['number'], result['vlanname'])
TypeError: __init__() missing 1 required positional argument: 'voicevlan'
app.py script@app.route('/addvlan',methods = ['POST', 'GET']) def addvlan(): if request.method == 'POST': result = request.form.to_dict() data = request.form.to_dict('number') addvlan = router('cisco_ios', result['hostname'], result['username'], result['password'], result['port'], result['number'], result['vlanname']) return render_template('addvlan.html',result=addvlan.addvlan()) else: return render_template('addvlan.html') @app.route('/addinterface',methods = ['POST', 'GET']) def addinterface(): if request.method == 'POST': result = request.form.to_dict() data = request.form.to_dict('interface') addinterface = router('cisco_ios', result['hostname'], result['username'], result['password'], result['port'], result['interface'], result['datavlan'], result['voi$ return render_template('addinterface.html',result=addinterface.addinterface()) else: return render_template('addinterface.html')addvlan.py
class router(object): def __init__(self,device_type,ip,username,password,port,number,vlanname): self.device_type = device_type self.ip = ip self.username = username self.password = password self.port = port self.number = number self.vlanname = vlanname def addvlan(self): cisco_vios = { 'device_type':self.device_type, 'ip': self.ip, 'username':self.username, 'password': self.password, 'port': self.port } net_connect = ConnectHandler(**cisco_vios) string_vlan = net_connect.send_command('en') string_vlan = net_connect.send_command('cisco') data = { 'number':self.number, 'vlanname':self.vlanname } config_commands = [ 'vlan {number}'.format(**data), 'name {vlanname}'.format(**data), ] output = net_connect.send_config_set(config_commands)addinterface.py
class router(object): def __init__(self,device_type,ip,username,password,port,interface,datavlan,voicevlan): self.device_type = device_type self.ip = ip self.username = username self.password = password self.port = port self.interface = interface self.datavlan = datavlan self.voicevlan = voicevlan def addinterface(self): cisco_vios = { 'device_type':self.device_type, 'ip': self.ip, 'username':self.username, 'password': self.password, 'port': self.port } net_connect = ConnectHandler(**cisco_vios) string_interface = net_connect.send_command('en') string_interface = net_connect.send_command('cisco') data = { 'interface':self.interface, 'datavlan':self.datavlan, 'voicevlan':self.voicevlan } config_commands = [ 'interface gi{interface}'.format(**data), 'switchport', 'switchport access vlan {datavlan}'.format(**data), 'switchport voice vlan {voicevlan}'.format(**data) ] output = net_connect.send_config_set(config_commands)