-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathget_facts.py
39 lines (29 loc) · 982 Bytes
/
get_facts.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
#!/usr/bin/env python
##############################################################
# Author: Stuart Clark <[email protected]>
#
#
# Allows you to get router facts change to an IOS-XR device
# python get_facts.py -ip [ip address]
##############################################################
from napalm import get_network_driver
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("-ip", "--router_ip", help="Enter device ip address")
args = parser.parse_args()
device_ip = args.router_ip
driver = get_network_driver('iosxr')
device = driver(username='vagrant',
password='vagrant',
optional_args={'port':2221},
hostname=device_ip)
device.open()
print ('Napalm Is Running........')
router_dic = device.get_facts()
for i in router_dic:
if type(router_dic[i]) == list:
for k in router_dic[i]:
print("\t -{}".format(k))
else:
print("{}: {}".format(i, router_dic[i]))
device.close()