Forum Discussion
jajamax_127538
Nimbostratus
Dec 03, 2003modify the LocalLBNode script???
I've got the LocalLBNode.pl working, but I'd like it to do more. Can anyone help with an "IF like" statement? What I'm wanting is basically this:
If node is enabled, then disable
If node is disabled, then enable
And how can I run this script against both big-ip's simultaneously, so that I'm covered in the event of a failover? (ie two hosts)
thanks
7 Replies
- What are the specifics of what you are doing? Are you looking for a "toggle" logic that will flip the node. The code in LocalLBNode.pl has the call to get_state() which returns the enabled state. It also illustrates the set_state() method to set the state to enabled or disabled. If you want to toggle, you can do something like this (minus the error checking)
Query the Node's state $soap_response = $soap->get_state ( SOAP::Data->name ( node_def => $node_definition ) ); my $state = $soap_response->result; my $toggleState; if ( 0 == $state ) { $toggleState = 1; } else { $toggleState = 0; } Toggle the state $soap_response = $soap->set_state ( SOAP::Data->name ( node_defs => ( [$node_definition] ) ), SOAP::Data->name ( state => $toggleState ) );
Hope this helps.
-Joe - jajamax_127538
Nimbostratus
Thanks Joe, I've got it doing exactly what I need. One thing though, when I failover the script will fail. Is there a way to query the state of the big-ip it self to ensure I'm running on the active node?
Thanks for all your help - To determine if the BIG-IP is in active or standby mode you can use the
ITCMLocalLB::Failover::get_failover_state() method which will return either FAILOVER_STATE_STANDBY (0) OR FAILOVER_STATE_ACTIVE (1) depending on it's current state.
Good luck, and let use know of any interesting projects you are using iControl for.
-Joe - Here's a sample app you can run to query the failover state of the BIG-IP (Active or Standby). Let me know if this helps.
-Joeuse SOAP::Lite; ---------------------------------------------------------------------------- Validate Arguments ---------------------------------------------------------------------------- my $sHost = $ARGV[0]; my $sPort = $ARGV[1]; my $sUID = $ARGV[2]; my $sPWD = $ARGV[3]; my $sProtocol = "https"; if ( ("80" eq $sPort) or ("8080" eq $sPort) ) { $sProtocol = "http"; } sub usage() { die ("Usage: LocalLBFailover.pl host port uid pwd \n"); } if ( ($sHost eq "") or ($sPort eq "") or ($sUID eq "") or ($sPWD eq "") ) { usage(); } ---------------------------------------------------------------------------- Transport Information ---------------------------------------------------------------------------- sub SOAP::Transport::HTTP::Client::get_basic_credentials { return "$sUID" => "$sPWD"; } $soap = SOAP::Lite -> uri('urn:iControl:ITCMLocalLB/Failover') -> readable(1) -> proxy("$sProtocol://$sHost:$sPort/iControl/iControlPortal.cgi"); &queryFailoverState(); sub queryFailoverState() { $soapResponse = $soap->get_failover_state(); if ( $soapResponse->fault ) { print $soap_response->faultcode, "(faultstring) ", $soap_response->faultstring, "\n"; print $soap_response->faultcode, "(faultdetail) ", $soap_response->faultdetail, "\n"; } else { $state = $soapResponse->result; print "Failover state: "; if ( 0 == $state ) { print "STANDBY\n"; } else { print "ACTIVE\n"; } } } - jajamax_127538
Nimbostratus
well son of a B..... I was missing the Failover
$soap = SOAP::Lite
-> uri('urn:iControl:ITCMLocalLB/Failover')
-> readable(1)
-> proxy("$sProtocol://
Thanks!!!!!!!!!!!!!!!!! - Yes, you need to make sure the uri is correct so that the iControl server knows where the method is to be processed. There are several "get_list()" type methods and without a uri to distinguish them, we have no way of knowing which to use.
You can create several $soap type variables if you need to access different interfaces within the same script.
ie.$LocalLBNode = SOAP::Lite -> uri('urn:iControl:ITCMLocalLB/Node')... $LocalLBFailover = SOAP::Lite -> uri('urn:iControl:ITCMLocalLB/Failover') ..
-Joe - jajamax_127538
Nimbostratus
Joe, i can't figure this one out for the life of me.
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
