Forum Discussion
Michel_van_der_
Nimbostratus
Apr 13, 2005Compatibility issue
I'm using some perl SOAP::Lite calls, specifically
ITCMLocalLB:Pool:get_member_list which presumably is
implemented as a compatibility call. But instead of
getting something like:
ARRAY(0x8e86080)
0 ITCMCommon::IPPortDefinition=HASH(0x8eb7028)
'address' => '1.2.3.4'
'port' => 80
I get:
ARRAY(0x9557e74)
0 ITCMCommon::IPPortDefinition=HASH(0x9575678)
'address' => '-414596721'
'port' => 389
Note the address.
Thoughts?
- Loc_Pham_101863Historic F5 AccountWhat does your call look like? Here's some sample code that gets the pool members:
..... ..... set up code, also populate $sPool variable ..... ------------------------------------------------------------------------ Get Member List ------------------------------------------------------------------------ (@member_list) = getPoolMemberList($sPool); foreach my $member (@member_list) { print $member->{"address"}, ":", $member->{"port"}, ", "; } ---------------------------------------------------------------------------- Get the list of pool members ---------------------------------------------------------------------------- sub getPoolMemberList() { my ($poolName) = @_; my @members; my $soap_response = $soap->get_member_list ( SOAP::Data->name ( pool_name => $poolName ) ); if ( $soap_response->fault ) { print $soap_response->faultcode, "\n"; print $soap_response->faultstring, "\n"; exit(""); } else { @members = @{$soap_response->result}; } return @members; }
- Michel_van_der_
Nimbostratus
Test case below. Call it with:!/usr/bin/perl require "dumpvar.pl"; use strict; use SOAP::Lite; my ($user, $pwd); sub SOAP::Transport::HTTP::Client::get_basic_credentials { return $user => $pwd; } sub getF5Pools { my $url = shift; my($soap, $soapResponse, $result); $soap = SOAP::Lite ->uri('urn:iControl:ITCMLocalLB/Pool') ->proxy($url) || die "Can't connect\n"; $soapResponse = $soap->get_list(); if ( $soapResponse->fault ) { return [] if $soapResponse->faultstring =~ /The requested item does not exist/i; return "Error getting Pools: " . $soapResponse->faultcode . " " . $soapResponse->faultstring; } return $soapResponse->result; } sub getF5PoolsMembers { my $url = shift; my $pools = shift; my($p, $soap, $soapResponse, $r); $soap = SOAP::Lite ->uri('urn:iControl:ITCMLocalLB/Pool') ->proxy($url) || die "Can't connect\n"; $r = []; for $p ( @$pools ) { $soapResponse = $soap->get_member_list( SOAP::Data->name('pool_name' => $p) ); if ( ! $soapResponse->fault ) { push @$r, [ $p, $soapResponse->result]; } } return $r; } sub main { my ($ip, $url, $r, $p, $m); $ip = $ARGV[0]; $user = $ARGV[1]; $pwd = $ARGV[2]; $url = "https://$ip/iControl/iControlPortal.cgi"; $r = getF5Pools($url); $r = getF5PoolsMembers($url, $r); for $p ( @$r ) { print "Pool: " . $p->[0] . " "; for $m ( @{$p->[1]} ) { print $m->{'address'} . ":" . $m->{'port'} . " "; } print "\n"; } } main; 1;
- Looks like you found a bug in the compatility methods. In the case of these methods we aren't converting the native long value of an IPAddress into it's string representation. I'll get this logged as a bug to be corrected in the next release. In the mean time, you can work around it with the following code (assuming IPv4 addresses)
sub getIPAddress { my ($ipaddr) = @_; my $value = $ipaddr; Look for a "." in the value to determine whether we need to convert to a string if ( $ipaddr !~ /\./) { my $a = ($ipaddr >> 24) & 0x000000FF; my $b = ($ipaddr >> 16) & 0x000000FF; my $c = ($ipaddr >> 8 ) & 0x000000FF; my $d = ($ipaddr ) & 0x000000FF; $value = "$a.$b.$c.$d"; } return $value; } sub main { my ($ip, $url, $r, $p, $m); $ip = $ARGV[0]; $user = $ARGV[1]; $pwd = $ARGV[2]; $url = "http://$ip/iControl/iControlPortal.cgi"; $r = getF5Pools($url); $r = getF5PoolsMembers($url, $r); for $p ( @$r ) { print "Pool: " . $p->[0] . " "; for $m ( @{$p->[1]} ) { print &getIPAddress($m->{'address'}) . ":" . $m->{'port'} . " "; } print "\n"; } }
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects