-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
34 lines (29 loc) · 1.07 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/python3
from netmiko import ConnectHandler
import re,sys,os
import requests
from flask import *
########################
app = Flask(__name__)
app.debug = True
@app.route('/show_ip_arp')
def show_ip_arp():
IP = request.args.get('IP', None)
os = request.args.get('os', 'cisco_ios')
user = request.args.get('user', 'cisco')
passwd = request.args.get('passwd', 'cisco')
net_connect=ConnectHandler(device_type=os, ip=IP, username=user, password=passwd)
showarp=net_connect.send_command("show ip arp",use_textfsm=True)
return(showarp)
@app.route('/show_mac_addr')
def show_mac_addr():
IP = request.args.get('IP', None)
os = request.args.get('os', 'cisco_ios')
user = request.args.get('user', 'cisco')
passwd = request.args.get('passwd', 'cisco')
net_connect=ConnectHandler(device_type=os, ip=IP, username=user, password=passwd)
net_connect.send_command("term len 0")
showmac=net_connect.send_command("show mac address-table",use_textfsm=True)
return(showmac)
if __name__ == '__main__':
app.run(host='0.0.0.0')