API & Integration

Reply
Highlighted

Perl on Windows no status_code() or status_detail() when session fails

[ Edited ]
StefanvanH
Techie
Posts: 6
4589     0

I have an issue where the status_code() or status_detail() is empty if session fails when used with Perl on Windows. On a Linux machine it runs just fine.
Here is a simple code I used on both Windows and Linux and I use 2 Virtual appliances one with NIOS 7.3.8 (which I have installed the perl module on both Linux and Windows) and one with 7.3.10 so I can force an error when trying to setup a session. The session to 7.3.8 will be succesfull and the session to 7.3.10 should fail.

(x.x.x.x is the ip-adres of the Virtual appliance)

 

code:
#!/usr/bin/perl
use strict ;
use warnings;
use Carp;
use Cwd;
use Infoblox;
# Determine OS for use read_password
BEGIN {
  if ($^O eq "MSWin32") {
    require Term::ReadPassword::Win32;
    import Term::ReadPassword::Win32 qw(read_password);
  } else {
    require Term::ReadPassword;
    import Term::ReadPassword qw(read_password);
   }
 }


my $pwd = passwd();
my $session = session("x.x.x.x", "admin", $pwd);

 

print $session->status_code( )."\n";

 

sub session {
    my ($gm, $username, $pwd ) = @_;
    print "Setting up session. One moment please...";
    my $session = Infoblox:Smiley Frustratedession->new(
        "master" => "$gm",
        "username" => "$username",
        "password" => "$pwd"
    );
    if ($session->status_code()) {
        die("Construct session failed: ",
        $session->status_code() . ":" . $session->status_detail());
    }
    print "Session created successfully\n";
    return $session;
}


sub passwd {
    our $pwd = read_password("Password: ");
    return $pwd;

}

 

Results:

 

Windows against Nios 7.3.8 (successful session)

output on screen:
C:\scripts>simple.pl
Password:
Setting up session. One moment please...Session created successfully
0
C:\scripts>

 

Linux against Nios 7.3.8 (seccessful session)
output on screen:
root@zt--ub01:/opt/scripts# ./simple.pl
Password:
Setting up session. One moment please...Session created successfully
0
root@zt--ub01:/opt/scripts#

 

Windows against Nios 7.3.10 (fails due to wrong perl module version)
output on screen:
C:\scripts>simple.pl
Password:
Setting up session. One moment please...
C:\scripts>

 

Linux against Nios 7.3.10 (fails due to wrong perl module version)
output on screen:
root@zt--ub01:/opt/scripts# ./simple.pl
Password:
Construct session failed: 1009:The version of perl module [7.3.8-340539] doesn't match the server version [7.3.10-345050]. Please upgrade your Infoblox perl module package at ./simple.pl line 33.
Setting up session. One moment please...root@zt--ub01:/opt/scripts#

 

As you can see there is no output on status_code() on Windows when the session fails so the "die" in Perl won't work either and hense you can't build any proper fail safe for it or a proper Log function for troubleshooting.

Re: Perl on Windows no status_code() or status_detail() when session fails

Moderator BRampling
Moderator
Posts: 69
4590     0

Are you using ActivePerl? Please open a support case for this.

Re: Perl on Windows no status_code() or status_detail() when session fails

GHorne Community Manager
Community Manager
Posts: 254
4590     0

I would also double check which libraries are being loaded on the 2 client systems to make sure that you are getting  a version mismatch.

 

you can do that with an undocumented creation of any object:

 

my $host = Infoblox:Smiley Very HappyNS::Host->new ("name" => "name");

my $CLIENT_REV = $host->{__version} ;

 

You might also try just dumping $session to see what it looks like, instead of testing for $session->status_code().

Something else (e.g. LWP errors) may have caused $session to fail to create.

 

       Note that SSL errors are not reported by the Perl API when debugging
       SSL connection issues (1006 'can't connect' errors). Infoblox
       recommends that you add either

        use IO::Socket::SSL qw(debug3);

       or

        use Net::SSLeay;
        $Net::SSLeay::trace = 3;

       to your Perl program before the "use Infoblox; line" to receive more
       complete debugging information.

Re: Perl on Windows no status_code() or status_detail() when session fails

StefanvanH
Techie
Posts: 6
4590     0

Ok, I have added the debugging in the script on both platforms and it seems that the Linux platform is outputting the SSL debug info even whe the connection is succesful whereas the Windows doens't output any information, so I'm completely blind there and can't see what happens.

 

So I guess this is not a Infoblox Perl API issue but a Perl on Windows issue.

 

I am using Activestate perl By the way.

 

Anyways, thank you for the suggestions. This helped me a bit further.

 

Regards,

 

Stefan

Re: Perl on Windows no status_code() or status_detail() when session fails

[ Edited ]
StefanvanH
Techie
Posts: 6
4590     0

Ok, I have done some more investigation on this issue and used the perl debug mode (perl -d)

It seems that it won't setup a session because Crypt:Smiley FrustratedSLeay is not installed. 

 

DB<1> n
Can't locate Crypt/SSLeay.pm in @INC (you may need to install the Crypt:Smiley FrustratedSLeay
module) (@INC contains: modules/ D:/perl/site/lib D:/perl/lib .) at D:/perl/site
/lib/Infoblox/Agent.pm line 75.
at D:/perl/site/lib/Infoblox/Agent.pm line 75.
Infoblox::Agent::new("Infoblox::Agent", "timeout", undef, "keep_alive",
1, "blox_session", Infoblox:Smiley Frustratedession=HASH(0x2996b40), "blox_agent", LWP::UserAge
nt=HASH(0x17228a00), ...) called at D:/perl/site/lib/Infoblox/Session.pm line 44
2
Infoblox:Smiley Frustratedession::create_ibap_server(Infoblox:Smiley Frustratedession=HASH(0x2996b40),
LWP::UserAgent=HASH(0x17228a00)) called at D:/perl/site/lib/Infoblox/Session.pm
line 117

 

When I try to install Crypt:Smiley FrustratedSLeay I get the following message:

 

*** THIS IS NOT AN ERROR, JUST A MESSAGE FOR YOUR INFORMATION ***

Do you really need Crypt:Smiley FrustratedSLeay?

Starting with version 6.02 of LWP, https support was unbundled into
LWP:Smiley Tonguerotocol::https. This module specifies as one of its prerequisites
IO:Smiley Frustratedocket:Smiley FrustratedSL which is automatically used by LWP::UserAgent unless
this preference is overridden separately. IO:Smiley Frustratedocket:Smiley FrustratedSL is a more
complete implementation, and, crucially, it allows hostname
verification. Crypt:Smiley FrustratedSLeay does not support this. At this point,
Crypt:Smiley FrustratedSLeay is maintained to support existing software that already
depends on it.

However, it is possible that your software does not really depend on
Crypt:Smiley FrustratedSLeay, only on the ability of LWP::UserAgent class to
communicate with sites over SSL/TLS.

If are using version LWP 6.02 or later, and therefore have installed
LWP:Smiley Tonguerotocol::https and its dependencies, and do not explicitly use
Net:Smiley FrustratedSL before loading LWP::UserAgent, or override the default socket
class, you are probably using IO:Smiley Frustratedocket:Smiley FrustratedSL and do not really need
Crypt:Smiley FrustratedSLeay.

Before installing Crypt:Smiley FrustratedSLeay, you may want to try specifying a
dependency on LWP:Smiley Tonguerotocol::https.

Failed to build and link a simple executable using OpenSSL

 

So it seems that it is missing Crypt:Smiley FrustratedSLeay but I don't need to install it as I am using LWP 6.08 but it doesn't create a session and it doesn't show any message of it.

Why ?

 

Re: Perl on Windows no status_code() or status_detail() when session fails

Anjushank
Techie
Posts: 3
4590     0

Hey if you want to find file explorer windows10 then you can easily find it, because it is the desktop application which is used to access the files with the graphical user interface.

Re: Perl on Windows no status_code() or status_detail() when session fails

[ Edited ]
RobertBarton
Techie
Posts: 1
4590     0

In this segment, we'll give you a overview of the a portion of the more helpful capacities and techniques in the LWP, HTML, HTTP, and URI modules. Alternate strategies, capacities, and modules are, as the expression goes, past the extent of. Along these lines, how about we go over the center modules that are useful. Assignment-land

Showing results for 
Search instead for 
Do you mean 

Recommended for You