-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathtabular_examples.py
76 lines (62 loc) · 2.81 KB
/
tabular_examples.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
from genie.conf import Genie
from genie import parsergen
from genie.utils.diff import Diff
from pprint import pprint
# Create Testbed Object with Genie
testbed = Genie.init('../default_testbed.yaml')
# Create Device Object
uut = testbed.devices['uut']
# Use connect method to initiate connection to the device under test
uut.connect()
# Execute command show nve nvi on connected device
# Create list of Header names of the table from the show_command
# these must match exactly to that which is output on cli
header = ['System ID', 'SNPA', 'Level', 'State', 'Hold Time', 'Interface']
# Capture Before output
before = uut.device.execute('show fabricpath isis adjacency')
before = parsergen.oper_fill_tabular(device_output=before,
device_os='nxos',
header_fields=header,
index=[0])
# Capture after output
after = uut.device.execute('show fabricpath isis adjacency')
after = parsergen.oper_fill_tabular(device_output=after,
device_os='nxos',
header_fields=header,
index=[0])
pprint(after.entries)
exclude = ['Hold Time']
dd = Diff(before.entries, after.entries, exclude=exclude)
dd.findDiff()
print(dd)
command = "show fabricpath switch-id"
output = uut.device.execute(command)
header_fields = ['SWITCH-ID', ' SYSTEM-ID', ' FLAGS',
' STATE', ' STATIC', ' EMULATED/']
label_fields = ['SWITCH-ID', 'SYSTEM-ID', 'FLAGS',
'STATE', 'STATIC', 'EMULATED/ANYCAST']
topology = parsergen.oper_fill_tabular(device_output=output,
header_fields=header_fields,
label_fields=label_fields,
index=[1])
pprint(topology.entries)
# show fabricpath isis interface brief
command = 'show fabricpath isis interface brief'
header = ['Interface', 'Type', 'Idx', 'State', 'Circuit',
'MTU', 'Metric', 'Priority', 'Adjs/AdjsUp']
int_brief = parsergen.oper_fill_tabular(device=uut,
show_command=command,
header_fields=header,
index=[0])
pprint(int_brief.entries)
# sh fabricpath isis host
command = "sh fabricpath isis host"
output = uut.device.execute(command)
header = ['Level', 'System ID', 'Dynamic hostname']
label_fields = ['level', 'system_id', 'hostname']
isis_hosts = parsergen.oper_fill_tabular(device_output=output,
device_os='nxos',
header_fields=header,
label_fields=label_fields,
index=[1])
pprint(isis_hosts.entries)