jhyland87 has asked for the wisdom of the Perl Monks concerning the following question:
So I am creating my own perl module to manage a Big-IP F5 load balancer. I realize theres already a module for it, but it sucks, and it doesn't have many features, if you want it done right, do it yourself! right?
Anyways, heres my WORKING example of how to do it, without just using subroutines in the same file.
#!/usr/bin/perl use strict; use Data::Dumper; use SOAP::Lite; use UNIVERSAL 'isa'; my $user = "xxxx"; my $pass = "xxxx"; my $host = "xxxx"; $ENV{'PERL_LWP_SSL_VERIFY_HOSTNAME'} = 0; sub newF5 { my ($server, $user, $pass) = (@_); my $proxy_uri = sprintf("https://%s:443/iControl/iControlPortal.cg +i", $server); my $soap = SOAP::Lite->proxy($proxy_uri); sub SOAP::Transport::HTTP::Client::get_basic_credentials { return $user => $pass; } return $soap; } sub getActivePartition { my ($soap) = (@_); my $soapResponse = $soap->uri("urn:iControl:Management/Partition") +->get_active_partition(); #$self->checkResponse($soapResponse); my $partition = $soapResponse->result; return $partition; } my $connection = newF5($host, $user, $pass); print getActivePartition($connection)."\n";
Now that works just fine, but I cant get it to work when I put it in a .pm file and try to use it as a module. Code is below.
PERL MODULE (File: ./BigIP/F5/F5.pm)
package BigIP::F5; #use strict; use SOAP::Lite; use UNIVERSAL 'isa'; use Data::Dumper; $ENV{'PERL_LWP_SSL_VERIFY_HOSTNAME'} = 0; sub new { my ($server, $user, $pass) = (@_); my $proxy_uri = sprintf("https://%s:443/iControl/iControlPortal.cg +i", $server); my $soap = SOAP::Lite->proxy($proxy_uri); sub SOAP::Transport::HTTP::Client::get_basic_credentials { return $user => $pass; } return $soap; } sub getActivePartition { my ($self, $soap) = (@_); my $soapResponse = $soap->uri("urn:iControl:Management/Partition") +->get_active_partition(); #$self->checkResponse($soapResponse); my @partition = @{$soapResponse->result}; return @partition; } 1;
Example of using the perl module
#!/usr/bin/perl #use strict; use Data::Dumper; use lib "./"; use BigIP::F5; my $user = "xxxx"; my $pass = "xxxx"; my $host = "xxxx"; my $connection = BigIP::F5->new($host, $user, $pass); my $partition = BigIP::F5->getActivePartition($connection); print $partition."\n";
That doesn't work, the error I get is: 500 Can't connect to BigIP::F5:443 (Bad service '443') at /BigIP/F5.pm line 50
I cant figure out what the problem is, i know the un/pw works because the first example works, its just not in the perl module.
Any ideas?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Creating my own perl module, having issues with SOAP tho
by Eliya (Vicar) on Dec 30, 2011 at 21:05 UTC | |
by jhyland87 (Sexton) on Dec 31, 2011 at 05:26 UTC | |
by jhyland87 (Sexton) on Dec 31, 2011 at 07:14 UTC | |
|
Re: Creating my own perl module, having issues with SOAP tho
by ~~David~~ (Hermit) on Dec 30, 2011 at 21:08 UTC |