Discussion:
[rancid] supermicro switch (again)
Marcin Dulak
2016-11-15 17:09:20 UTC
Permalink
Hi,

I read through this thread ending with no solution
http://www.shrubbery.net/pipermail/rancid-discuss/2013-November/007279.html

Things I have tried:

Version rancid-3.1-4.el6.x86_64

0.
add to ~rancid/.cloginrc the supermicro-switch settings

add autoenable supermicro-switch 1
add user supermicro-switch username
add password supermicro-switch password password
add method supermicro-switch ssh


1.
clogin shows errors out-of-the-box, this is expected

rancid $ clogin -c"show version" supermicro-switch
supermicro-switch
spawn ssh -c 3des -x -l username supermicro-switch
***@supermicro-switch's password:

Supermicro Switch

supermicro-switch#
supermicro-switch# terminal length 0
% Invalid Command
supermicro-switch# terminal width 132
% Invalid Command
supermicro-switch# show version
Switch ID Hardware Version Firmware Version OS
Version
0 XXX-XXXX Rev. X (XX-XX) X.X.X-X X.X.X
supermicro-switch#exit

2.
copy clogin to smlogin

root # cp /usr/libexec/rancid/clogin /usr/libexec/rancid/smlogin

and replace the offending
send "terminal length 0\r" and send "terminal width 132\r" with with send
"\r"

After that this returns without errors:

rancid $ smlogin -c"show version" supermicro-switch

3.
rancid $ rancid -d supermicro-switch
loadtype(): device_type is empty
Couldn't load device type spec for

So I add to /etc/rancid/rancid.types.base:

supermicro;script;rancid -t supermicro
supermicro;login;smlogin
supermicro;inloop;supermicro::inloop
supermicro;command;supermicro::ShowVersion;show version
supermicro;command;supermicro::WriteTerm;show running-config

and then:

rancid $ rancid -d -t supermicro supermicro-switch
loadtype: device type supermicro
loadtype: found device type supermicro in /etc/rancid/rancid.types.base
executing smlogin -t 90 -c"show version;show running-config"
supermicro-switch
supermicro-switch: missed cmd(s): all commands
supermicro-switch: End of run not found
supermicro-switch: End of run not found

but as we know executing directly on the command line works: smlogin -t 90
-c"show version;show running-config" supermicro-switch

To further debug I create `cp /usr/libexec/rancid/rancid
/usr/libexec/rancid/smrancid` and point to it with
supermicro;script;smrancid -t supermicro
but my guess is wrong: some other script than /usr/libexec/rancid/smrancid
is executed during `rancid -d -t supermicro supermicro-switch`

How to debug this further?

Regards,

Marcin
heasley
2016-11-16 20:14:01 UTC
Permalink
Post by Marcin Dulak
Hi,
I read through this thread ending with no solution
http://www.shrubbery.net/pipermail/rancid-discuss/2013-November/007279.html
Version rancid-3.1-4.el6.x86_64
0.
add to ~rancid/.cloginrc the supermicro-switch settings
add autoenable supermicro-switch 1
add user supermicro-switch username
add password supermicro-switch password password
add method supermicro-switch ssh
1.
clogin shows errors out-of-the-box, this is expected
rancid $ clogin -c"show version" supermicro-switch
supermicro-switch
spawn ssh -c 3des -x -l username supermicro-switch
Supermicro Switch
supermicro-switch#
supermicro-switch# terminal length 0
% Invalid Command
supermicro-switch# terminal width 132
% Invalid Command
supermicro-switch# show version
Switch ID Hardware Version Firmware Version OS
Version
0 XXX-XXXX Rev. X (XX-XX) X.X.X-X X.X.X
supermicro-switch#exit
2.
copy clogin to smlogin
root # cp /usr/libexec/rancid/clogin /usr/libexec/rancid/smlogin
and replace the offending
send "terminal length 0\r" and send "terminal width 132\r" with with send
"\r"
so, how do you turn of the pager?

does supermicro actually make the switch, or is it an OEM for which a script
may already exist.
Post by Marcin Dulak
rancid $ smlogin -c"show version" supermicro-switch
3.
rancid $ rancid -d supermicro-switch
loadtype(): device_type is empty
Couldn't load device type spec for
supermicro;script;rancid -t supermicro
This implies that there is a lib/supermicro.pm library.
Post by Marcin Dulak
supermicro;login;smlogin
supermicro;inloop;supermicro::inloop
supermicro;command;supermicro::ShowVersion;show version
supermicro;command;supermicro::WriteTerm;show running-config
rancid $ rancid -d -t supermicro supermicro-switch
loadtype: device type supermicro
loadtype: found device type supermicro in /etc/rancid/rancid.types.base
executing smlogin -t 90 -c"show version;show running-config"
supermicro-switch
supermicro-switch: missed cmd(s): all commands
supermicro-switch: End of run not found
supermicro-switch: End of run not found
but as we know executing directly on the command line works: smlogin -t 90
-c"show version;show running-config" supermicro-switch
To further debug I create `cp /usr/libexec/rancid/rancid
/usr/libexec/rancid/smrancid` and point to it with
supermicro;script;smrancid -t supermicro
but my guess is wrong: some other script than /usr/libexec/rancid/smrancid
is executed during `rancid -d -t supermicro supermicro-switch`
How to debug this further?
i'd start with rancid 3.5.1.
Marcin Dulak
2016-11-17 13:12:31 UTC
Permalink
Post by Marcin Dulak
Post by Marcin Dulak
Hi,
I read through this thread ending with no solution
http://www.shrubbery.net/pipermail/rancid-discuss/2013-
November/007279.html
Post by Marcin Dulak
Version rancid-3.1-4.el6.x86_64
0.
add to ~rancid/.cloginrc the supermicro-switch settings
add autoenable supermicro-switch 1
add user supermicro-switch username
add password supermicro-switch password password
add method supermicro-switch ssh
1.
clogin shows errors out-of-the-box, this is expected
rancid $ clogin -c"show version" supermicro-switch
supermicro-switch
spawn ssh -c 3des -x -l username supermicro-switch
Supermicro Switch
supermicro-switch#
supermicro-switch# terminal length 0
% Invalid Command
supermicro-switch# terminal width 132
% Invalid Command
supermicro-switch# show version
Switch ID Hardware Version Firmware Version OS
Version
0 XXX-XXXX Rev. X (XX-XX) X.X.X-X X.X.X
supermicro-switch#exit
2.
copy clogin to smlogin
root # cp /usr/libexec/rancid/clogin /usr/libexec/rancid/smlogin
and replace the offending
send "terminal length 0\r" and send "terminal width 132\r" with with send
"\r"
so, how do you turn of the pager?
https://www.supermicro.com/manuals/other/SM-CLI-Guide.pdf page 72: no cli
pagination
Post by Marcin Dulak
does supermicro actually make the switch, or is it an OEM for which a script
may already exist.
Post by Marcin Dulak
rancid $ smlogin -c"show version" supermicro-switch
3.
rancid $ rancid -d supermicro-switch
loadtype(): device_type is empty
Couldn't load device type spec for
supermicro;script;rancid -t supermicro
This implies that there is a lib/supermicro.pm library.
Post by Marcin Dulak
supermicro;login;smlogin
supermicro;inloop;supermicro::inloop
supermicro;command;supermicro::ShowVersion;show version
supermicro;command;supermicro::WriteTerm;show running-config
rancid $ rancid -d -t supermicro supermicro-switch
loadtype: device type supermicro
loadtype: found device type supermicro in /etc/rancid/rancid.types.base
executing smlogin -t 90 -c"show version;show running-config"
supermicro-switch
supermicro-switch: missed cmd(s): all commands
supermicro-switch: End of run not found
supermicro-switch: End of run not found
but as we know executing directly on the command line works: smlogin -t
90
Post by Marcin Dulak
-c"show version;show running-config" supermicro-switch
To further debug I create `cp /usr/libexec/rancid/rancid
/usr/libexec/rancid/smrancid` and point to it with
supermicro;script;smrancid -t supermicro
but my guess is wrong: some other script than
/usr/libexec/rancid/smrancid
Post by Marcin Dulak
is executed during `rancid -d -t supermicro supermicro-switch`
How to debug this further?
i'd start with rancid 3.5.1.
I'm at the latest version now.

$ rancid -V
rancid 3.5.1

$ cat ~/.cloginrc
add autoenable supermicro-switch 1
add user supermicro-switch username
add password supermicro-switch password password
add method supermicro-switch ssh

Created smlogin based on blogin so `smlogin -c"show version"
supermicro-switch` runs fine:

$ diff usr/libexec/rancid/blogin usr/libexec/rancid/smlogin
501c501
< send "more off\r"
---
Post by Marcin Dulak
send "no cli pagination\r"
Now, most of the posts suggest that the reason for getting "End of run not
found" is that rancid does not recognize
when the session to the switch is terminated. On Supermicro that seems to
be "supermicro-switch#exit".

I'm trying to find out the workflow of rancid in order to make the
adjustments:

$ grep '#exit\$' usr/share/perl5/vendor_perl/rancid/*
usr/share/perl5/vendor_perl/rancid/edgemax.pm: if (/\#exit$/) {
usr/share/perl5/vendor_perl/rancid/foundry.pm: if (/\#exit$/) {

$ grep '#exit\$' usr/libexec/rancid/*
usr/libexec/rancid/rrancid: if (/\#exit$/) {

First question: what is the purpose of usr/libexec/rancid/rrancid compared
to the perl modules under usr/share/perl5/vendor_perl/rancid?

Second question - I'm doing:

$ cat etc/rancid/rancid.types.conf
supermicro;script;rrancid
supermicro;login;smlogin
supermicro;inloop;edgemax::inloop
supermicro;command;edgemax::ShowVersion;show version

but I can see that there seem to be no effect due to what I write for some
of these options, e.g. I can do without errors:
supermicro;script;dummy
supermicro;login;smlogin
supermicro;inloop;dummy::inloop

I would imagine something like that would be caught by rancid configuration
parser as incorrect and prevent the run?

Adding debug prints to the check for completness in
usr/libexec/rancid/rancid (also suggested in some posts) is not helpful:
printf(STDERR "$host: missed cmd(s): all commands\n");
printf(STDERR "$host: $clean_run\n");
printf(STDERR "$host: $found_end\n");

$ rancid -d -t supermicro supermicro-switch
loadtype: device type supermicro
loadtype: found device type supermicro in ./etc/rancid/rancid.types.conf
executing smlogin -t 90 -c"show version" supermicro-switch
supermicro-switch: missed cmd(s): all commands
supermicro-switch: 0
supermicro-switch: 0
supermicro-switch: End of run not found

Marcin
heasley
2016-11-21 06:35:21 UTC
Permalink
Post by Marcin Dulak
Now, most of the posts suggest that the reason for getting "End of run not
found" is that rancid does not recognize
when the session to the switch is terminated. On Supermicro that seems to
be "supermicro-switch#exit".
That is
if (!$clean_run || !$found_end) {
if !(command failure or undefined function or unexpected command or end of
session missing)
or
!(found end of the config)
Post by Marcin Dulak
I'm trying to find out the workflow of rancid in order to make the
$ grep '#exit\$' usr/share/perl5/vendor_perl/rancid/*
usr/share/perl5/vendor_perl/rancid/edgemax.pm: if (/\#exit$/) {
usr/share/perl5/vendor_perl/rancid/foundry.pm: if (/\#exit$/) {
$ grep '#exit\$' usr/libexec/rancid/*
usr/libexec/rancid/rrancid: if (/\#exit$/) {
First question: what is the purpose of usr/libexec/rancid/rrancid compared
to the perl modules under usr/share/perl5/vendor_perl/rancid?
rancid is function used by some (eventually all) of the rancid modules.
rrancid is the redback module.
Post by Marcin Dulak
$ cat etc/rancid/rancid.types.conf
supermicro;script;rrancid
supermicro;login;smlogin
supermicro;inloop;edgemax::inloop
supermicro;command;edgemax::ShowVersion;show version
but I can see that there seem to be no effect due to what I write for some
supermicro;script;dummy
supermicro;login;smlogin
supermicro;inloop;dummy::inloop
I would imagine something like that would be caught by rancid configuration
parser as incorrect and prevent the run?
how would it know until it tries to import the module? I did add recently
for 3.6:

rancid.pm: check for existence of functions for given device type after
loading the modules for the type. return failure if any are missing.
Post by Marcin Dulak
Adding debug prints to the check for completness in
printf(STDERR "$host: missed cmd(s): all commands\n");
printf(STDERR "$host: $clean_run\n");
printf(STDERR "$host: $found_end\n");
$ rancid -d -t supermicro supermicro-switch
loadtype: device type supermicro
loadtype: found device type supermicro in ./etc/rancid/rancid.types.conf
executing smlogin -t 90 -c"show version" supermicro-switch
split it into pieces;

eval `rancid -C -t supermicro supermicro-switch` >output

make sure that works. then work on the module

rancid -d -t supermicro -f output
Post by Marcin Dulak
supermicro-switch: missed cmd(s): all commands
supermicro-switch: 0
supermicro-switch: 0
supermicro-switch: End of run not found
Marcin
Marcin Dulak
2016-11-21 09:26:25 UTC
Permalink
Post by heasley
Post by Marcin Dulak
Now, most of the posts suggest that the reason for getting "End of run
not
Post by Marcin Dulak
found" is that rancid does not recognize
when the session to the switch is terminated. On Supermicro that seems to
be "supermicro-switch#exit".
That is
if (!$clean_run || !$found_end) {
if !(command failure or undefined function or unexpected command or end of
session missing)
or
!(found end of the config)
Post by Marcin Dulak
I'm trying to find out the workflow of rancid in order to make the
$ grep '#exit\$' usr/share/perl5/vendor_perl/rancid/*
usr/share/perl5/vendor_perl/rancid/edgemax.pm: if (/\#exit$/) {
usr/share/perl5/vendor_perl/rancid/foundry.pm: if (/\#exit$/) {
$ grep '#exit\$' usr/libexec/rancid/*
usr/libexec/rancid/rrancid: if (/\#exit$/) {
First question: what is the purpose of usr/libexec/rancid/rrancid
compared
Post by Marcin Dulak
to the perl modules under usr/share/perl5/vendor_perl/rancid?
rancid is function used by some (eventually all) of the rancid modules.
rrancid is the redback module.
Post by Marcin Dulak
$ cat etc/rancid/rancid.types.conf
supermicro;script;rrancid
supermicro;login;smlogin
supermicro;inloop;edgemax::inloop
supermicro;command;edgemax::ShowVersion;show version
but I can see that there seem to be no effect due to what I write for
some
Post by Marcin Dulak
supermicro;script;dummy
supermicro;login;smlogin
supermicro;inloop;dummy::inloop
I would imagine something like that would be caught by rancid
configuration
Post by Marcin Dulak
parser as incorrect and prevent the run?
how would it know until it tries to import the module? I did add recently
rancid.pm: check for existence of functions for given device type after
loading the modules for the type. return failure if any are missing.
Post by Marcin Dulak
Adding debug prints to the check for completness in
printf(STDERR "$host: missed cmd(s): all commands\n");
printf(STDERR "$host: $clean_run\n");
printf(STDERR "$host: $found_end\n");
$ rancid -d -t supermicro supermicro-switch
loadtype: device type supermicro
loadtype: found device type supermicro in ./etc/rancid/rancid.types.conf
executing smlogin -t 90 -c"show version" supermicro-switch
split it into pieces;
eval `rancid -C -t supermicro supermicro-switch` >output
this works.
Post by heasley
make sure that works. then work on the module
naively I do:
cp usr/share/perl5/vendor_perl/rancid/edgemax.pm
usr/share/perl5/vendor_perl/rancid/supermicro.pm
change "package supermicro;" on the top and add a print STDERR ("I'm
here"); to ShowVersion,
but "I'm here" does no appear in the output of:
$ rancid -d -t supermicro supermicro-switch

This goes back to my question: what gets executed when I replace
"supermicro::" with "dummy::" in

$ cat ./etc/rancid/rancid.types.conf
supermicro;script;rancid
supermicro;login;smlogin
supermicro;inloop;supermicro::inloop
supermicro;command;supermicro::ShowVersion;show version

Marcin
Post by heasley
rancid -d -t supermicro -f output
Post by Marcin Dulak
supermicro-switch: missed cmd(s): all commands
supermicro-switch: 0
supermicro-switch: 0
supermicro-switch: End of run not found
Marcin
heasley
2016-11-21 15:33:10 UTC
Permalink
Post by Marcin Dulak
cp usr/share/perl5/vendor_perl/rancid/edgemax.pm
usr/share/perl5/vendor_perl/rancid/supermicro.pm
change "package supermicro;" on the top and add a print STDERR ("I'm
here"); to ShowVersion,
you havent a module line in the device config below, so the module is not
loaded.
Post by Marcin Dulak
$ rancid -d -t supermicro supermicro-switch
This goes back to my question: what gets executed when I replace
"supermicro::" with "dummy::" in
$ cat ./etc/rancid/rancid.types.conf
supermicro;script;rancid
supermicro;login;smlogin
supermicro;inloop;supermicro::inloop
supermicro;command;supermicro::ShowVersion;show version
Marcin Dulak
2016-11-22 12:47:00 UTC
Permalink
Post by heasley
Post by Marcin Dulak
cp usr/share/perl5/vendor_perl/rancid/edgemax.pm
usr/share/perl5/vendor_perl/rancid/supermicro.pm
change "package supermicro;" on the top and add a print STDERR ("I'm
here"); to ShowVersion,
you havent a module line in the device config below, so the module is not
loaded.
thanks, this was missing. It was also important to specify the module to be
used with "supermicro;script;rancid -t supermicro".
Based on rancid-3.5.1, I managed to get the basic information out of the
switch with the following changes:

$ cat etc/rancid/rancid.types.conf
supermicro;script;rancid -t supermicro
supermicro;login;smlogin
supermicro;inloop;supermicro::inloop
supermicro;module;supermicro
supermicro;command;supermicro::ShowVersion;show version
supermicro;command;supermicro::WriteTerm;show running-config

$ cd usr/share/perl5/vendor_perl/rancid/
$ cp edgemax.pm supermicro.pm
$ cd -
$ patch -p0 < ../module.patch

$ cd usr/libexec/rancid/
$ cp blogin smlogin
$ patch -p0 < ../login.patch

with the patches:

--- usr/share/perl5/vendor_perl/rancid/supermicro.pm.orig 2016-11-22
10:03:53.393367703 +0100
+++ usr/share/perl5/vendor_perl/rancid/supermicro.pm 2016-11-22
10:32:52.577324682 +0100
@@ -1,6 +1,6 @@
-package edgemax;
+package supermicro;
##
-## $Id: edgemax.pm.in 3376 2016-04-06 17:52:30Z heas $
+## $Id: supermicro.pm.in 3376 2016-04-06 17:52:30Z heas $
##
## rancid 3.5.1
## Copyright (c) 1997-2016 by Terrapin Communications, Inc.
@@ -54,7 +54,7 @@
#
# RANCID - Really Awesome New Cisco confIg Differ
#
-# edgemax.pm - Ubiquity ("UBNT") EdgeMAX switch rancid procedures
+# supermicro.pm - Supermicro switch rancid procedures

use 5.010;
use strict 'vars';
@@ -120,7 +120,7 @@
last TOP;
}
}
- if (/\#exit$/) {
+ if (/\# logout$/) {
$clean_run = 1;
last;
}
@@ -337,7 +337,7 @@

ProcessHistory("","","","$_");
# end of config
- if (/^end$/) {
+ if (/\# logout$/) {
$found_end = 1;
return(1);
}

--- usr/libexec/rancid/smlogin.orig 2016-11-22 10:03:43.265367954 +0100
+++ usr/libexec/rancid/smlogin 2016-11-22 10:30:54.329327607 +0100
@@ -1,6 +1,6 @@
-#! /bin/expect --
+#! /usr/bin/expect --
##
-## $Id: blogin.in 3445 2016-08-10 17:15:38Z heas $
+## $Id: smlogin.in 3445 2016-08-10 17:15:38Z heas $
##
## rancid 3.5.1
## Copyright (c) 1997-2016 by Terrapin Communications, Inc.
@@ -52,7 +52,7 @@
# The original looking glass software was written by Ed Kern, provided by
# permission and modified beyond recognition.
#
-# blogin - Bay Networks(Nortel) login
+# smlogin - Supermicro login
#
# Unlike the Cisco's, there is no enable function on the Bay's. Instead
# there are seperate User and Manager accounts. A 'system' command exists,
@@ -498,7 +498,7 @@
global in_proc
set in_proc 1

- send "more off\r"
+ send "no cli pagination\r"

expect $prompt {}

Cleaning usr/libexec/rancid/smlogin, usr/share/perl5/vendor_perl/rancid/
supermicro.pm and making them fully functional for Supermicro would be a
large task.
It would be nicer to have minimal templates to start with, and build the
functionality gradually.

Marcin
Post by heasley
Post by Marcin Dulak
$ rancid -d -t supermicro supermicro-switch
This goes back to my question: what gets executed when I replace
"supermicro::" with "dummy::" in
$ cat ./etc/rancid/rancid.types.conf
supermicro;script;rancid
supermicro;login;smlogin
supermicro;inloop;supermicro::inloop
supermicro;command;supermicro::ShowVersion;show version
heasley
2016-12-07 17:38:50 UTC
Permalink
Post by Marcin Dulak
Post by heasley
Post by Marcin Dulak
cp usr/share/perl5/vendor_perl/rancid/edgemax.pm
usr/share/perl5/vendor_perl/rancid/supermicro.pm
change "package supermicro;" on the top and add a print STDERR ("I'm
here"); to ShowVersion,
you havent a module line in the device config below, so the module is not
loaded.
thanks, this was missing. It was also important to specify the module to be
used with "supermicro;script;rancid -t supermicro".
Based on rancid-3.5.1, I managed to get the basic information out of the
$ cat etc/rancid/rancid.types.conf
supermicro;script;rancid -t supermicro
supermicro;login;smlogin
supermicro;inloop;supermicro::inloop
supermicro;module;supermicro
supermicro;command;supermicro::ShowVersion;show version
supermicro;command;supermicro::WriteTerm;show running-config
do you/anyone have one of these that I can access remotely?

Loading...