Forum Discussion
Keith_Richards_
Nimbostratus
Jan 10, 2006modify sample togglePoolMember.pl code
I have a limited programming background...
I would like to modify the togglePoolMember.pl script so that it changes a member state to the equivalent of Forced Disabled in the GUI i.e. it onl...
Jan 10, 2006
Keith,
It's the set_monitor_state() method that you want. When you manually set the monitor state to STATE_DISABLED then it will be in the FORCED_DISABLED state that equates to the "Only active connections allowed" option in the GUI.
Here is a thread where this topic is discussed:http://devcentral.f5.com/Default.aspx?tabid=53&view=topic&forumid=1&postid=4019Click here
If you want to modify the togglePoolMember.pl script, then all you have to do is add the call at the bottom of the togglePoolMember subroutine as follows:
----------------------------------------------------------------------------
Toggle a specified pool member
----------------------------------------------------------------------------
sub togglePoolMember()
{
my ($pool_name, $member_def) = (@_);
------------------------------------------------------------------------
Split apart node:port
------------------------------------------------------------------------
($sNodeIP, $sNodePort) = split(/:/, $member_def, 2);
if ( "" eq $sNodePort )
{
$sNodePort = "0";
}
$member = { address => $sNodeIP, port => $sNodePort };
--------------------------------------------------------------------
Query enabled state for given Node:port
--------------------------------------------------------------------
$pool_member_state = &getPoolMemberState($pool_name, $member);
----------------------------------------------------------------
Set the state to be toggled to.
----------------------------------------------------------------
my $toggleState = "STATE_DISABLED";
if ( "STATE_DISABLED" eq $pool_member_state )
{
$toggleState = "STATE_ENABLED";
}
elsif ( "STATE_ENABLED" eq $pool_member_state )
{
$toggleState = "STATE_DISABLED";
}
else
{
die("Couldn't find member $member_def in pool $pool_name\n");
}
$MemberSessionState =
{
member => $member,
session_state => $toggleState
};
push @MemberSessionStateList, $MemberSessionState;
push @MemberSessionStateLists, [@MemberSessionStateList];
----------------------------------------------------------------
Toggle the state.
----------------------------------------------------------------
$soapResponse =
$PoolMember->set_session_enabled_state
(
SOAP:ata->name ( pool_names => ( [$pool_name] ) ),
SOAP:ata->name ( session_states => [@MemberSessionStateLists] )
);
&checkResponse($soapResponse);
$MemberMonitorState =
{
member => $member,
monitor_state => $toggleState
};
push @MemberMonitorStateList, $MemberMonitorState;
push @MemberMonitorStateLists, [@MemberMonitorStateList];
----------------------------------------------------------------
Toggle the Monitor State
----------------------------------------------------------------
$soapResponse =
$PoolMember->set_monitor_state
(
SOAP:ata->name ( pool_names => ( [$pool_name] ) ),
SOAP:ata->name ( monitor_states => [@MemberMonitorStateLists] )
);
&checkResponse($soapResponse);
print "Pool Member $pool_name {$sNodeIP:$sNodePort} state set from '$pool_member_state' to '$toggleState'\n";
}
-Joe
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