def get_int(switch, interface): """ Get a config snippet from a device """ conf_file = conf_dir + switch + extension interface = expand_port(interface) try: parse = CiscoConfParse(conf_file) except: print("Error: could not load config for ", conf_file) sys.exit(1) search_int = "^interface " + interface + "$" if args.match: m = parse.find_objects_w_child(parentspec=search_int, childspec=args.match) if m: print(args.switch + ',' + args.int + ',' + args.match) else: iface = parse.find_all_children(search_int) if iface: print('!' + switch + ' ' + interface) for line in iface: print(line) if iface: print('!')
def main(): """ Find all crypto map entires that use PFS Group 2. """ cisco_file = "cisco_ipsec.txt" cisco_cfg = CiscoConfParse(cisco_file) crypto_maps = cisco_cfg.find_objects_w_child(parentspec=r"^crypto map CRYPTO",childspec=r"pfs group2") print("Printing crypto_maps content") print(crypto_maps) print('\n\n') print ("#" * 3) print ("#" * 3, 'crypto_maps Type:') print ("#" * 3) print(type(crypto_maps)) for c_map in crypto_maps: print ("#" * 3) print ("#" * 3, 'c_map Type:') print ("#" * 3) print(type(c_map)) print() print(c_map.text) for child in c_map.children: print(child.text) print()
def main(): cisco_cfg = CiscoConfParse("cisco_ipsec.txt") cryptomaps = cisco_cfg.find_objects_w_child(parentspec = r"crypto map CRYPTO", childspec = r"pfs group2") print "\n crypto maps using PFS group2:" for entry in cryptomaps: print " {0}" .format(entry.text)
def main(): #YAML file cisco_cfg = CiscoConfParse("./cisco_file.txt") transform_set = cisco_cfg.find_objects(r"^crypto ipsec transform-set") t_set_list = [] for t_set in transform_set: if ('esp-aes' not in t_set.text): t_set_list.append(t_set.text) print 'Transform sets found without AES are:', t_set_list print '\nCrypto Maps without AES are:\n' for t_set in t_set_list: var_tmp1 = t_set.split() reference = var_tmp1[3].strip() #print 'reference es', reference var_tmp1 = cisco_cfg.find_objects_w_child(r"^crypto map ", reference) #print 'var_tmp1 es', var_tmp1[0].text for index in range(0, len(var_tmp1)): config_crypto_map = cisco_cfg.find_children(var_tmp1[index].text) for item in config_crypto_map: print ' ', item
def main(): cisco_cfg = CiscoConfParse("cisco_ipsec.txt") map_list = cisco_cfg.find_objects(r"^crypto map CRYPTO") for cryptoMap in map_list: print cryptoMap.text mapChildren = cryptoMap.children for child in mapChildren: print child.text print '\nCrypto maps using PFS group 2:\n' pfs2_list = cisco_cfg.find_objects_w_child(parentspec=r"^crypto map CRYPTO", childspec=r"set pfs group2") for cryptoMap in pfs2_list: print cryptoMap.text print '\nCrypto maps not using AES:\n' noaes_list = cisco_cfg.find_objects_wo_child(parentspec=r"^crypto map CRYPTO", childspec=r"set transform-set AES-SHA") for cryptoMap in noaes_list: print cryptoMap.text mapChildren = cryptoMap.children transformSetLine = mapChildren[1] (head,transformSet) = transformSetLine.text.split('set transform-set') print transformSet
def main(): cisco_cfg = CiscoConfParse("cisco_ipsec.txt") crypto_map = cisco_cfg.find_objects_w_child(parentspec=r'crypto map CRYPTO', childspec=r'pfs group2') print "\n the crypto maps with pfs group2 :", "\n" for each_map in crypto_map: print each_map.text
def main(): cisco_cfg = CiscoConfParse("cisco_ipsec.txt") intf = cisco_cfg.find_objects_w_child(parentspec=r"^crypto map CRYPTO", childspec=r"pfs group2") print "Crypto maps using PFS group2:" for i in intf: print i.text
def main(): cisco_cfg = CiscoConfParse('cisco_ipsec.txt') crypto_maps = cisco_cfg.find_objects_w_child(parentspec=r'crypto map CRYPTO', childspec=r'pfs group2') print "Crypto map entries that are using PFS group2:" for crypto_map in crypto_maps: print crypto_map.text
def main(): cisco_cfg = CiscoConfParse("cisco_ipsec.txt") crypto_map = cisco_cfg.find_objects_w_child( parentspec=r'crypto map CRYPTO', childspec=r'pfs group2') print "\n the crypto maps with pfs group2 :", "\n" for each_map in crypto_map: print each_map.text
def main(): cisco_file = 'cisco_ipsec.txt' output = CiscoConfParse(cisco_file) crypto_output = output.find_objects_w_child(parentspec=r'crypto map CRYPTO',childspec=r'set pfs group2') for child in crypto_output: print(child.text)
def main(): ''' Main function ''' my_cisco_cfg = CiscoConfParse("cisco_ipsec.txt") out = my_cisco_cfg.find_objects_w_child(parentspec=r"^crypto map CRYPTO", childspec=r"set pfs group2") for item in out: print item.text
def parse_conf_file(file1): cisco_conf = CiscoConfParse(file1) target = cisco_conf.find_objects_w_child(parentspec=r'^' + P_PARSE_STRING, childspec=C_PARSE_STRING) for p_elmt in target: print 'Found target:\n{}'.format(p_elmt.text) for c_elmt in p_elmt.all_children: print c_elmt.text print ''
def main(): cfg=CiscoConfParse('Config-file.txt') temp_list=cfg.find_objects_w_child(parentspec=r"^crypto map", childspec="pfs group2") #for entry in temp_list: for entry in temp_list: print "Crypto Map " , entry.text , " is using PFS Group 2"
def main(): cisco_test_file = 'cisco_ipsec.txt' parse_file = CiscoConfParse(cisco_test_file) crypto_maps = parse_file.find_objects_w_child(parentspec=r'crypto map CRYPTO', childspec=r'pfs group2') print "\nCrypto Maps using PFS group2:" for entry in crypto_maps: print " {0}".format(entry.text) print
def main(): cisco_cfg=CiscoConfParse("cisco_ipsec.txt") crypto_map=cisco_cfg.find_objects_w_child(parentspec=r'crypto map CRYPTO', childspec=r'pfs group2') print "Crypto Map Using PFS Group2: " for child in crypto_map: print "{0}".format(child.text)
def main(): cisco_file = 'cisco_ipsec.txt' cisco_cfg = CiscoConfParse(cisco_file) crypto_maps = cisco_cfg.find_objects_w_child(parentspec=r'crypto map CRYPTO', childspec=r'pfs group2') print("\nCrypto Maps using PFS group2:") for entry in crypto_maps: print(" {}".format(entry.text)) print()
def main(): text_file = 'cisco_ipsec.txt' config = CiscoConfParse(text_file) maps = config.find_objects_w_child(parentspec=r'crypto map CRYPTO',childspec=r'pfs group2') for i in maps: print(i.text) print('\n')
def main(): cfg = CiscoConfParse('Config-file.txt') temp_list = cfg.find_objects_w_child(parentspec=r"^crypto map", childspec="pfs group2") #for entry in temp_list: for entry in temp_list: print "Crypto Map ", entry.text, " is using PFS Group 2"
def main(): cisco_cfg = CiscoConfParse("cisco_ipsec.txt") crypto_g2 = cisco_cfg.find_objects_w_child( parentspec=r"^crypto map CRYPTO", childspec=r"group2") for parent in crypto_g2: print parent.text for child in parent.children: print child.text
def main(): cisco_file = '/home/student13/pynet-ons-oct17/day3/cisco_ipsec.txt' cisco_cfg = CiscoConfParse(cisco_file) # Returns a list of child objects children = cisco_cfg.find_objects_w_child(childspec=r'pfs group2', parentspec=r'crypto map CRYPTO') print('\nCrypto Maps using PFS group 2:') for child in children: print(' {}'.format(child.text)) print()
def main(cisco_file='cisco_ipsec.txt'): ''' Use the ciscoconfparse library to find the crypto maps that are using pfs group2 ''' cisco_cfg = CiscoConfParse(cisco_file) for crypto_map in cisco_cfg.find_objects_w_child( parentspec=r'crypto map CRYPTO', childspec=r'pfs group2'): print crypto_map.text
def main(): cisco_file = "cisco_ipsec.txt" cisco_cfg = CiscoConfParse(cisco_file) crypto_maps = cisco_cfg.find_objects_w_child( parentspec=r'crypto map CRYPTO', childspec=r'set pfs group2') print "Crypto maps using PFS group2: " for cmap in crypto_maps: print " {0}".format(cmap.text) print
def main(): cisco_cfg = CiscoConfParse("cisco_ipsec.txt") crypto_map = cisco_cfg.find_objects_w_child( parentspec=r'crypto map CRYPTO', childspec=r'pfs group2') print "Crypto Map Using PFS Group2: " for child in crypto_map: print "{0}".format(child.text)
def main(cisco_file='cisco_ipsec.txt'): ''' Use the ciscoconfparse library to find the crypto maps that are using pfs group2 ''' cisco_cfg = CiscoConfParse(cisco_file) for crypto_map in cisco_cfg.find_objects_w_child(parentspec=r'crypto map CRYPTO', childspec=r'pfs group2'): print crypto_map.text
def _get_all_l3_int_entries(self): parse = CiscoConfParse(self.file_input) self.hostname = parse.re_match_iter_typed(r'^hostname\s+(\S+)', default='None') for obj in parse.find_objects_w_child(r'^interface', r'^\s*ip address'): cisco = L3Interface() cisco.get_all_properties(obj.text) for obj_child in obj.children: cisco.get_all_properties(obj_child.text) self.l3_int_entries.append(cisco)
def main(): cisco_cfg = CiscoConfParse("cisco_ipsec.txt") crypto_g2 = cisco_cfg.find_objects_w_child(parentspec=r"^crypto map CRYPTO", childspec=r"group2") for parent in crypto_g2: print parent.text for child in parent.children: print child.text
def main(): """ 9. Use ciscoconfparse to find all of the crypto map entries that are using PFS group2 """ cisco_conf = CiscoConfParse("cisco_ipsec.txt") crypto_map = cisco_conf.find_objects_w_child( parentspec=r"^crypto map CRYPTO", childspec=r"pfs group2") for pfs_map in crypto_map: print(pfs_map.text)
def ip_helper(config): """Process config find interfaces using ip helper.""" cfg = CiscoConfParse(config.splitlines()) helper_obj = cfg.find_objects_w_child(parentspec=r"^interface ", childspec=r"ip helper-address") return_intf = [] for helper in helper_obj: _, intf_name = helper.text.split('interface ') return_intf.append(intf_name) print(return_intf) return return_intf
def main(): cisco_file = 'cisco_config.txt' cisco_cfg = CiscoConfParse(cisco_file) crypto_maps = cisco_cfg.find_objects_w_child(parentspec=r'crypto map CRYPTO', childspec=r'pfs group2') print "\nCrypto maps using PFS group2:" for entry in crypto_maps: print " {0}".format(entry.text) print
def interface_to_connected_map(source_file, target_file): int_ref = CiscoConfParse(source_file) list_with_connected_name=int_ref.find_objects_w_child(parentspec=r"interface ethernet", childspec=r"port-name") with open(target_file, "w") as f: f.write("") for i in list_with_connected_name: for j in i.children: if "port-name" in j.text: k = re.search(r"port-name (.+)", j.text) m = k.group(1) with open(target_file, "a") as f: l = i.text+" connected network element is: " + m +"\n" f.write(l)
def main(): cisco_cfg_file = "cisco_ipsec.txt" cisco_cfg = CiscoConfParse(cisco_cfg_file) crypto_pfs2_maps = cisco_cfg.find_objects_w_child(parentspec=r"crypto map CRYPTO", childspec=r"set pfs group2") print("\nCrypto Maps using Perfect Forwarding Secrecy Group 2:") for c_map in crypto_pfs2_maps: print " {0}".format(c_map.text) #print(c_map.text) for child in c_map.children: print " {0}".format(child.text)
def main(): ''' use the ciscoconfparse library to find the crypto maps that are using pfs ''' cisco_file = 'cisco_ipsec.txt' cisco_cfg = CiscoConfParse(cisco_file) crypto_maps = cisco_cfg.find_objects_w_child(parentspec=r'crypto map CRYPTO', childspec=r'pfs group2') print "\nCrypto Maps using PFS group2:" for entry in crypto_maps: print " {0}".format(entry.text)
def main(): """ find all crypto map entries that are using pfs group 2 """ cisco_file = 'config.txt' cisco_cfg = CiscoConfParse(cisco_file) crypto_maps = cisco_cfg.find_objects_w_child(parentspec=r'^crypto map CRYPTO', childspec=r'pfs group2') print("\nCrypto Maps using PFS group2:") for entry in crypto_maps: print(" {}".format(entry.text)) print()
def main(): """ Use the ciscoconfparse library to find the crypto maps that are using pfs group2 """ cisco_file = "cisco_ipsec.txt" cisco_cfg = CiscoConfParse(cisco_file) crypto_maps = cisco_cfg.find_objects_w_child( parentspec=r"crypto map CRYPTO", childspec=r"pfs group2") print("\nCrypto Maps using PFS group2:") for entry in crypto_maps: print(" {0}".format(entry.text)) print()
def main(): ''' Use the ciscoconfparse library to find the crypto maps that are using pfs group2 ''' cisco_file = 'cisco_ipsec.txt' cisco_cfg = CiscoConfParse(cisco_file) crypto_maps = cisco_cfg.find_objects_w_child( parentspec=r'crypto map CRYPTO', childspec=r'pfs group2') print "\nCrypto Maps using PFS group2:" for entry in crypto_maps: print " {0}".format(entry.text) print
def parseIntf(conf): parse = CiscoConfParse(conf) intf_list = [] interfaces = parse.find_objects(r"^interface ") for interface in interfaces: intf_list.append(interface.text) if interface in parse.find_objects_w_child('^interface', '^\s+no ip address'): intf_list.remove(interface.text) return (intf_list)
def main(): ''' Find all of the crypto map entries in the file (lines that begin with 'crypto map CRYPTO') and print out the entries that are using PFS group2. ''' cisco_conf = CiscoConfParse("cisco_ipsec.txt") crypto_maps = cisco_conf.find_objects_w_child( parentspec=r"crypto map CRYPTO", childspec=r"set pfs group2") print "\nCrypto Maps using PFS group2:" for map in crypto_maps: print " {0}".format(map.text) print
def main(): file = 'cisco.txt' config = CiscoConfParse(file) crypto_maps = config.find_objects_w_child(parentspec=r'crypto map CRYPTO',childspec=r'pfs group2') print "Crypto Maps with PFS group 2 mode: " for txt in crypto_maps: print " {0}".format(txt.text) print
def _get_all_l3_int_entries(self): self.__logger.info("Get Info L3 interfaces") parse = CiscoConfParse(self.file_input) self.hostname = parse.re_match_iter_typed(r'^hostname\s+(\S+)', default='None') self.__logger.info(f"Hostname: {self.hostname}") for obj in parse.find_objects_w_child(r'^interface', r'^\s*ip address'): cisco = L3Interface(self.__dbg) cisco.get_all_properties(obj.text) for obj_child in obj.children: cisco.get_all_properties(obj_child.text) self.l3_int_entries.append(cisco) self.__logger.debug( f"L3 int: {cisco.name} IPv4: {cisco.dict['ipv4']}")
def main(): ''' finds all of the crypto map entires and prints all using pfs group2 ''' file_in = 'cisco_ipsec.txt' config_file = CiscoConfParse(file_in) crypto_maps = config_file.find_objects_w_child( parentspec=r'crypto map CRYPTO', childspec=r'pfs group2') print "\nCrypto Maps using PFS group2:" for entry in crypto_maps: print " {0}".format(entry.text) print
def main(): ''' Find all of the crypto map entries in the file (lines that begin with 'crypto map CRYPTO') and print out the children of each crypto map. ''' cisco_file = 'cisco_ipsec.txt' cisco_cfg = CiscoConfParse(cisco_file) crypto_maps = cisco_cfg.find_objects_w_child(parentspec=r'crypto map CRYPTO',childspec=r'pfs group2') print "\nCrypto Maps using PFS group2:" for entry in crypto_maps: print " {0}".format(entry.text) print
def main(): cisco_file = "cisco.cfg" cisco_cfg = CiscoConfParse(cisco_file) crypto_maps = cisco_cfg.find_objects_w_child(parentspec=r'crypto map CRYPTO',childspec=r'pfs group2') print "\nCrypto Maps using PFS group2:" for entry in crypto_maps: print " {0}".format(entry.text) print
def parse(file_name): f = open(file_name, "r") cisco_cfg = CiscoConfParse(f.read().splitlines(keepends=False)) interfaces = cisco_cfg.find_objects_w_child(parentspec=r"^interface", childspec=r"^\s+ip address") # print(interfaces) for i in interfaces: # print("Interface: {}".format(i.text)) ip_address = i.re_search_children(r"ip address")[0].text description_list = i.re_search_children(r"description") if len(description_list) == 0: # HAS DESCRIPTION continue description = description_list[0].text # parts = description.split("-") # user = parts[-1] if not description.endswith("USER"): continue authentication_list = i.re_search_children(r"authentication") if len(authentication_list ) == 1 and authentication_list[0].text == "port-control auto": continue good_count = 0 if len(authentication_list) > 0: bad = False for a in authentication_list: if a.text == " authentication open": bad = True elif a.text == " authentication port-control auto": good_count += 1 if bad == False: continue if good_count > 0 and not bad: continue #BAD print("Interface: {}".format(i.text)) print("IP Address: {}".format(ip_address)) print() print()
def Cisco_Parser(filename): cisco_cfg=CiscoConfParse(filename) interfaces=cisco_cfg.find_objects(r"^interface") vtys=cisco_cfg.find_objects(r"^line vty ") for intf in interfaces: output= str(intf) output+= '\n' + str(intf.children) for vty in vtys: output+= '\n' + '#' * 80 output+= "Configuration for Line vty is: \n {}".format(vty.children) l2_interfaces=cisco_cfg.find_objects_w_child(parentspec=r"^interface", childspec="no ip address") l3_interfaces=cisco_cfg.find_objects_wo_child(parentspec=r"^interface", childspec="no ip address") output+= '\n' +'#' * 80 output+= "\nL2 Interfaces are {}".format(l2_interfaces) output+= '\n' +'#' * 80 output+= "\nL3 Interfaces are {}".format(l3_interfaces) return output
def main(): cisco_file = 'pynet-rtr1.txt' cisco_cfg = CiscoConfParse(cisco_file) interfaces = cisco_cfg.find_objects(r"^interface") for interface in interfaces: print print interface.text for child in interface.children: print child.text print interfacess = cisco_cfg.find_objects_w_child(parentspec=r'interface', childspec=r'no ip address') print "\nInterfaces without ip address:" for interface in interfaces: print " {0}".format(interface.text) print
def main(): cisco_cfg = CiscoConfParse(CISCO_FILENAME) print 'All crypto maps that use "pfs group2"' cisco_objs = cisco_cfg.find_objects_w_child(parentspec=r"crypto map CRYPTO", childspec=r"set pfs group2") for obj in cisco_objs: print "[-]" print obj.text for child in obj.all_children: print child.text print '\n\nAll crypto maps that are not using AES' cisco_objs = cisco_cfg.find_objects_wo_child(parentspec=r"crypto map CRYPTO", childspec=r"set transform-set AES-") for obj in cisco_objs: print "[-]" print obj.text for child in obj.all_children: print child.text
def pfs_group2(config): ''' Accepts Cisco configuration and finds crypto map entries using only pfs group 2. ''' # Create CiscoConfParse object with config passed into function. cisco_cfg = CiscoConfParse(config) # Find only crypto maps using pfs group 2. cmap = cisco_cfg.find_objects_w_child(parentspec=r"^crypto map CRYPTO", childspec=r"set pfs group2") # Iterate over lines matched previously. Print the line. for seq_num in cmap: print seq_num.text # Iterate over children of the config line, print children. for child in seq_num.children: print child.text
def main(): cisco_file = 'pynet-rtr1.txt' cisco_cfg = CiscoConfParse(cisco_file) crypto_maps = cisco_cfg.find_objects(r"^crypto map CRYPTO") for c_map in crypto_maps: print print c_map.text for child in c_map.children: print child.text print crypto_maps = cisco_cfg.find_objects_w_child(parentspec=r'crypto map CRYPTO', childspec=r'pfs group5') print "\nCrypto Maps using PFS group5:" for entry in crypto_maps: print " {0}".format(entry.text) print crypto_maps = cisco_cfg.find_objects_wo_child(parentspec=r'crypto map CRYPTO', childspec=r'set peer 5.5.5.1') print "\nCrypto maps not peer 5.5.5.1:" for entry in crypto_maps: print " {0}".format(entry.text) print
from ciscoconfparse import CiscoConfParse # Read cisco_ipsec.text file using CiscoConfParse cisco_cfg = CiscoConfParse("cisco_ipsec.txt") # Find all entries that begin with crypto map CRYPTO crypto_map = cisco_cfg.find_objects(r"^crypto map CRYPTO") # Now print the CRYPTO map entries found print "\nPrinting the crypto map CRYPTO entries found\n" for i in crypto_map: print i.text print "\n" # Find all entries that are using pfs group2 crypto_PFS = cisco_cfg.find_objects_w_child(parentspec=r"^crypto map", childspec=r"pfs group2") # Print all crypto map using pfs group2 print "\nPrinting the crypto map entries using pfs group2\n" for i in crypto_PFS: print i.text print "\n" # Find all crypto maps that are not usind AES transform-set crypto_noAES = cisco_cfg.find_objects_wo_child(parentspec=r"^crypto map", childspec=r"set transform-set AES") # Print all maps without AES and config under eact. print "\nPrinting the crypto map entries using pfs group2\n" for i in crypto_noAES: print i.text
#!/usr/bin/env python from ciscoconfparse import CiscoConfParse crypto_file = CiscoConfParse("cisco_ipsec.txt") c_maps = crypto_file.find_objects(r"^crypto map CRYPTO") for c_map in c_maps: for i in c_map.children: print i.text pfs2 = crypto_file.find_objects_w_child(parentspec=r"crypto map CRYPTO", childspec="set pfs group2") print "\nPFS group2 crypto maps:" for group in pfs2: print group.text non_aes = crypto_file.find_objects_wo_child(parentspec=r"crypto map CRYPTO", childspec="AES-SHA") print "\nNon-AES crypto map(s):" for group in non_aes: print group.text for i in group.children: print i.text
#!/usr/bin/env python #9 Find all of the crypto map entries that are using PFS group2 from ciscoconfparse import CiscoConfParse cisco_cfg = CiscoConfParse("cisco_crypto.txt") #crypto_cfg = cisco_cfg.find_objects(r"^crypto map CRYPTO") #cisco_cfg.find_objects_w_child(parentspec=r"^interface", childspec=r"no ip address") group_2_crypto = cisco_cfg.find_objects_w_child(parentspec=r"^crypto map CRYPTO", childspec=r"group2") print "\nThese Crypto Maps use PFS group 2" for line in group_2_crypto: print line.text
from ciscoconfparse import CiscoConfParse config = CiscoConfParse("cisco_ipsec.txt") list1 = config.find_objects(r"^crypto map CRYPTO") list2 = config.find_objects_w_child(parentspec=r"^crypto map CRYPTO", childspec=r"set pfs group2") list3 = config.find_objects_wo_child(parentspec=r"^crypto map CRYPTO", childspec=r"set transform-set AES*") for i in list1: for child in i.children: print child.text for i in list2: for child in i.children: print child.text for i in list3: for child in i.children: print child.text
#!/usr/bin/env python from ciscoconfparse import CiscoConfParse config = CiscoConfParse( "cisco_ipsec.txt" ) crypto_maps = config.find_objects_w_child( parentspec=r"^crypto map", childspec=r"pfs group2" ) for i in crypto_maps: print i.text + ":\n" for c in i.children: print c.text print "\n" exit()
from ciscoconfparse import CiscoConfParse config_file = CiscoConfParse("cisco_config.txt") crypto_map = config_file.find_objects(r"^crypto map CRYPTO") pfs_group2 = config_file.find_objects_w_child(parentspec = r"^crypto map CRYPTO", childspec = "set pfs group2") for i in pfs_group2: print i.text print i.children[2].text
fa4 = intf[3] for child in fa4.children: print child.text crypto_pki = cisco_cfg.find_objects(r"^crypto map CRYPTO") for child in crypto_pki: print child.text child.is_child child.is_parent child.parent child.all_parents crypto_pki = cisco_cfg.find_objects_w_child(parentspec=r"^crypto map CRYPTO",childspec=r"pfs group2") for child in crypto_pki: print child.text """ int_txt = CiscoConfParse("interface.txt") main_int = int_txt.find_objects(r"line protocol is") for i in main_int: print i.text vlan1 = i for child in vlan1.children: print child.text