Highlighted
Established Member..
Established Member..
339 views

Need help updating perl api script after NA proxy behavior change

I use what I think is a fairly generic perl script to connect to my NA proxy (v9.22) and query Cisco devices. For some reason the NA administrators have changed the NA cli proxy behavior such that when you do "connect xyz.corp," instead of getting straight to the xyz.corp Cisco device enable prompt, you now get an SSH login prompt on the xyz.corp device.

 

Now, when logged directly into the the NA proxy (no perl script), when I try to connect to a device  I get:

 

NA>connect xyz.corp
Attempting to connect to device xyz.corp (10.10.0.10). 

Device SSH Login:  

 I need to adapt my perl script to handle this.

 

Current script:

 

#!/usr/bin/perl
#
#

use lib qw(/ops/shared/home/tmnet/lib);
use Opsware::NAS::Connect;
use Socket;

if ($ARGV[0] eq "") {die print ("\nPlease enter a switch\n");};

my $con = Opsware::NAS::Connect->new(
             -user => 'nasuser',        # NAS user name
             -pass => 'naspw',      # NAS user's password
             -host => 'hpnas.techsys.corp:8023',    # NAS server host IP (may include :port)
         );

         # log in to NAS Proxy
         $con->login();

         my $prompt = qr/^\w+\#\s*$/m;  # use pre-compiled regular expression
                 if ($ARGV[0]=~m/.*east.*/) {$dc = "east";}
                 elsif ($ARGV[0]=~m/.*west.*/) {$dc = "west";}
                        else {$dc = "eu";};

                 print "$ARGV[0]:\n\n";
                                 
         # Connect to the switch
        $con->connect( "$ARGV[0] -override", $prompt ) or die ("\nFailed to connect to $ARGV[0]\n");

        $con->cmd("terminal length 0");

         # issue a command and capture the output...
                 if ($ARGV[1] eq "group2") {@lines = $con->cmd("sho mac address-table dynamic vlan 500 | incl Eth");}
                 else {
         @lines = $con->cmd("sho mac address-table dynamic | incl Eth");};

         # disconnect from this device
         $con->disconnect("exit");

<remainder snipped>

 

I have started doing a little Python scripting - but I don't know perl yet.

 

Thank you,

Scott

 (If I should have posted this elsewhere, please let me know.)

 

Tags (4)
0 Likes
4 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Need help updating perl api script after NA proxy behavior change

Hi ,

 

Is by any chance this device user in a TACAS/RADIUS configuration?

 

this message has been seen in devices with this configuration,

 

Best Regards,

Pedro A. Batista
Customer Support Engineer

If you find that this or any other post resolves your issue, please be sure to mark it as an accepted solution.
If you are satisfied with anyone’s response please remember to give them a KUDOS by clicking on the THUMB at the bottom left of the post and show your appreciation.
0 Likes
Highlighted
Absent Member.. Absent Member..
Absent Member..

Re: Need help updating perl api script after NA proxy behavior change

Not sure if you got your problem solved yet?

It could be simpler, if your forget the Perl script.

Do you have permission to create diagnostic script? or ask your admin to create for you.

diag script 1: 

sho mac address-table dynamic | incl Eth 

 diag script 2:

sho mac address-table dynamic vlan 500 | incl Eth

then you can create group in HPNA with your list of devices to run script 1 or script 2 (if you have permission to create group), or your can run the diagnostic with a .csv file.

 

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Need help updating perl api script after NA proxy behavior change

Variation of that, you could still use an API to tell NA to run the diagnostics that are predefined.  That's a lot easier, and the point of diagnostics - to run show commands on your behalf.

0 Likes
Highlighted
Established Member..
Established Member..

Re: Need help updating perl api script after NA proxy behavior change

Sorry, I'm a little late in following up - must have missed this one.

Anyway, yes, the login to the individual devices uses TACACS/RADIUS.

My theory is that the regex in the Opsware::NAS::Connect library(?) is not prepared to expect the second login prompt. I don't know how to get around that.

Hoping you are still around.

Regards,
Scott

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.