-
Notifications
You must be signed in to change notification settings - Fork 1
/
ssh_napalm_get_configurations.py
48 lines (42 loc) · 1.58 KB
/
ssh_napalm_get_configurations.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
''' ssh and get information about cisco switch using python and napalm '''
# Author: Anubhavsingh Sawdagur
# Created Date: 12 Febuary 2019
import json
from napalm_base import get_network_driver
IP_LIST = ["192.168.44.110", "192.168.44.111", "192.168.44.121", "192.168.44.122"]
for IP in IP_LIST:
DRIVER = get_network_driver("ios")
DEVICE = DRIVER(str(IP), "anubhav", "cisco")
DEVICE.open()
print("Connected to " + str(IP))
# ------------------------------------
print("Facts - " + str(IP))
OUTPUT = DEVICE.get_facts()
OUTPUT = json.dumps(OUTPUT, indent=4)
print(OUTPUT)
# ------------------------------------
print("Interfaces - " + str(IP))
OUTPUT = DEVICE.get_interfaces()
OUTPUT = json.dumps(OUTPUT, sort_keys=True, indent=4)
print(OUTPUT)
# ------------------------------------
print("Interfaces IP - " + str(IP))
OUTPUT = DEVICE.get_interfaces_ip()
OUTPUT = json.dumps(OUTPUT, sort_keys=True, indent=4)
print(OUTPUT)
# ------------------------------------
print("MAC Address Table - " + str(IP))
OUTPUT = DEVICE.get_mac_address_table()
OUTPUT = json.dumps(OUTPUT, sort_keys=True, indent=4)
print(OUTPUT)
# ------------------------------------
print("ARP Table - " + str(IP))
OUTPUT = DEVICE.get_arp_table()
OUTPUT = json.dumps(OUTPUT, sort_keys=True, indent=4)
print(OUTPUT)
# ------------------------------------
print("BGP Neighbors - " + str(IP))
OUTPUT = DEVICE.get_bgp_neighbors()
OUTPUT = json.dumps(OUTPUT, sort_keys=True, indent=4)
print(OUTPUT)
DEVICE.close()