Closed bk2zsto closed 10 years ago
banner configs generated by IOS for show differ from those generated by copy
show generates a "^" followed by a "C" as the delimiter and inserts a comment before the next non-banner lines.
copy generates an actual ^C (\x03) as the delimiter and does not insert a comment after the end of the banner
0.9.30 handles show-style output but does not assign banner lines to their parent on copy-style output
See below to reproduce. Possible patch
$ cat tmp-confg.py #!/usr/bin/env python import sys sys.path[0] = "/tmp/ciscoconfparse/ciscoconfparse" import ciscoconfparse v = ciscoconfparse.__version__ p = ciscoconfparse.CiscoConfParse(sys.argv[1],linesplit_rgx="[\r\n]+", ignore_blank_lines=False) for o in p.ConfigObjs: print "("+v+") ", o.parent.linenum, ": ", o $ jobs [1]+ Stopped ssh 169.254.0.2 $ fg %1 router#sh run | redirect tftp://169.254.0.1/rtr.show ! router#~^Z [suspend ssh] $ ####### process config generated with "show run" with 0.9.30 $ ####### banner lines assigned to parent $ python ./tmp-confg.py rtr.show | sed -n '/banner /,/line con/p' (0.9.30) 380 : <IOSCfgLine # 380 'banner login ^C'> (0.9.30) 380 : <IOSCfgLine # 381 'Github, Incorporated Unauthorized Access Prohibited' (parent is # 380)> (0.9.30) 380 : <IOSCfgLine # 382 '=============================================================' (parent is # 380)> (0.9.30) 380 : <IOSCfgLine # 383 '^C' (parent is # 380)> (0.9.30) 384 : <IOSCfgLine # 384 '!'> (0.9.30) 385 : <IOSCfgLine # 385 'line con 0'> $ fg %1 router# router#copy run tftp://169.254.0.1/rtr.copy Address or name of remote host [169.254.0.1]? Destination filename [rtr.copy]? !! 11937 bytes copied in 1.952 secs (6115 bytes/sec) router#~^Z [suspend ssh] $ ####### process config generated with "copy run tftp" with 0.9.30 $ ####### banner lines not assigned to parent $ python ./tmp-confg.py rtr.copy | sed -n '/banner /,/line con/p' (0.9.30) 379 : <IOSCfgLine # 379 'banner login '> (0.9.30) 380 : <IOSCfgLine # 380 'Github, Incorporated Unauthorized Access Prohibited'> (0.9.30) 381 : <IOSCfgLine # 381 '============================================================='> (0.9.30) 382 : <IOSCfgLine # 382 ''> (0.9.30) 383 : <IOSCfgLine # 383 '!'> (0.9.30) 384 : <IOSCfgLine # 384 'line con 0'>
Just wondering if I shud submit as a PR instead of an issue?
This should be fixed in CiscoConfParse version 0.9.32. Thank you for reporting the bug.
banner configs generated by IOS for show differ from those generated by copy
show generates a "^" followed by a "C" as the delimiter and inserts a comment before the next non-banner lines.
copy generates an actual ^C (\x03) as the delimiter and does not insert a comment after the end of the banner
0.9.30 handles show-style output but does not assign banner lines to their parent on copy-style output
See below to reproduce. Possible patch