As of CiscoConfParse version 1.2.18, calling delete() on an IOSConfigLine() can delete too many config lines... this is an example....
from ciscoconfparse import CiscoConfParse
CONFIG = ['!',
'interface GigabitEthernet0/0',
' ip address 10.0.0.1 255.255.255.0',
'banner motd ^', ' trivial banner1 here ^', ## Deleting this banner line fails
'interface GigabitEthernet0/1',
' ip address 192.0.2.1 255.255.255.0',
'banner exec ^', ' trivial banner2 here ^',
'end']
parse = CiscoConfParse(CONFIG)
banner = parse.find_objects('banner motd')[0]
banner.delete()
parse.atomic()
The code above fails with:
Traceback (most recent call last):
File "banner.py", line 18, in <module>
banner.delete()
File "/home/mpenning/fail/ciscoconfparse/ccp_abc.py", line 198, in delete
child.delete()
File "/home/mpenning/fail/ciscoconfparse/ccp_abc.py", line 199, in delete
del self.confobj._list[self.linenum]
IndexError: list assignment index out of range
As of CiscoConfParse version 1.2.18, calling
delete()
on anIOSConfigLine()
can delete too many config lines... this is an example....The code above fails with: