-
Notifications
You must be signed in to change notification settings - Fork 0
/
cisco-parse.py
40 lines (33 loc) · 1.11 KB
/
cisco-parse.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
from ciscoconfparse import CiscoConfParse
import sys
def cryptomap():
cisco_conf = CiscoConfParse("cisco.config")
cis_map = cisco_conf.find_objects(r'^crypto map CRYPTO')
for i in cis_map:
print i.text
for j in i.children:
print j.text
def pfsmap():
cisco_conf = CiscoConfParse("cisco.config")
cis_map = cisco_conf.find_objects_w_child(parentspec=r'^crypto map CRYPTO',\
childspec=r'pfs group2')
for i in cis_map:
print i.text
for j in i.children:
print j.text
def notaes():
cisco_conf = CiscoConfParse("cisco.config")
cis_map = cisco_conf.find_objects_wo_child(r'^crypto map CRYPTO',\
r'transform-set AES')
for i in cis_map:
print i.text
for j in i.children:
print j.text
if __name__ == "__main__":
if len(sys.argv) == 2:
if sys.argv[1] == "allmaps":
cryptomap()
elif sys.argv[1] == "pfs2":
pfsmap()
elif sys.argv[1] == "notaes":
notaes()