-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwk1-cconfparse.py
27 lines (24 loc) · 1.02 KB
/
wk1-cconfparse.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
#!/usr/bin/env python
from ciscoconfparse import CiscoConfParse
cfg = CiscoConfParse ("cisco_ipsec.txt")
crypto_maps = cfg.find_objects("^crypto map CRYPTO")
#Excercise 8, part1
#find all lines that begin with 'crypto map CRYPTO'& for each crypto map entry print out its children
print "These are cryto map lines"
for crypto in crypto_maps:
print crypto.text
for child in crypto.children:
print child.text
#Excercise 8, part2:show crypto maps that have pfs group 2
print "These Crypto maps have pfs group 2"
pfs2 = cfg.find_objects_w_child(parentspec=r"^crypto map CRYPTO", childspec=r"set pfs group2")
for i in pfs2:
print i.text
#Excercise 8, part2:show crypto maps that aren't using AES and also print transform set
print "Find MAPS not using AES"
#aes = cfg.find_objects_w_child(parentspec=r"^crypto map CRYPTO", childspec=r"AES-SHA")
aes = cfg.find_objects_wo_child(parentspec=r"^crypto map CRYPTO", childspec="set transform-set AES-SHA")
for each in aes:
print each.text
for child in each.children:
print child.text