Todd_Rosenberge
Mar 05, 2014Nimbostratus
Issue with Perl iControl script to get Enable State of GTM Virtual Server
I am trying use Perl with iControl to determin the Enable State of a Server/Virtual server (not pool members). The sample code below results in the error:
SOAP-ENV:Server Could not find element by name: virtual_servers
I am note very fluent in Perl, but this seems straight forward. I am obviously missing something. I hacked the code together based on success with a similar script for VirtualServer::get_list, which I was able to use to print a list of Virtual Server names, IP's and ports. The two appear to use the same VirtualServerDefinition type.
The GTM is version 10.x so I am using the VirtualServer::get_enabled_state (Not VirtualServerV2::get_enabled_state)
=== Current "Bad" script to get Enable State === !/usr/local/bin/perl
$ENV{PERL_LWPSSL_VERIFY_HOSTNAME}=0;
use SOAP::Lite;
use MIME::Base64;
my $BIGIP = 'gtmname';
my $User = 'admin';
my $Pass = 'admin';
my %VServers = (
name => "VS_Name_in_GTM",
address => "VS_IP_in_GTM",
port => "443"
);
sub SOAP::Transport::HTTP::Client::get_basic_credentials {
return "$User" => "$Pass";
}
&getVsState();
sub GetInterface() {
print "In GetInterface with BigIP $BIGIP \n";
my ($module, $name) = @_;
$interface = SOAP::Lite
-> uri("urn:iControl:$module/$name")
-> readable(1)
-> proxy("https://$BIGIP/iControl/iControlPortal.cgi");
eval { $interface->transport->http_request->header
( 'Authorization' => 'Basic ' . MIME::Base64::encode("$User:$Pass", '') ); };
return $interface;
}
sub getVsState () {
print "In VsState\n";
$VSSTATE = &GetInterface("GlobalLB", "VirtualServer");
$soapResponse = $VSSTATE->get_enabled_state(%VServers
SOAP::Data->name (virtual_server => %VServers)
);
&checkResponse($soapResponse);
@vsstate = @{$soapResponse->result};
print "\n\n\nVS State = $vsstate";
print "End VsState";
}
sub checkResponse() {
print "in checkResponse\n";
my ($soapResponse) = (@_);
if ( $soapResponse->fault ) {
die $soapResponse->faultcode, " ", $soapResponse->faultstring, "\n";
}
}