Discussion:
[rancid] Fixed Ciena-ws Rancid 3.6.2
Tanner Lyle
2017-06-19 17:14:37 UTC
Permalink
Ciena Engineer provided the changes needed, prompts were not matching make
following changes to your wavesvros.pm file in /usr/local/rancid/lib/rancid/

[***@localhost rancid]$ pwd
/usr/local/rancid/lib/rancid

*wavesvros.pm <http://wavesvros.pm>*

*Line 112*
*change this line*
while (/>\s*($cmds_regexp)\s*$/) {
*to this *
while (/[#]\s*($cmds_regexp)\s*$/) {


*Line 115*
*change this line*
$prompt = ($_ =~ /^([^>]+>)/)[0];
*to this*
$prompt = ($_ =~ /^([^#]+#)/)[0];


*Line 140*
*change this line*
if (/>\s*exit/) {
*to this*
if (/\s*exit/) {


*Line 207 add *
$found_end = 0;

*from this*

# This routine parses "configuration show"
sub WriteTerm {
my($INPUT, $OUTPUT, $cmd) = @_;
my($snmp) = 0;
print STDERR " In ShowConfiguration: $_" if ($debug);

# include the command

*to this*

# This routine parses "configuration show"
sub WriteTerm {
my($INPUT, $OUTPUT, $cmd) = @_;
my($snmp) = 0;
$found_end = 0;
print STDERR " In ShowConfiguration: $_" if ($debug);

# include the command

*Original line 212 now line 214*

*from this *

while (<$INPUT>) {
tr/\015//d;
last if (/^$prompt/);
/no matching entry found/ && return(-1); # unknown cmd

*to this*

while (<$INPUT>) {
tr/\015//d;
return (0) if (/^$prompt/);
/no matching entry found/ && return(-1); # unknown cmd
return (0) if ($found_end == 1);


*Change Line 265*

*from this*

if (/^! END OF CONFIG:/) {

*to this*

if (/! END OF CONFIG:/) {



For those of you better at reading diffs than me

[***@localhost rancid]$ diff wavesvros.pm wavesvros.pm.orig

112c112
< while (/[#]\s*($cmds_regexp)\s*$/) {
---
while (/>\s*($cmds_regexp)\s*$/) {
115c115
< $prompt = ($_ =~ /^([^#]+#)/)[0];
---
$prompt = ($_ =~ /^([^>]+>)/)[0];
140c140
< if (/\s*exit/) {
---
if (/>\s*exit/) {
207d206
< $found_end = 0;
215c214
< return (0) if (/^$prompt/);
---
last if (/^$prompt/);
217d215
< return (0) if ($found_end == 1);
265c263
< if (/! END OF CONFIG:/) {
---
if (/^! END OF CONFIG:/) {
---------- Forwarded message ----------
From: Tanner Lyle <***@gmail.com>
Date: Thu, Jun 8, 2017 at 7:29 AM
Subject: Help ciena-ws Rancid 3.6.2
To: rancid-***@shrubbery.net


I cannot get a Ciena Waveserver (192.168.168.32 in the files) to complete,
all commands run and login works but never makes it to the parse output or
get a PROMPT MATCH: like it's trying to run the perl module against the
device. Trying to gain some traction on this, out of ideas and know how to
trouble shoot it. Any suggestions, i think the problem is still in hlogin
or in the wavesvros.pm.

[***@localhost logs]$ export NOPIPE=YES && rancid -d -t ciena-ws
192.168.168.32
loadtype: device type ciena-ws
loadtype: found device type ciena-ws in /usr/local/rancid/etc/rancid.t
ypes.base
executing hlogin -t 120 -c"software show;chassis show;configuration show"
192.168.168.32
192.168.168.32: missed cmd(s): all commands
192.168.168.32: End of run not found
!


I can get different devices to complete and run so i don't think it's a
permissions or install issue

[***@localhost logs]$ export NOPIPE=YES && rancid -d -t foundry 10.0.2.2
loadtype: device type foundry
loadtype: found device type foundry in /usr/local/rancid/etc/rancid.t
ypes.base
executing flogin -t 90 -c"show version;show chassis;show module;show
media;show media validation;show flash;write term;show running-config"
10.0.2.2
PROMPT MATCH: ***@LAB_MLX16#
HIT COMMAND:***@LAB_MLX16#show version
In ShowVersion: ***@LAB_MLX16#show version
HIT COMMAND:***@LAB_MLX16#show chassis
In ShowChassis: ***@LAB_MLX16#show chassis
HIT COMMAND:***@LAB_MLX16#show module
In ShowModule: ***@LAB_MLX16#show module
HIT COMMAND:***@LAB_MLX16#show media
In ShowMedia: ***@LAB_MLX16#show media
HIT COMMAND:***@LAB_MLX16#show media validation
In ShowMedia: ***@LAB_MLX16#show media validation
HIT COMMAND:***@LAB_MLX16#show flash
In ShowFlash: ***@LAB_MLX16#show flash
HIT COMMAND:***@LAB_MLX16#write term
In WriteTerm: ***@LAB_MLX16#write term
HIT COMMAND:***@LAB_MLX16#show running-config
In WriteTerm: ***@LAB_MLX16#show running-config
heasley
2017-07-19 15:48:28 UTC
Permalink
Post by Tanner Lyle
Ciena Engineer provided the changes needed, prompts were not matching make
following changes to your wavesvros.pm file in /usr/local/rancid/lib/rancid/
/usr/local/rancid/lib/rancid
*wavesvros.pm <http://wavesvros.pm>*
*Line 112*
*change this line*
while (/>\s*($cmds_regexp)\s*$/) {
*to this *
while (/[#]\s*($cmds_regexp)\s*$/) {
*Line 115*
*change this line*
$prompt = ($_ =~ /^([^>]+>)/)[0];
*to this*
$prompt = ($_ =~ /^([^#]+#)/)[0];
These changes do not seem right to me. i understand that its working for
you, but i'm not sure that it will be reliable.

Also, of the 4 raw command output examples that i have, all of them have
the prompt ">", not "#". Can you tell me why it is different? keep in
mind that I havent much experience with these and we no longer have them.

If someone could extend remote access to me, I can feel more comfortable
accepting these changes. anyone?
Post by Tanner Lyle
*Line 140*
*change this line*
if (/>\s*exit/) {
*to this*
if (/\s*exit/) {
*Line 207 add *
$found_end = 0;
*from this*
# This routine parses "configuration show"
sub WriteTerm {
my($snmp) = 0;
print STDERR " In ShowConfiguration: $_" if ($debug);
# include the command
*to this*
# This routine parses "configuration show"
sub WriteTerm {
my($snmp) = 0;
$found_end = 0;
print STDERR " In ShowConfiguration: $_" if ($debug);
# include the command
*Original line 212 now line 214*
*from this *
while (<$INPUT>) {
tr/\015//d;
last if (/^$prompt/);
/no matching entry found/ && return(-1); # unknown cmd
*to this*
while (<$INPUT>) {
tr/\015//d;
return (0) if (/^$prompt/);
/no matching entry found/ && return(-1); # unknown cmd
return (0) if ($found_end == 1);
*Change Line 265*
*from this*
if (/^! END OF CONFIG:/) {
*to this*
if (/! END OF CONFIG:/) {
For those of you better at reading diffs than me
112c112
< while (/[#]\s*($cmds_regexp)\s*$/) {
---
Post by Tanner Lyle
while (/>\s*($cmds_regexp)\s*$/) {
115c115
< $prompt = ($_ =~ /^([^#]+#)/)[0];
---
Post by Tanner Lyle
$prompt = ($_ =~ /^([^>]+>)/)[0];
140c140
< if (/\s*exit/) {
---
Post by Tanner Lyle
if (/>\s*exit/) {
207d206
< $found_end = 0;
215c214
< return (0) if (/^$prompt/);
---
Post by Tanner Lyle
last if (/^$prompt/);
217d215
< return (0) if ($found_end == 1);
265c263
< if (/! END OF CONFIG:/) {
---
Post by Tanner Lyle
if (/^! END OF CONFIG:/) {
---------- Forwarded message ----------
Date: Thu, Jun 8, 2017 at 7:29 AM
Subject: Help ciena-ws Rancid 3.6.2
I cannot get a Ciena Waveserver (192.168.168.32 in the files) to complete,
all commands run and login works but never makes it to the parse output or
get a PROMPT MATCH: like it's trying to run the perl module against the
device. Trying to gain some traction on this, out of ideas and know how to
trouble shoot it. Any suggestions, i think the problem is still in hlogin
or in the wavesvros.pm.
192.168.168.32
loadtype: device type ciena-ws
loadtype: found device type ciena-ws in /usr/local/rancid/etc/rancid.t
ypes.base
executing hlogin -t 120 -c"software show;chassis show;configuration show"
192.168.168.32
192.168.168.32: missed cmd(s): all commands
192.168.168.32: End of run not found
!
I can get different devices to complete and run so i don't think it's a
permissions or install issue
loadtype: device type foundry
loadtype: found device type foundry in /usr/local/rancid/etc/rancid.t
ypes.base
executing flogin -t 90 -c"show version;show chassis;show module;show
media;show media validation;show flash;write term;show running-config"
10.0.2.2
_______________________________________________
Rancid-discuss mailing list
http://www.shrubbery.net/mailman/listinfo/rancid-discuss
Chris Wopat
2017-07-19 20:43:07 UTC
Permalink
Post by heasley
These changes do not seem right to me. i understand that its working for
you, but i'm not sure that it will be reliable.
Also, of the 4 raw command output examples that i have, all of them have
the prompt ">", not "#". Can you tell me why it is different? keep in
mind that I havent much experience with these and we no longer have them.
If someone could extend remote access to me, I can feel more comfortable
accepting these changes. anyone?
The prompt varies depending on userlevel. If you're the superuser
account, it's #. If you're a read only or perhaps generally lesser user,
it's >.

My user is defined as:

user create user MYUSERNAME access-level limited

I just tested this patch WITHOUT the prompt changes for my user, which
is a read only user, and it seemed to work!

It sounds like the best case would be to adjust regexp to match # or >.

--Chris
heasley
2017-07-21 15:35:04 UTC
Permalink
Post by Tanner Lyle
Ciena Engineer provided the changes needed, prompts were not matching make
following changes to your wavesvros.pm file in /usr/local/rancid/lib/rancid/
*Line 140*
*change this line*
if (/>\s*exit/) {
*to this*
if (/\s*exit/) {
This should not be necessary; and would/could be a problem. if this is
still necesary after the patch I sent, there is another problem that
this change is masking.
Post by Tanner Lyle
*Line 207 add *
$found_end = 0;
This is already initialized in rancid.pm. What is the error that led to
this change?
Post by Tanner Lyle
*from this*
# This routine parses "configuration show"
sub WriteTerm {
my($snmp) = 0;
print STDERR " In ShowConfiguration: $_" if ($debug);
# include the command
*to this*
# This routine parses "configuration show"
sub WriteTerm {
my($snmp) = 0;
$found_end = 0;
print STDERR " In ShowConfiguration: $_" if ($debug);
# include the command
*Original line 212 now line 214*
*from this *
while (<$INPUT>) {
tr/\015//d;
last if (/^$prompt/);
/no matching entry found/ && return(-1); # unknown cmd
*to this*
while (<$INPUT>) {
tr/\015//d;
return (0) if (/^$prompt/);
/no matching entry found/ && return(-1); # unknown cmd
return (0) if ($found_end == 1);
Unless the prompt is not being parsed and suffed in $prompt properly, this
shouldn't be necessary.
Post by Tanner Lyle
*Change Line 265*
*from this*
if (/^! END OF CONFIG:/) {
*to this*
if (/! END OF CONFIG:/) {
This shouldn't be necessary. Is there a case where the ! is not at the
beginning of the line? Is the pager perhaps not being disabled properly?
The command is in the hlogin.

I guess, please try it with just the patch that I sent (or the current
alpha). if that fails, share the devicename.raw file with me:
NOPIPE=YES; export NOPIPE
rancid -t ciena -d devicename

and, i'll go back to look at the one you (i think) already shared.
Post by Tanner Lyle
For those of you better at reading diffs than me
diff -u will help you.
heasley
2017-07-21 14:22:16 UTC
Permalink
Post by Chris Wopat
Post by heasley
These changes do not seem right to me. i understand that its working for
you, but i'm not sure that it will be reliable.
Also, of the 4 raw command output examples that i have, all of them have
the prompt ">", not "#". Can you tell me why it is different? keep in
mind that I havent much experience with these and we no longer have them.
If someone could extend remote access to me, I can feel more comfortable
accepting these changes. anyone?
The prompt varies depending on userlevel. If you're the superuser
account, it's #. If you're a read only or perhaps generally lesser user,
it's >.
user create user MYUSERNAME access-level limited
I just tested this patch WITHOUT the prompt changes for my user, which
is a read only user, and it seemed to work!
It sounds like the best case would be to adjust regexp to match # or >.
great; thanks for testing that. Just addressing that one point, the patch
is:

Index: lib/wavesvros.pm.in
===================================================================
--- lib/wavesvros.pm.in (revision 3719)
+++ lib/wavesvros.pm.in (working copy)
@@ -62,10 +62,10 @@
$clean_run = 0;
last;
}
- while (/>\s*($cmds_regexp)\s*$/) {
+ while (/[>#]\s*($cmds_regexp)\s*$/) {
$cmd = $1;
if (!defined($prompt)) {
- $prompt = ($_ =~ /^([^>]+>)/)[0];
+ $prompt = ($_ =~ /^([^>#]+[>#])/)[0];
$prompt =~ s/([][}{)(\\])/\\$1/g;
# prompt changes when config is unsaved - "foo*> "
$prompt =~ s/\*/\\\*/;
@@ -90,7 +90,7 @@
last TOP;
}
}
- if (/>\s*exit/) {
+ if (/[>#]\s*exit/) {
$clean_run=1;
last;
}
@@ -103,7 +103,7 @@
print STDERR " In ShowChassisClocks: $_" if ($debug);

# include the command
- s/^[a-z]+@//; s/^([^ ]+)\*>/$1>/;
+ s/^[a-z]+@//; s/^([^ ]+)\*([>#])/$1$2/;
ProcessHistory("","","","! $_");
while (<$INPUT>) {
tr/\015//d;
@@ -131,7 +131,7 @@
print STDERR " In ShowVersion: $_" if ($debug);

# include the command
- s/^[a-z]+@//; s/^([^ ]+)\*>/$1>/;
+ s/^[a-z]+@//; s/^([^ ]+)\*([>#])/$1$2/;
ProcessHistory("","","","! $_");
# skip software state info
while (<$INPUT>) {
@@ -160,7 +160,7 @@
print STDERR " In ShowConfiguration: $_" if ($debug);

# include the command
- s/^[a-z]+@//; s/^([^ ]+)\*>/$1>/;
+ s/^[a-z]+@//; s/^([^ ]+)\*([>#])/$1$2/;
ProcessHistory("","","","! $_");
while (<$INPUT>) {
tr/\015//d;
Chris Wopat
2017-07-21 19:37:08 UTC
Permalink
Post by heasley
great; thanks for testing that. Just addressing that one point, the patch
I tested this patch against the stock wavesvros.pm, did not work, it
goes back to 'end of run not found' as it was always doing.

Keeping that patch in place, I stepped through the changes from Tanner's
patch and find that it works with only one change, the addition of this
line where it is originally stated in context (in sub WriteTerm)

return (0) if ($found_end == 1)

I did a test run on several Waveservers it seems to work consistently. I
did not test with a superuser account that would use the # prompt, just
my limited user with > prompt.
heasley
2017-07-25 18:53:55 UTC
Permalink
Post by Chris Wopat
Post by heasley
great; thanks for testing that. Just addressing that one point, the patch
I tested this patch against the stock wavesvros.pm, did not work, it
goes back to 'end of run not found' as it was always doing.
Keeping that patch in place, I stepped through the changes from Tanner's
patch and find that it works with only one change, the addition of this
line where it is originally stated in context (in sub WriteTerm)
return (0) if ($found_end == 1)
I did a test run on several Waveservers it seems to work consistently. I
did not test with a superuser account that would use the # prompt, just
my limited user with > prompt.
somehostname-11^>logout

can you tell me what the ^ is in that prompt? in 3 of the 5 examples
folks have sent to me, the prompt has this ^ in it after the show
configuration command has run. This would cause a problem, which is
probably easy to fix if i understand the cause.
heasley
2017-07-28 17:31:06 UTC
Permalink
Post by heasley
Post by Chris Wopat
Post by heasley
great; thanks for testing that. Just addressing that one point, the patch
I tested this patch against the stock wavesvros.pm, did not work, it
goes back to 'end of run not found' as it was always doing.
Keeping that patch in place, I stepped through the changes from Tanner's
patch and find that it works with only one change, the addition of this
line where it is originally stated in context (in sub WriteTerm)
return (0) if ($found_end == 1)
I did a test run on several Waveservers it seems to work consistently. I
did not test with a superuser account that would use the # prompt, just
my limited user with > prompt.
somehostname-11^>logout
can you tell me what the ^ is in that prompt? in 3 of the 5 examples
folks have sent to me, the prompt has this ^ in it after the show
configuration command has run. This would cause a problem, which is
probably easy to fix if i understand the cause.
anyone?

Loading...