Forum Discussion

nexus_55890's avatar
nexus_55890
Icon for Nimbostratus rankNimbostratus
Dec 06, 2007

Pool List

Me again, with my poor English

 

 

Is there some Method that i can use to get a List of pools related to a specific Virtual Server?

 

 

I can get a list of all Pools, but i need some specific pools.

 

 

 

(I really need to study English...)

4 Replies

  • Don_MacVittie_1's avatar
    Don_MacVittie_1
    Historic F5 Account
    Your English is just fine - and certainly better than my Spanish ;-)

     

     

    The only way to do this at this time is to call pool.get_list(), then for each element call get_members() and compare to your pool.

     

     

    I think I will be adding a method to handle all of this for you to the next release of the wrappers - this is a very common question. But that won't be for a while yet, so the above is your best option.

     

     

    I hope that helps!

     

    Don.
  • Can you elaborate a bit further by what you mean by "pools related to a specific virtual server"? You can determine the default pool assigned to the virtual in it's profile by using the LocalLB::VirtualServer::get_default_pool_name() method. There are ways to override the default pool within an iRule but there is no programmatic way to do this on a connection-by-connection basis.

     

     

    -Joe
  • Patrick_Chang_7's avatar
    Patrick_Chang_7
    Historic F5 Account

     

    !/usr/bin/perl

     

    this script expects input of the following:

     

    F5 device ($Host) in the form of a string,

     

    User ID ($UID) in the form of a string,

     

    Password ($PASSWD) in the form of a string and

     

    Member ($member_def) in the form of ":"

     

    we also assume transport is HTTPS on port 443 to the F5 device

     

    we then print out the Pools to which the Pool Member belongs

     

    and the Virtual Servers which use those Pools

     

    use SOAP::Lite;

     

     

    my $Host = $ARGV[0];

     

    my $UID = $ARGV[1];

     

    my $PASSWD = $ARGV[2];

     

    my $member_def = $ARGV[3];

     

     

    sub usage()

     

    {

     

    die ("usage: poolMemberInfo.pl host usedID passwd addr:port\n");

     

    }

     

     

    if (($Host eq "") or ($UID eq "") or ($PASSWD eq "") or ($member_def eq ""))

     

    {

     

    usage();

     

    }

     

     

    sub SOAP::Transport::HTTP::Client::get_basic_credentials

     

    {

     

    return "$UID" => "$PASSWD";

     

    }

     

     

    set up Virtual Server, Pool and PoolMember SOAP Objects

     

    $VirtualServer = SOAP::Lite

     

    -> uri('urn:iControl:LocalLB/VirtualServer')

     

    -> proxy("https://$Host:443/iControl/iControlPortal.cgi");

     

    $Pool = SOAP::Lite

     

    -> uri('urn:iControl:LocalLB/Pool')

     

    -> readable(1)

     

    -> proxy("https://$Host:443/iControl/iControlPortal.cgi");

     

    $PoolMember = SOAP::Lite

     

    -> uri('urn:iControl:LocalLB/PoolMember')

     

    -> readable(1)

     

    -> proxy("https://$Host:443/iControl/iControlPortal.cgi");

     

     

    pass login credentials

     

    eval { $Pool->transport->http_request->header (

     

    'Authorization' =>

     

    'Basic ' . MIME::Base64::encode("$UID:$PASSWD", ''));

     

    };

     

    eval { $PoolMember->transport->http_request->header (

     

    'Authorization' =>

     

    'Basic ' . MIME::Base64::encode("$UID:$PASSWD", ''));

     

    };

     

    eval { $VirtualServer->transport->http_request->header (

     

    'Authorization' =>

     

    'Basic ' . MIME::Base64::encode("$sUID:$sPWD", ''));

     

    };

     

    if port is missing, set to 0

     

    ($IP, $port) = split(/:/, $member_def,2);

     

    if ($port eq "") {

     

    $port = "0";

     

    }

     

     

    Get list of Pools

     

    $soapResponse = $Pool->get_list();

     

    &checkResponse($soapResponse);

     

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

     

     

    Get list of all Pool Members

     

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

     

    &checkResponse($soapResponse);

     

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

     

     

    Loop through member list to build up array of pools that contain the member

     

    $i = 0;

     

    foreach $pool_name (@pool_list) {

     

    @member_list = @{@member_lists[$i]};

     

    foreach $member (@member_list) {

     

    $addr = $member->{"address"};

     

    $pt = $member->{"port"};

     

    if ($addr eq $IP and $pt == $port) {

     

    fill up pool_names structure

     

    push @PoolNames, $pool_name;

     

    }

     

    }

     

    $i++;

     

    }

     

     

    pool member is not in any pools

     

    if ($PoolNames < 0) {

     

    print "$IP:$port not in any pools and thus, no virtual servers\n";

     

    exit;

     

    }

     

     

    print out the pool names that contain the member

     

    print "$IP:$port is in the following pools\n";

     

    foreach $pool_name (@PoolNames) {

     

    print "$pool_name\n";

     

    }

     

     

    Get list of Virtual Servers

     

    $soapResponse = $VirtualServer->get_list();

     

    &checkResponse($soapResponse);

     

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

     

     

    Get list of default pools for the Virtual Servers

     

    $soapResponse = $VirtualServer->get_default_pool_name(

     

    SOAP::Data->name(virtual_servers => [@VS_list])

     

    );

     

    &checkResponse($soapResponse);

     

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

     

     

    Loop through the default pool list to build up the array of Virtual Servers that use the pools

     

    that contain the pool member

     

    $i = 0;

     

    foreach $default_pool_name (@default_pool_list) {

     

    foreach $pool_name (@PoolNames) {

     

    if ($pool_name eq $default_pool_name) {

     

    push @VSNames, $VS_list[$i];

     

    }

     

    }

     

    $i++;

     

    }

     

     

    pools not the default for any virtual servers

     

    if ($VSNames < 0) {

     

    print "$IP:$port not in any default pool of a virtual server\n";

     

    exit;

     

    }

     

     

    print out the virtual server names with default pool that contains the member

     

    print "$IP:$port is in the default pool of the following virtual servers\n";

     

    foreach $virtual_name (@VSNames) {

     

    print "$virtual_name\n";

     

    }

     

     

     

    ----------------------------------------------------------------------------

     

    checkResponse makes sure the error isn't a SOAP error

     

    ----------------------------------------------------------------------------

     

    sub checkResponse()

     

    {

     

    my ($soapResponse) = (@_);

     

    if ( $soapResponse->fault )

     

    {

     

    print $soapResponse->faultcode, " ", $soapResponse->faultstring, "\n";

     

    exit();

     

    }

     

    }

     

     

  • Patrick_Chang_7's avatar
    Patrick_Chang_7
    Historic F5 Account
    whoops misread the question. The last iControl tells you what pools and VSs are associated with a particular pool member.