Forum Discussion
Gunasekaran_344
Nimbostratus
Jun 05, 2008LocalLB.PoolMember
I'm a newbie to F5.i am trying to associate a monitor with a PoolMember with the snippet below. It doesn't throw any error, even checked by dumping the response
On verifying from GUI, the monitor is not associated for that poolMember
sub setmonitor {
my ($ip,$port,$pool,$lb);
my $soap = SOAP::Lite
->uri("urn:iControl:LocalLB/PoolMember")
->proxy("https://$lb/iControl/iControlPortal.cgi")|| die "Can't create SOAP object for $lb\n";
my $address_type ="ATYPE_UNSET";
my $ipport = { 'address' => $ip, 'port' => $port };
my $member ={ 'address_type'=>$address_type,'ipport'=>$ipport};
my $monitor_rule={'type' => 'MONITOR_RULE_TYPE_SINGLE', 'quorum' => 0, 'monitor_templates' => ['tcp']};
my $soapResponse = $soap->set_monitor_association(
SOAP::Data->name(pool_names=>[$pool]),
SOAP::Data->name(monitor_associations=> ['{member=>{$member}, {monitor_rule =>$monitor_rule}'] ) );
print "Response", Dumper($soapResponse), "\n";
if ( $soapResponse->fault ) {
print $soapResponse->faultcode;
print $soapResponse->faultstring;
print "ERROR";
}
}
Thanks in advance
-Guna
3 Replies
- This is a common question with dynamic languages. The method for set_monitor_association is
set_monitor_association( in String [] pool_names, in LocalLB__PoolMember__MemberMonitorAssociation [] [] monitor_associations );
You are calling it with this:set_monitor_association( in String [] pool_names, in LocalLB__PoolMember__MemberMonitorAssociation [] monitor_associations );
The second parameter for monitor_associations is a 2-d array so you can pass in multiple monitor_associations for each passed in pool member. You are passing in a 1-d array and the server is interpreting that as a 2-d array with the 2-nd dimension being size zero and thus a no-op is occuring. You'll want to make that monitor_associations a 2-d array.... my $monitor_rule={'type' => 'MONITOR_RULE_TYPE_SINGLE', 'quorum' => 0, 'monitor_templates' => ['tcp']}; my $monitor_assoc={'member' => $member, 'monitor_rule' => $monitor_rule} push monitor_assoc_array, $monitor_assoc; push monitor_assoc_AofA, monitor_assoc_array; my $soapResponse = $soap->set_monitor_association( SOAP::Data->name(pool_names => [$pool]), SOAP::Data->name(monitor_associations => [@monitor_assoc_AofA]) );
Disclaimer, I haven't tested this so hopefully it works for you. But, you get the idea, you need to make sure that the parameter is declared as an array and then coerced into a 2-d array with brackets. I'm sure there are other ways to do this, but this has worked for me in the past.
-Joe - Gunasekaran_344
Nimbostratus
Thanks Joe..
It's working ... :-)
-Guna - Great!
Debugging issues with the perl libraries can be tricky at times. Feel free to post again if anything else comes up.
-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
