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 only allows active connections to continue and not persistent.
Is this a simple task or would it require major reworking of the script?
I have looked through the forums and some sample scripts and the following would seem to be roughly equivalent:
set_session_enabled_state - sets the state that determines whether to allow new sessions to be established. If disabled, this allows current connections to stay connected, but stops the node from accepting new connections. This corresponds to the set_state method in 4.5x.
- set_monitor_state - sets the availability state, i.e. UP/DOWN. If disabled, this immediately performs a forced-down to all node addresses/pool members.. This basically stops all traffic (including persistent connections) from being sent to the node addresses/pool members. This corresponds to the set_availability method in 4.5x.
however, which state/status is equivalent to Active Connections ONLY, i.e. no persistent or new connections allowed?
Has anyone written a script that allows you to set pool_member to what the GUI calls Forced Disabled?
thanks, Keith
1 Reply
- 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
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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