Forum Discussion

storg_88340's avatar
storg_88340
Icon for Nimbostratus rankNimbostratus
May 09, 2008

LocalLB.Pool.get_member() call using perl

I've just started using perl to query our F5, and what I've done so far (not much) is working,

 

but it seems I must be doing things the hard way.

 

 

I've done this

 

 

$jjjj = 'pool_test';

 

$soapResponse = $Pool->get_member(SOAP::Data->name(pool_names => [ ($jjjj) ]) );

 

&checkResponse($soapResponse);

 

@blah = @{$soapResponse->result};

 

 

which works, and I get a array of arrays of hashes, with address and port of my pool members,

 

but the resultant thingie that is returned by the get_member() call appears to be an object,

 

I used data dumper on it.

 

 

print Dumper( @blah );

 

 

and this is what comes out

 

 

$VAR1 = bless( [

 

bless( {

 

'address' => '1.1.1.2',

 

'port' => '100'

 

}, 'Common::IPPortDefinition' ),

 

bless( {

 

'address' => '1.1.1.2',

 

'port' => '101'

 

}, 'Common::IPPortDefinition' )

 

], 'Common::IPPortDefinition[]' );

 

 

 

So what's the most correct/neatest way of getting my address and port out of that structure.

 

 

I've printed the values doing this

 

 

foreach $xx ( @blah ) {

 

foreach $yy ( @{$xx} ) {

 

foreach $key (keys %{ $yy } ) {

 

print "Key:$key Data: ${$yy}{$key}\n";

 

}

 

 

}

 

}

 

 

and it gives

 

 

Key:address Data: 1.1.1.2

 

Key:port Data: 100

 

Key:address Data: 1.1.1.2

 

Key:port Data: 101

 

 

 

Seems a little unwieldy

 

 

 

Mark.

 

 

1 Reply

  • The get_member() method returns a 2-d array. The first dimension to match to each pool name you passed in in the pool_list parameter. The "Disabling Node Servers" codeshare entry will query all pools, and then pass that list into get_member, and then enumerate through the 2-d array.

     

     

    http://devcentral.f5.com/wiki/default.aspx/iControl/DisablingNodeServers.html

     

    Click here

     

     

     

    Look for the findPoolsFromMember() method. It calls a subroutine to get the 2-d array of members and loops through the results. Not sure if this is the "best" way, but it does work.

     

     

    Cheers!

     

     

    -Joe