Discussion:
[rancid] help request after I developed new module 'vnxrancid', but it don't save output properly to configs directory
d***@vmware.com
2011-09-17 11:56:04 UTC
Permalink
I hacked fnlogin/fnrancid pair to do some EMC VNX commands on their RHAT/Linux shell, but the only a portion of the output is not being checked into the configs directory.

I have done the following:
NOPIPE=yes;export NOPIPE
vnxrancid -d vnx01

I get the two files: vnx01.raw and vnx01.new

But if I do just:
rancid-run -r vnx01 testing

The .../var/testing/configs/vnx01 file only has saved some lines like:
!RANCID-CONTENT-TYPE: vnxrancid

The contents of the vnx01.new file looks perfect (in my opinion)

I noticed that the end of the vnx01.raw file still have lots of control characters, is this interfering with the rancid-run
^M
^[]0;***@r2778-vnx01cs0:~^G[***@r2778-vnx01cs0 ~]$ ^M
^[]0;***@r2778-vnx01cs0:~^G[***@r2778-vnx01cs0 ~]$ exit^M
logout^M
^[[H^[[2JConnection to vnx01 closed.^M^M

whereas an UCS, N7K, Vyatta device the .raw file is much cleaner.
exit^M
r2845-n6k-B#exit^M
Connection to r2845-n6k02 closed.^M^M

commit^M
^[]0;***@hub-las01-fw01b: ~^G^[[01;***@hub-las01-fw01b^[[00m:^[[01;34m~^[[00m$ ^M
^[]0;***@hub-las01-fw01b: ~^G^[[01;***@hub-las01-fw01b^[[00m:^[[01;34m~^[[00m$ exit^M
logout^M
Connection to hub-las01-fw01b closed.^M^M
^M


Thanks,
Daniel Chen
d***@vmware.com
2011-09-17 12:35:38 UTC
Permalink
Nevermind.

I used ProcessHistory("","","","","!field:$_");
so all the lines in the .new are practically comments as there is no "configuration" to capture as such.

I think that would be it. Trying now.

Sorry,
Daniel Chen

----- Original Message -----
From: ***@vmware.com
To: rancid-***@shrubbery.net
Sent: Saturday, September 17, 2011 7:56:04 AM
Subject: [rancid] help request after I developed new module 'vnxrancid', but it don't save output properly to configs directory

I hacked fnlogin/fnrancid pair to do some EMC VNX commands on their RHAT/Linux shell, but the only a portion of the output is not being checked into the configs directory.

I have done the following:
NOPIPE=yes;export NOPIPE
vnxrancid -d vnx01

I get the two files: vnx01.raw and vnx01.new

But if I do just:
rancid-run -r vnx01 testing

The .../var/testing/configs/vnx01 file only has saved some lines like:
!RANCID-CONTENT-TYPE: vnxrancid

The contents of the vnx01.new file looks perfect (in my opinion)

I noticed that the end of the vnx01.raw file still have lots of control characters, is this interfering with the rancid-run
^M
^[]0;***@r2778-vnx01cs0:~^G[***@r2778-vnx01cs0 ~]$ ^M
^[]0;***@r2778-vnx01cs0:~^G[***@r2778-vnx01cs0 ~]$ exit^M
logout^M
^[[H^[[2JConnection to vnx01 closed.^M^M

whereas an UCS, N7K, Vyatta device the .raw file is much cleaner.
exit^M
r2845-n6k-B#exit^M
Connection to r2845-n6k02 closed.^M^M

commit^M
^[]0;***@hub-las01-fw01b: ~^G^[[01;***@hub-las01-fw01b^[[00m:^[[01;34m~^[[00m$ ^M
^[]0;***@hub-las01-fw01b: ~^G^[[01;***@hub-las01-fw01b^[[00m:^[[01;34m~^[[00m$ exit^M
logout^M
Connection to hub-las01-fw01b closed.^M^M
^M


Thanks,
Daniel Chen
d***@vmware.com
2011-09-17 17:43:59 UTC
Permalink
I backtracked my changes to which part of the changes caused the rancid-run to fail.
I think I broke my variation of the fnrancid when I attempted to get the prompt to be recognized.
As stand-alone, vnxrancid -d vnx01 appear to be able to generate the vnx01.raw and vnx01.new files when NOPIPE=yes was engaged.

The prompt looks like the following during a ssh:
[***@r2778-vnx01cs0 ~]$

In looking at the .raw file, it looks like a there is an escape sequence:
^[]0;***@r2778-vnx01cs0:~^G[***@r2778-vnx01cs0 ~]$ ^M




while (/^.+(#|\$)\s*($cmds_regexp)\s*$/) {
$cmd = $2;
# - FortiGate prompts end with either '#' or '$'. Further, they may
# be prepended with a '~' if the hostname is too long. Therefore,
# we need to figure out what our prompt really is.
# if (!defined($prompt)) {
# if ($_ =~ m/^.+\~\$/) {
# $prompt = '\~\$ .*';
# } else {
# if ($_ =~ m/^.+\$/) {
# $prompt = ' \$ .*';
# } else {
# if ($_ =~ m/^.+\~#/) {
# $prompt = '\~# .*';
# } else {
# if ($_ =~ m/^.+#/) {
# $prompt = ' # .*';
# }
# }
# }
# }
# }

print STDERR ("line:$_\ncmd:$2\n") if ($debug);
if (!defined($prompt)) {
print STDERR ("PROMPT0 MATCH: $1\n") if ($debug);
# $prompt = ($_ =~ /^([^#]+#)/)[0];
$prompt = ($_ =~ /^([^\$]+\$)/)[0];
print STDERR ("PROMPT1 MATCH: $prompt\n") if ($debug);
# $prompt =~ s/([][}{)(\\])/\\$1/g;
print STDERR ("PROMPT2 MATCH: $prompt\n") if ($debug);
# $prompt =~ s/[\$]//g;
print STDERR ("PROMPT3 MATCH: $prompt\n") if ($debug);
}

Regards,
Daniel Chen

----- Original Message -----
From: ***@vmware.com
To: rancid-***@shrubbery.net
Sent: Saturday, September 17, 2011 8:35:38 AM
Subject: Re: [rancid] help request after I developed new module 'vnxrancid', but it don't save output properly to configs directory

Nevermind.

I used ProcessHistory("","","","","!field:$_");
so all the lines in the .new are practically comments as there is no "configuration" to capture as such.

I think that would be it. Trying now.

Sorry,
Daniel Chen

----- Original Message -----
From: ***@vmware.com
To: rancid-***@shrubbery.net
Sent: Saturday, September 17, 2011 7:56:04 AM
Subject: [rancid] help request after I developed new module 'vnxrancid', but it don't save output properly to configs directory

I hacked fnlogin/fnrancid pair to do some EMC VNX commands on their RHAT/Linux shell, but the only a portion of the output is not being checked into the configs directory.

I have done the following:
NOPIPE=yes;export NOPIPE
vnxrancid -d vnx01

I get the two files: vnx01.raw and vnx01.new

But if I do just:
rancid-run -r vnx01 testing

The .../var/testing/configs/vnx01 file only has saved some lines like:
!RANCID-CONTENT-TYPE: vnxrancid

The contents of the vnx01.new file looks perfect (in my opinion)

I noticed that the end of the vnx01.raw file still have lots of control characters, is this interfering with the rancid-run
^M
^[]0;***@r2778-vnx01cs0:~^G[***@r2778-vnx01cs0 ~]$ ^M
^[]0;***@r2778-vnx01cs0:~^G[***@r2778-vnx01cs0 ~]$ exit^M
logout^M
^[[H^[[2JConnection to vnx01 closed.^M^M

whereas an UCS, N7K, Vyatta device the .raw file is much cleaner.
exit^M
r2845-n6k-B#exit^M
Connection to r2845-n6k02 closed.^M^M

commit^M
^[]0;***@hub-las01-fw01b: ~^G^[[01;***@hub-las01-fw01b^[[00m:^[[01;34m~^[[00m$ ^M
^[]0;***@hub-las01-fw01b: ~^G^[[01;***@hub-las01-fw01b^[[00m:^[[01;34m~^[[00m$ exit^M
logout^M
Connection to hub-las01-fw01b closed.^M^M
^M


Thanks,
Daniel Chen
d***@vmware.com
2011-09-18 02:27:42 UTC
Permalink
Nevermind again.
I was working backwards. I should have started with the fnlogin equivalent first, then work on the fnrancid equivalent second.
I have some minor clean-up to program vnxrancid to ignore certain run-time statistics.


I made a new copy of fnlogin and made a few changes:
1)
# FortiOS 2.x prompts can end in either '#' or '$'
# set prompt "\[#\\$] "
# VNX prompt looks like [***@r2778-vnx01cs0 ~]$
set prompt "\[~.\\$] "

2)
some of the expect during the proc run_command to match more closely to a linux workstation

I made a new copy of fnrancid and made some more changes to the prompt processing there:
while (/^.+(#|\$)\s*($cmds_regexp)\s*$/) {
$cmd = $2;
# - FortiGate prompts end with either '#' or '$'. Further, they may
# be prepended with a '~' if the hostname is too long. Therefore,
# we need to figure out what our prompt really is.
# if (!defined($prompt)) {
# if ($_ =~ m/^.+\~\$/) {
# $prompt = '\~\$ .*';
# print STDERR ("line0:$_\nprompt:$prompt\n") if ($debug);
# } else {
# if ($_ =~ m/^.+\$/) {
# $prompt = ' \$ .*';
# print STDERR ("line1:$_\nprompt:$prompt\n") if ($debug);
# } else {
# if ($_ =~ m/^.+\~#/) {
# $prompt = '\~# .*';
# print STDERR ("linei2:$_\nprompt:$prompt\n") if ($debug);
# } else {
# if ($_ =~ m/^.+#/) {
# $prompt = ' # .*';
# print STDERR ("linei3:$_\nprompt:$prompt\n") if ($debug);
# }
# }
# }
# }
# }
print STDERR ("line:$_\ncmd:$2\n") if ($debug);
if (!defined($prompt)) {
print STDERR ("PROMPT0 MATCH: $1\n") if ($debug);
# $prompt = ($_ =~ /^([^#]+#)/)[0];
# $prompt = ($_ =~ /\a([^\$]+\$)/)[0];
# $prompt = ($_ =~ /\a(.+\b)/)[0];
$prompt = ($_ =~ /\a(.+\b)/)[1];
print STDERR ("PROMPT1 MATCH: $prompt\n") if ($debug);
# $prompt =~ s/([][}{)(\\])/\\$1/g;
# $prompt =~ s/([][}{)(\\])//g;
print STDERR ("PROMPT2 MATCH: $prompt\n") if ($debug);
# $prompt =~ s/[\$]//g;
print STDERR ("PROMPT3 MATCH: $prompt\n") if ($debug);
}


Daniel Chen


----- Original Message -----
From: ***@vmware.com
To: rancid-***@shrubbery.net
Sent: Saturday, September 17, 2011 1:43:59 PM
Subject: Re: [rancid] help request after I developed new module 'vnxrancid', but it don't save output properly to configs directory

I backtracked my changes to which part of the changes caused the rancid-run to fail.
I think I broke my variation of the fnrancid when I attempted to get the prompt to be recognized.
As stand-alone, vnxrancid -d vnx01 appear to be able to generate the vnx01.raw and vnx01.new files when NOPIPE=yes was engaged.

The prompt looks like the following during a ssh:
[***@r2778-vnx01cs0 ~]$

In looking at the .raw file, it looks like a there is an escape sequence:
^[]0;***@r2778-vnx01cs0:~^G[***@r2778-vnx01cs0 ~]$ ^M




while (/^.+(#|\$)\s*($cmds_regexp)\s*$/) {
$cmd = $2;
# - FortiGate prompts end with either '#' or '$'. Further, they may
# be prepended with a '~' if the hostname is too long. Therefore,
# we need to figure out what our prompt really is.
# if (!defined($prompt)) {
# if ($_ =~ m/^.+\~\$/) {
# $prompt = '\~\$ .*';
# } else {
# if ($_ =~ m/^.+\$/) {
# $prompt = ' \$ .*';
# } else {
# if ($_ =~ m/^.+\~#/) {
# $prompt = '\~# .*';
# } else {
# if ($_ =~ m/^.+#/) {
# $prompt = ' # .*';
# }
# }
# }
# }
# }

print STDERR ("line:$_\ncmd:$2\n") if ($debug);
if (!defined($prompt)) {
print STDERR ("PROMPT0 MATCH: $1\n") if ($debug);
# $prompt = ($_ =~ /^([^#]+#)/)[0];
$prompt = ($_ =~ /^([^\$]+\$)/)[0];
print STDERR ("PROMPT1 MATCH: $prompt\n") if ($debug);
# $prompt =~ s/([][}{)(\\])/\\$1/g;
print STDERR ("PROMPT2 MATCH: $prompt\n") if ($debug);
# $prompt =~ s/[\$]//g;
print STDERR ("PROMPT3 MATCH: $prompt\n") if ($debug);
}

Regards,
Daniel Chen

----- Original Message -----
From: ***@vmware.com
To: rancid-***@shrubbery.net
Sent: Saturday, September 17, 2011 8:35:38 AM
Subject: Re: [rancid] help request after I developed new module 'vnxrancid', but it don't save output properly to configs directory

Nevermind.

I used ProcessHistory("","","","","!field:$_");
so all the lines in the .new are practically comments as there is no "configuration" to capture as such.

I think that would be it. Trying now.

Sorry,
Daniel Chen

----- Original Message -----
From: ***@vmware.com
To: rancid-***@shrubbery.net
Sent: Saturday, September 17, 2011 7:56:04 AM
Subject: [rancid] help request after I developed new module 'vnxrancid', but it don't save output properly to configs directory

I hacked fnlogin/fnrancid pair to do some EMC VNX commands on their RHAT/Linux shell, but the only a portion of the output is not being checked into the configs directory.

I have done the following:
NOPIPE=yes;export NOPIPE
vnxrancid -d vnx01

I get the two files: vnx01.raw and vnx01.new

But if I do just:
rancid-run -r vnx01 testing

The .../var/testing/configs/vnx01 file only has saved some lines like:
!RANCID-CONTENT-TYPE: vnxrancid

The contents of the vnx01.new file looks perfect (in my opinion)

I noticed that the end of the vnx01.raw file still have lots of control characters, is this interfering with the rancid-run
^M
^[]0;***@r2778-vnx01cs0:~^G[***@r2778-vnx01cs0 ~]$ ^M
^[]0;***@r2778-vnx01cs0:~^G[***@r2778-vnx01cs0 ~]$ exit^M
logout^M
^[[H^[[2JConnection to vnx01 closed.^M^M

whereas an UCS, N7K, Vyatta device the .raw file is much cleaner.
exit^M
r2845-n6k-B#exit^M
Connection to r2845-n6k02 closed.^M^M

commit^M
^[]0;***@hub-las01-fw01b: ~^G^[[01;***@hub-las01-fw01b^[[00m:^[[01;34m~^[[00m$ ^M
^[]0;***@hub-las01-fw01b: ~^G^[[01;***@hub-las01-fw01b^[[00m:^[[01;34m~^[[00m$ exit^M
logout^M
Connection to hub-las01-fw01b closed.^M^M
^M


Thanks,
Daniel Chen
_______________________________________________
Rancid-discuss mailing list
Rancid-***@shrubbery.net
http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss

Loading...