0

Lookout if you process Cisco IOS-XR configuration files

I lost too much time just doing a simple script: checking for a class-map configuration across several backup configuration files. And it never matched!

The problem should be with me or my script as I knew it was all ok on some of the files.

However after bouncing my head several times I found the issue.

Some of the configuration has trailing spaces at the end of the line!

At first I thought it was may be a problem with RANCID. But it was not.

To make this visible I just issued something like this at the router prompt

sh run | b ^class-map match-any CORE-VOICE

And copy-pasted some lines to vim that gave me this

ios-xr-with-trailing-spaces

The red squares show that there are spaces at the end of two lines!

It’s a nice feature to have active on vim. Just add these two lines to your ~/.vimrc

highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/

So, next time you have to chew some IOS-XR configurations files don’t forget to right trim all those lines!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.