# Class 1, Exercise 10
# Find the crypto maps that are not using AES (based-on the transform set name). Print these entries and their corresponding transform set name.
# There are two methods of computing the result. One of which is commented out.
#!/usr/bin/env python

from ciscoconfparse import CiscoConfParse

#num_cryptomaps_wo_AES = 0
cisco_config = CiscoConfParse ("cisco_ipsec.txt")

#list_crypto_maps = cisco_config.find_objects(r"^crypto map CRYPTO")

print "\nThis script lists the crypto maps that are not using AES in the transform set"
print"----------------------------------------------------------------------------------"
#for crymap in list_crypto_maps:
#    if not crymap.re_search_children(r"AES"):
#        print crymap.text
#        num_cryptomaps_wo_AES += 1
#print"-----------------------------------------------------------------"
#print "Found a total of %d crypto maps without AES in transform set.\n" % num_cryptomaps_wo_AES



no_AES_crymaps = cisco_config.find_objects_wo_child(r'crypto map CRYPTO', r'AES')
for obj in no_AES_crymaps:
    print obj.text

print"---------------------------------------------------------------------------------"

@@ -165,88 +165,8 @@
 me.%0A
-# There are two methods of computing the result. One of which is commented out.%0A
 #!/u
@@ -231,35 +231,8 @@
 se%0A%0A
-#num_cryptomaps_wo_AES = 0%0A
 cisc
@@ -282,78 +282,8 @@
 %22)%0A%0A
-#list_crypto_maps = cisco_config.find_objects(r%22%5Ecrypto map CRYPTO%22)%0A%0A
 prin
@@ -368,16 +368,54 @@
  set
-%22%0Aprint%22
+ and the transform set name%22%0Aprint%22-----------
 ----
@@ -496,99 +496,216 @@
 ----
-%22%0A#for crymap in list_crypto_
+--------------%22%0A%0Ano_AES_crymaps = cisco_config.find_objects_wo_child(r'crypto map CRYPTO', r'AES')%0Afor obj in no_AES_cry
 maps:%0A
-#
     
-if not crymap.re_search_children(r%22AES%22)
+print %22Crypto-map name: %25s%22 %25 obj.text%0A    for child in obj.children
 :%0A
-#
         
 prin
@@ -704,191 +704,220 @@
     
-pr
+if %22transform-set%22 
 in
-t
  c
-rymap.text%0A#        num_cryptomaps_wo_AES += 1%0A#print%22-----------------------------------------------------------------%22%0A#print %22Found a total of %25d crypto maps without AES in 
+hild.text:%0A            mystring = child.text%0A            mystringlist = mystring.split()%0A            count = 0%0A            for i in mystringlist:%0A                if mystringlist%5Bcount%5D == %22
 tran
@@ -925,179 +925,251 @@
 form
- set.%5Cn%22 %25 num_cryptomaps_wo_AES%0A%0A%0A%0Ano_AES_crymaps = cisco_config.find_objects_wo_child(r'crypto map CRYPTO', r'AES')%0Afor obj in no_AES_crymaps:%0A    print obj.text%0A%0Aprint%22
+-set%22:%0A                    count = count + 1%0A                    print %22Transform-set name is: %25s%5Cn%22 %25 mystringlist%5Bcount%5D%0A                    exit()%0A                else:%0A                    count = count + 1%0A%0Aprint%22--------------------------
 ----

fix up ex10 bugs