[rancid] Error handler for Cisco switches in rancid.
Per-Olof Olsson
peo at chalmers.se
Mon Jun 24 07:49:41 UTC 2013
Hi
I don't think error handler is doing what is expected. (2.3.8)
After I added some extra debug, it shows that subroutines exit on
"pointer line" (lines like " ^ ") instead of error text lines.
For me it seems safer to use text lines for deciding how to exit.
rancid -d cisco-sw1
...
HIT COMMAND:cisco-sw1#dir /all sec-bootflash:
In DirSlotN: cisco-sw1#dir /all sec-bootflash:
SUB return(1) parsing line: ^
HIT COMMAND:cisco-sw1#dir /all sec-slot0:
In DirSlotN: cisco-sw1#dir /all sec-slot0:
SUB return(1) parsing line: ^
...
After replacing
< return(1) if (/^\s*\^\s*$/);
---
> next if (/^\s*\^\s*$/);
...
HIT COMMAND:cisco-sw1#dir /all sec-bootflash:
In DirSlotN: cisco-sw1#dir /all sec-bootflash:
SUB return(1) parsing line: % Invalid input detected at '^' marker.
HIT COMMAND:cisco-sw1#dir /all sec-slot0:
In DirSlotN: cisco-sw1#dir /all sec-slot0:
SUB return(1) parsing line: % Invalid input detected at '^' marker.
...
I only have a limited set of Cisco switches to test this on so
it's possible that this not will work on all devices using rancid (device type=cisco).
Some devices may depend on these "pointer lines" and is missing error handler for text.
Extende debug code:
diff -c rancid.in_ORG rancid
...
***************
*** 2129,2141 ****
--- 2210,2238 ----
last TOP;
}
$rval = &{$commands{$cmd}};
+ $_last_line = $_;
delete($commands{$cmd});
+ if ($rval != 0) {
+ print STDERR ("SUB return\($rval\) parsing line: $_last_line\n") if ($debug);
+ }
if ($rval == -1) {
$clean_run = 0;
+ print STDOUT ("$host: \"$cmd\" failed parsing line: $_last_line\n");
+ print STDERR ("$host: \"$cmd\" failed parsing line: $_last_line\n") if ($debug);
last TOP;
}
}
}
...
/Peo
----------------------------------------------------------
Per-Olof Olsson Email: peo at chalmers.se
Chalmers tekniska högskola IT-service
Hörsalsvägen 5 412 96 Göteborg
Tel: 031/772 6738 Fax: 031/772 8680
----------------------------------------------------------
More information about the Rancid-discuss
mailing list