Forum Discussion
Jon_Steel_3910
Nimbostratus
Sep 23, 2009How to Force Offline DisableNode using iControl ?
Hi
Currently, I'm using the Disable-F5.LTMNodeAddress -node {IP} to disable access to a device. However, this marks the node as "disabled" (allowing persistent connections to continue) - but I want to "Force Offline" (only allowing active connections).
How do I do this through the powershell scripts ?
5 Replies
- The Disable-F5.LTMNodeAddress Cmdlet calls the iControl LocalLBNodeAddress.set_session_enabled_state method under the seams with the iControl.CommonEnabledState.STATE_DISABLED flag.
The GUI has a three way toggle that I've talked about before but I'll address it again. The mapping is as followsEnabled (All traffic allowed):
set_monitor_state : STATE_ENABLED
set_session_enabled_state : STATE_ENABLED
Disabled (Only persistent or active connections allowed):
set_monitor_state : STATE_ENABLED
set_session_enabled_state : STATE_DISABLED
Forced Offline (Only active connections allowed):
set_monitor_state : STATE_DISABLED
set_session_enabled_state : STATE_DISABLED
From this it seems you want to call set_monitor_state as well with the STATE_DISABLED flag.
A little background on the Cmdlets first. I wrote those as some simple use cases knowing they wouldn't cover everyones situations. With that in mind, I added the Get-F5.iControl Cmdlet that will return an interface into the entire iControl API. As you've probably seen in some of my tech tipshttp://devcentral.f5.com/wiki/default.aspx/iControl/PowerShell.html
Click here
I use this Cmdlet exclusively since it gives the most flexibility. I wrote this tech tip on Graceful Server Shutdown that doesn't address NodeAddresses, but illustrates Pool Membershttp://devcentral.f5.com/Default.aspx?tabid=63&articleType=ArticleView&articleId=254
Click here
But, I think what you finally want is this CodeShare entry I wrote titled PsServerControlhttp://devcentral.f5.com/wiki/default.aspx/iControl/PsServerControl.html
Click here
In this sample you can either pass in either an address (ie 10.10.10.10) and a state (enabled or disabled) or you can pass in an address:port (10.10.10.10:80) along with the target state of "enable" or "disable". It will then then set the state of the nodeaddress (or pool members) to either "Enabled" or "Offline" depending on the state you pass in.
In the future, I'd suggest looking at the core APIs since they do provide more flexibility and it's fairly easy to write function wrappers that will emulate a Cmdlet's look and feel.
Hopefully this gets you where you need to go with the Forced Offline mode. Let me know if not and I'll whip something else up for you.
Also, if you have a hard time figuring out the core API and how to associate it with PowerShell, let me know specifics and I can work on a series of Tech Tips.
-Joe - Jon_Steel_3910
Nimbostratus
Ignore what I just posted (I'm editing)
Your Servercontrol script worked perfectly !
I saved the script, then called it as follows from a DOS script :
powershell -psconsolefile "C:\Program Files\F5 Networks\iControlSnapIn\iControlSnapIn.psc1" -command "&servercontrol.ps1" {IP Address of F5} {Username on F5} {Password on F5} {NodeAddress} enabled|disabled|offline
Works perfectly ! Thankyou ! - Sweet, glad I could help. Please don't hesitate to ask if anything else comes up. As long as the requests aren't too complicated, I'm glad to mock something up and add it as a CodeShare entry.
-Joe - Justin_111680
Nimbostratus
Is this applicable to pyControl? I added set_monitor_status to my disable_member function but it still shows up as 'Disabled (Only persistent or active connections allowed)' when i verify in UI. I am still using pyControl v1. I tried updating to pyControl v2 but just attempting to connect to LB threw a stack trace. - JRahm
Admin
pycontrol is just another way to access the API. As long as you use the methods Joe describes above properly, it will work just as well. the constructor in pycontrol changed slightly from v1 -> v2 in that you need to specify fromurl = True (or provide a local directory where your wsdl files are) and instead of wsdl_files its is wsdls. Check out the constructor video Matt put together (Click here)
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
