Forum Discussion
Patrick_Chang_7
Oct 01, 2007Historic F5 Account
iControl to disable a pool member globally in all pools in which it appears
I am trying to disable a pool member in all pools in which it appears in one shot.
I thought that under v9 disabling a node in the UI did not disable all the pool members associated with that node. Is the iControl version different?
Here is the iControl perl script
!/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
use SOAP::Lite;
my $Host = $ARGV[0];
my $UID = $ARGV[1];
my $PASSWD = $ARGV[2];
my $member_def = $ARGV[3];
sub usage()
{
die ("usage: globalForceDownPoolMember.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 Pool and PoolMember SOAP Objects
$Pool = SOAP::Lite
-> uri('urn:iControl:LocalLB/Pool')
-> readable(1)
-> proxy("https://$Host:443/iControl/iControlPortal.cgi");
set up Member
$PoolMember = SOAP::Lite
-> uri('urn:iControl:LocalLB/PoolMember')
-> readable(1)
-> proxy("https://$Host:443/iControl/iControlPortal.cgi");
set up 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", ''));
};
if port is missing, set to 0
($IP, $port) = split(/:/, $member_def,2);
if ($port eq "")
{
$port = "0";
}
set $themember
$themember = { address => $IP, port => $port };
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};
print "Past the get_member part\n";
Loop through member list to build up arrays for the set_session_enabled_state and set_monitor_state commands
$i = 0;
foreach $member_list (@member_lists) {
$pool_name = $pool_list[$i];
print "$pool_name\n";
foreach $member (@$member_list) {
if ($member == $themember) {
print "$member\n";
set the state "STATE_DISABLED" or "STATE_ENABLED" to "STATE_DISABLED"
$MemberSessionState = { member => $member, session_state => "STATE_DISABLED" };
fill up pool_names structure
push @PoolNames, $pool_name;
push @MemberSessionStateList, $MemberSessionState;
push @MemberSessionStateLists, [@MemberSessionStateList];
}
}
$i++;
}
print "Past the looping part\n";
disable the member in all pools
$soapResponse = $PoolMember->set_session_enabled_state
(
SOAP::Data->name ( pool_names => ( @PoolNames ) ),
SOAP::Data->name ( session_states => [@MemberSessionStateLists] )
);
&checkResponse($soapResponse);
disable the monitor in all pools
we can reuse the session enabled state structures since the state is the same enum value
$soapResponse = $PoolMember->set_monitor_state
(
SOAP::Data->name ( pool_names => ( @PoolNames ) ),
SOAP::Data->name ( session_states => [@MemberSessionStateLists] )
);
&checkResponse($soapResponse);
print "Pool Member $pool_name $IP:$port globally Forced Down\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_7Historic F5 AccountI figured out my problem. Did not read the method descriptions closely enough. Here is the working version:
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