Forum Discussion
Prasad_81758
Nimbostratus
Dec 16, 2009Toggle Pool Members iControl java API
I am trying to toggle pool members in a local traffic pool to control the traffic to one or other ip. Defined two pool members through BigIP Console:
10.20.30.101:15001
10.20.30.105:15001
Initial State : 10.20.30.101:15001 is enabled and 10.20.30.105:15001 is disabled.
Now trying to disable 10.20.30.101:15001 and enable 10.20.30.105:15001.
I am setting pool memeber session status, session state to achieve this. But when verified back in console, no changes takes place. Any help is greatly appreciated:
Here is the java code:
LocalLBPoolPortType t = myi.getLocalLBPool();
// retrieve the entire list of pools for this load balancer
String[] poolList = t.get_list();
LocalLBPoolMemberPortType poolMember = myi.getLocalLBPoolMember();
LocalLBPoolMemberMemberSessionStatus[][] sessionstatus = poolMember.get_session_status(chudPoolList);
LocalLBPoolMemberMemberSessionState[][] sessionstate = poolMember.get_session_enabled_state(chudPoolList);
LocalLBPoolMemberMemberMonitorStatus[][] monitorstatus = poolMember.get_monitor_status(chudPoolList);
for (int j = 0; j < sessionstate.length; j++)
{
for (int k = 0; k < sessionstate[j].length; k++)
{
if (sessionstate[j][k].getSession_state().equals(CommonEnabledState.STATE_ENABLED))
{
System.out.println("Current Session State.." + sessionstate[j][k].getMember().getPort() + ".." + sessionstate[j][k].getSession_state().getValue());
sessionstate[j][k].setSession_state(CommonEnabledState.STATE_DISABLED);
System.out.println("Updated Session State.." + sessionstate[j][k].getMember().getPort() + ".." + sessionstate[j][k].getSession_state().getValue());
System.out.println("Current Session Status.." + sessionstatus[j][k].getMember().getPort() + ".." + sessionstatus[j][k].getSession_status().getValue());
sessionstatus[j][k].setSession_status(LocalLBSessionStatus.SESSION_STATUS_DISABLED);
System.out.println("Updated Session Status.." + sessionstatus[j][k].getMember().getPort() + ".." + sessionstatus[j][k].getSession_status().getValue());
}
else
if (sessionstate[j][k].getSession_state().equals(CommonEnabledState.STATE_DISABLED))
{
System.out.println("Current Session State.." + sessionstate[j][k].getMember().getPort() + ".." + sessionstate[j][k].getSession_state().getValue());
sessionstate[j][k].setSession_state(CommonEnabledState.STATE_ENABLED);
System.out.println("Updated Session State.." + sessionstate[j][k].getMember().getPort() + ".." + sessionstate[j][k].getSession_state().getValue());
System.out.println("Current Session Status.." + sessionstatus[j][k].getMember().getPort() + ".." + sessionstatus[j][k].getSession_status().getValue());
sessionstatus[j][k].setSession_status(LocalLBSessionStatus.SESSION_STATUS_ENABLED);
System.out.println("Updated Session Status.." + sessionstatus[j][k].getMember().getPort() + ".." + sessionstatus[j][k].getSession_status().getValue());
}
}
}
- You are querying the values and returning them into a local structure. You are then setting values in the local structure but I don't see anywhere you are making the call to "set" the values on the existing objects. Local structures have no connection to the BIG-IP unless you make a "set" method call to assign them. If you want to see the methods needed, you can check out the "togglePoolMember" perl script in the CodeShare
http://devcentral.f5.com/wiki/default.aspx/iControl/TogglePoolMember.html
http://devcentral.f5.com/wiki/default.aspx/iControl/PsServerControl.html
- Prasad_81758
Nimbostratus
Thanks Joe for pointing out. Made the changes and working good. Here is the complete method in case someone needs in future.
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