Re: [rancid] Watchguard xml file

2019-07-08 Thread 'john heasley'
Wed, Jul 03, 2019 at 06:49:20PM +, Wayne Eisenberg:
> -Original Message-
> From: 'john heasley'  
> Sent: Wednesday, July 03, 2019 1:41 PM
> To: Wayne Eisenberg 
> Cc: 'john heasley' ; 'rancid-discuss@shrubbery.net' 
> 
> Subject: Re: [rancid] Watchguard xml file
> 
> 
> >> However, in the xtm.pm module, line 102 defines it again. 
> 
> >i'm not familiar with this device, but redefining (or refining) the prompt 
> >is normal.  the filter functions and login scripts begin with something 
> >loose, and once it sees the prompt, it can be refined to be more precise, 
> >and >may later further refine it (eg: in run_commands) to match the prompt 
> >when/if it changes in config or other modes that are platform dependent.
> 
> Ah, if I only had that skill.
> 
> >> ---
> >> while (/\s*($cmds_regexp)\s*$/) {
> >>$cmd = $1;
> >>$prompt = ">>";
> this is probably a mistake; should be part of the 
> while() regex.  I suspect it might be here because the author could not make 
> the regex below match correctly.
> 
> >>if (!defined($prompt)) {
> >>$prompt = ($_ =~ /^([^>]+>)/)[0];
> >>$prompt =~ s/([][}{)(\\])/\\$1/g;
> >>print STDERR ("PROMPT MATCH: $prompt\n") if ($debug);
> >>}
> >> ---
> >> Once you get to the sub ShowConfiguration section, on line 199 if it sees 
> >> the prompt, end. Guess what? The "#" character is inside the config (there 
> >> is some html code in one of the xml sections) and that is where the config 
> >> ends.
> 
> >seems that the prompt is ">>".
> 
> Yes, in this example. I wanted to show the original file, not something that 
> I modded. In my current version, the line is
> $prompt = ">>|#"
> which works, but causes the problem of the config getting truncated because 
> it sees "#" as the prompt. The $prompt should either be the entire thing or 
> some string that ends in #.

yes, this is why it refines the prompt match to be the complete thing, but
it has to see one before it can extract it.  and your inloop set is at the
top of the loop, so it never refines it to be the whole prompt.

> >> ---
> >> sub ShowConfiguration {
> >> my($INPUT, $OUTPUT, $cmd) = @_;
> >> my($lines) = 0;
> >> my($snmp) = 0;
> >> print STDERR "In ShowConfiguration: $_" if ($debug);
> >> # We don't care about password filtering as passwords are hashed
> >> # So don't use this if you need it (or develop the functionality).
> >> if ($filter_pwds >= 1){
> >> print STDERR "WARNING: Password filtering isn't implemented 
> >> yet!\n";
> >> print STDERR "Either disable password filtering in rancid.conf";
> >> print STDERR " or don't use this plugin.\n";
> >> }
> >> s/^[a-z]+@//;
> >> ProcessHistory("","","","# $_");
> >> while (<$INPUT>) {
> >>tr/\015//d;
> >>next if (/^\s*$/);
> >># end of config - hopefully.
> >># end-of-config tag.  appears to end with "\nPROMPT:~$".
> >>if (/$prompt/) {
> >>$found_end++;
> >>last;
> >>}
> >> ---
> >> 
> >> So I'm thinking if I can figure out a different way to define the prompt 
> >> to be more than just the # sign (at least in the xtm.pm), that should do 
> >> the trick? Can you do something like $prompt = "#$" ?

it has to be as a set (regex or glob), like; [#$].  but that is a single
atom; if your prompt is or may be ">>", then you likely need to use a
group atom, like (>>|#).

> >its better to anchor it and have it be as complete as reasonable.  eg:
> >not #
> >not hostname#
> >but ^hostname#
> 
> >look at ios.pm.
> 
> Looking, but I don't see anywhere that it defines the prompt. It uses it a 
> lot, but doesn't define it.

its starts with [>#] in the while() (and exit match); then refines it to be
a match the entire prompt with regex atoms escaped in the
if(!defined($prompt)).  after that, it anchors the prompt match when
appropiate; /^$prompt/.

you should do similarly for this watchguard device.  I suspect that you can
just steal the ios.pm inloop() and modify the initial prompt matching.  It
could be kinkier, but it is a good starting point.

i think i;ve answered everything.

___
Rancid-discuss mailing list
Rancid-discuss@shrubbery.net
http://www.shrubbery.net/mailman/listinfo/rancid-discuss


Re: [rancid] Unable to figure out "end of run not found"

2019-07-08 Thread john heasley
Fri, Jul 05, 2019 at 07:16:35AM -0600, Kevin Morales:
> Thanks John!
> 
> The configuration finish in some case with:
> 
> !
> ZXR10-01#
> 
> $
> !
> ZXR10-02#
> 
> $
> !
> ZXR10-03#
> 
> and sorry, I don't have experience with programation..,

it would need to handle the check like exos.pm; by counting valid output.
Maybe try just using that module with a private device type like:

zte;script;rancid -t zte
zte;login;xlogin
zte;module;exos
zte;inloop;exos::inloop  
zte;command;exos::ShowVersion;show version
zte;command;exos::WriteTerm;show configuration

> Thanks!
> 
> On Wed, Jul 3, 2019 at 6:10 PM john heasley  wrote:
> 
> > Wed, Jul 03, 2019 at 02:53:14PM -0600, Kevin Morales:
> > > Yes, my Router is ZTE and I am using CISCO type, because the command is
> > the
> > > same to see the configuration..show running-config
> >
> > I have no idea what ZTE is; does it behave *exactly* the same as IOS?
> > It seems not.
> >
> > > > > > found end means that it found the end of the config; for type
> > cisco,
> > > > > > that means "^end".
> >
> > Does it's config end with:
> >
> > "
> > end
> > "?
> >
> > > > > > clean run means that it found the cli logout; for type cisco, that
> > > > > > means "prompt[>#] exit$"
> >
> > in your .raw file, does the last prompt where clogin exited the cli, match
> > the regex
> >
> > "prompt[>#] exit$"
> > ?
> >
> > clearly these sanity checks are not working with your ZTE device.  You
> > need to figure-out why and correct it, likely by creating your own
> > rancid module for ZTE with a customized inloop() function.  you can
> > probably use the parsing functions from the ios module, like the
> > 'ciscoshtech' example that comes with rancid uses 2 modules.
> >
> > > On Wed, Jul 3, 2019 at 2:52 PM Piegorsch, Weylin William 
> > > wrote:
> > >
> > > > Hi Kevin,
> > > >
> > > > I think you said this is a ZTE device, but that you’re using -t cisco.
> > is
> > > > ZTE a cisco device?
> > > >
> > > > weylin
> > > >
> > > >
> > > >
> > > > *From: *Kevin Morales 
> > > > *Date: *Wednesday, July 3, 2019 at 3:18 PM
> > > > *To: *john heasley 
> > > > *Cc: *Weylin Piegorsch , Nick Nauwelaerts <
> > > > nick.nauwelae...@aquafin.be>, "rancid-discuss@shrubbery.net" <
> > > > rancid-discuss@shrubbery.net>
> > > > *Subject: *Re: [rancid] Unable to figure out "end of run not found"
> > > >
> > > >
> > > >
> > > > I am sorry, I dont get you, What do you want I do?
> > > >
> > > >
> > > >
> > > > on my Rancid Server I execute:
> > > >
> > > > [rancid@localhost bin]$ NOPIPE=yes ./rancid -d -t  cisco 172.17.1.6
> > > >
> > > >
> > > >
> > > > On Wed, Jul 3, 2019 at 12:43 PM john heasley 
> > wrote:
> > > >
> > > > Wed, Jul 03, 2019 at 11:33:08AM -0600, Kevin Morales:
> > > > > Thanks Piegorsh,
> > > > >
> > > > > I did it..
> > > > >
> > > > > NOPIPE=yes ./rancid -d -t cisco 172.17.1.6
> > > > >
> > > > > but in the two file 172.17.1.6.new and 172.17.1.6.raw don't see
> > anything
> > > > > about this error. both show the correct command output.
> > > >
> > > > correct command output and matching the criteria that i described below
> > > > for type cisco are not necessarily the same thing.  read it again.
> > > >
> > > > > On Wed, Jul 3, 2019 at 11:29 AM Piegorsch, Weylin William <
> > wey...@bu.edu
> > > > >
> > > > > wrote:
> > > > > > > *172.17.1.6 : End of run not found*
> > > > > > > 172.17.1.6: clean_run is false
> > > > > > > 172.17.1.6: found_end is false
> > > > > > > !
> > > > > >
> > > > > > found end means that it found the end of the config; for type
> > cisco,
> > > > > > that means "^end".
> > > > > >
> > > > > > clean run means that it found the cli logout; for type cisco, that
> > > > > > means "prompt[>#] exit$"
> >
> 
> 
> -- 
> *Kevin Morales*

___
Rancid-discuss mailing list
Rancid-discuss@shrubbery.net
http://www.shrubbery.net/mailman/listinfo/rancid-discuss