[rancid] End of config in Extreme Switches

Paul Thornton prt at prt.org
Tue Oct 1 12:43:21 UTC 2013


Hi

I had exactly the same problem, and used the same "solution".

However, due to other Extreme oddities a diff for my current xrancid 
against the standard 2.3.8 release is full of debug.

However, the key things I changed to "fix" this (I'm sure others here 
will suggest better ways) are in the attached diff.  I've removed a load 
of my temp debug to tidy it up for you.

Note that I rely on a "# Module XYZ configuration" at the end of the 
config as well, and this almost certainly will break if the version on 
the switch changes.  It is very brittle as well because luckily all of 
the EXOS switches we have are X450 series and running the same software 
but if you have a number of different switches with different software 
then I can see this failing badly.

There are a number of nasty hacks here, so beware:

1) I've bypassed the last if ($prompt) in the main loop going through 
the output from the switch.
2) It relies on a 'Module xxx configuration' in some cases to spot the 
end of the show conf.
3) Detecting a clean run, I rely on the SSH message "Connection to 
myswitch.mydomain closed" message.  This has a hard-coded regex which 
happens to match all of my switch names; this should probably be the 
hostname.

As an emergency get-you-going this may help, but please realise that it 
isn't really general case production grade!

Paul.

On 01/10/2013 13:08, Aleksey P wrote:
> Hello to all.
> we use rancid 2.3.4 with Extreme Summit X670 and X650 with XOS 15.3.2.11.
> I know that in Extreme swithes there no "End of configuration file"
> string. To fix this I changed "xrancid" file:
>
>       -       if (/^# End of configuration file/i) {
>
>       -           printf STDERR "    End WriteTerm: $_" if ($debug);
>
>       -           $found_end = 1;
>
>       -           return(0);
>
>       -       }
>
> for
>
> + if (/^# Module vrrp configuration./i) {
>
> + printf STDERR " End WriteTerm: $_" if ($debug);
>
> + $found_end = 1;
>
> + return(0);
>
> + }
>
>
> So rancid found vrrp config and then exit.
> But now we use "mlag" on Extreme and its config below vrrp. So rancid
> exit before this config and we have some missed config lines.
> I tried rancid 2.3.8 (clean install on other server), with all default
> config files, but only see
> "...configuration appears to be truncated.
> ...missed cmd(s): show configuration"
> in logs.
>
> Help me please.
>
>
>
>
>
> _______________________________________________
> Rancid-discuss mailing list
> Rancid-discuss at shrubbery.net
> http://www.shrubbery.net/mailman/listinfo/rancid-discuss
>

-- 
Paul Thornton
-------------- next part --------------
--- ./xrancid.in	2011-12-22 20:21:34.000000000 +0000
+++ /usr/local/libexec/rancid/xrancid	2013-10-01 12:36:58.000000000 +0000
@@ -304,8 +309,9 @@
     my($comment) = 1;	# strip extra comments, esp to preserve chassis type
 
     while (<INPUT>) {
+
 	tr/\015//d;
-	last if(/^$prompt/);
+#	last if(/^$prompt/);
 	next if(/^\s*$/);
 	return(0) if (/^syntax error at token /i);
 	return(0) if (/^%% Invalid input detected at /i);
@@ -395,19 +403,29 @@
 	# catch anything that wasnt match above.
 	ProcessHistory("COMMENTS","keysort","H0","$_");
 	# end of config
-	if (/^# End of configuration file/i) {
+	if (/End of configuration file for/i) {
+	    printf STDERR "    End WriteTerm: $_" if ($debug);
+	    $found_end = 1;
+	    return(0);
+	}
+	if (/^# Module vsm configuration/i) {
 	    printf STDERR "    End WriteTerm: $_" if ($debug);
 	    $found_end = 1;
 	    return(0);
 	}
     }
 
     if ($lines < 3) {
 	printf(STDERR "ERROR: $host configuration appears to be truncated.\n");
 	$found_end = 0;
 	return(-1);
     }
     $found_end = 1;
 
     return(0);
 }
@@ -495,10 +512,14 @@
     # note: this match sucks rocks, but currently the extreme bits are
     # unreliable about echoing the 'exit\n' command.  this match might really
     # be a bad idea, but instead rely upon WriteTerm's found_end?
-    if (/$prompt\s?(quit|exit|Connection( to \S+)? closed)/ && $found_end) {
+    if (/$prompt\s?(quit|exit|Connection( to \S+)? closed|Received disconnect from)/ && $found_end) {
 	$clean_run = 1;
 	last;
     }
+    if (/^[Cc]onnection [Tt]o [\w\-\_\.]+ [Cc]losed/ && $found_end) {
+        $clean_run = 1;
+        last;
+    }
     if (/^Error:/) {
 	print STDOUT ("$host clogin error: $_");
 	print STDERR ("$host clogin error: $_") if ($debug);


More information about the Rancid-discuss mailing list