Subject: | Fix for IOS-XR banners |
Date: | Wed, 11 Jul 2012 07:06:25 +0000 |
To: | "bug-Cisco-Reconfig [...] rt.cpan.org" <bug-Cisco-Reconfig [...] rt.cpan.org> |
From: | "Allan Houston (ZA)" <allan.houston [...] dimensiondata.com> |
Hi David,
As I mentioned in my email, the Cisco::Reconfig module is failing to parse my Cisco CRS-1's config due to a difference in the banner in IOS-XR. In normal IOS the banner termination characters get replaced with ^C, but apparently in IOS-XR it actually keeps your termination separator intact.
Here is the patch I've made to fix this:
--- Reconfig.pm.old 2012-07-11 09:00:29.359604270 +0200
+++ Reconfig.pm.fixed 2012-07-11 09:00:07.152114222 +0200
@@ -182,11 +182,13 @@
$last = $context;
- if ($line && $line =~ /\^C/ && $line !~ /\^C.*\^C/) {
+ my $seperator = "^C";
+ if ($line && ( $line =~ /banner [a-z\-]+ (.+)/ && $line !~ /^$1+/ )) {
#
# big special case for banners 'cause they don't follow
# normal indenting rules
#
+ $seperator = $1 if ($1); # Check for banner seperator not ^C
my $sub = $last->{$subs} = bless { $bloc => 1 }, __PACKAGE__;
$sub->{$cntx} = $last;
weaken $sub->{$cntx};
@@ -205,10 +207,10 @@
$l->{$cntx} = $subnull;
weaken($l->{$cntx});
push(@{$subnull->{$dupl}}, $l);
- last if $line =~ /\^C\r?$/;
+ last if ($line =~ /^$seperator+\r?$/);
}
warn "parse probably failed"
- unless ($line =~ /\^C[\r]?$/);
+ unless ($line =~ /^$seperator+[\r]?$/);
}
}
return $config;
Thanks,
Allan Houston
Senior Network Engineer - Metroconnect
This email and all contents are subject to the following disclaimer:
"http://www.dimensiondata.com/emaildisclaimer"