I've read the examples which seem similar but I am not at that level to understand the answers. I want to take the list output and write each interface as a separate line (aka list I write to a csv)
. I need to split the initial return list on the keyword 'interface Vlan*'
I want to split returned list vlanlist on keyword interface vlan*
into separate lists
from ciscoconfparse import CiscoConfParse
import os
for filename in os.listdir():
if filename.endswith(".cfg"):
p = CiscoConfParse(filename)
vlanlist=(p.find_all_children('^interface Vlan'))
vlanlist.insert(0,filename)
print(vlanlist)
This is one line of output. I need to split the list on keyword "interface vlanxxx"
into separate lines
[ 'interface Vlan1', ' no ip address', ' shutdown', 'interface Vlan2003', ' description XXXXXX', ' ip address 10.224.6.130 255.255.255.224', ' no ip redirects', ' no ip unreachables', ' no ip proxy-arp', ' load-interval 60', ' arp timeout 420']
Desired OUTPUT (this may have 2-20 diferent interfaces I want to split on depending on config file)
['interface Vlan1' ' no ip address', ' shutdown']
['interface Vlan2003', ' description XXXXXX', ' ip address 10.224.6.130 255.255.255.224', ' no ip redirects', ' no ip unreachables', ' no ip proxy-arp', ' load-interval 60', ' arp timeout 420']