Forum Discussion
benhaw01_9110
May 03, 2011Nimbostratus
No effect when using remove_wideip_pool and add_wideip_pool
Hello.
I'm using iControl against a v9.4.7 Build330.0 Hotfix HF2 GTM. I am trying to set the ratio of pool members in a wideIP. To be clear, PoolMember's set_ratio method won't do what I want, because I'm trying to set the ratio on the pool within the WideIP, not the ratio of members in a pool.
At a high level, I'm doing:
set_active_partition('Partition_1')
get_wideip_pool('wideip_name')
{get the pool definition from this response based on input parameters}
remove_wideip_pool('wideip_name', pooldef from previous step)
{set new ratio value on pooldef object}
add_wideip_pool('wideip_name', modified pooldef)
When I run the script, I find that it runs without error, but there is no effect reflected in the GUI, and subsequent runs show that iControl returns the old values as if they were never updated. The user that I'm logging in with has the Administrator role. Running it with only the "remove" request also shows no effect. The pool is not removed.
I'm attaching the code snippet in question as well as the input and output SOAP. I can attach the entire script if necessary. Am I doing something wrong (i.e. do I need to invoke some kind of "commit" or "update" method after sending these requests)? Does this GTM version have a bug? Does the output SOAP look like a successful response?
Perl code snippet:
Set the session to the appropriate Partition
$soapResponse = $ManagementPartition->set_active_partition(
SOAP::Data->name('active_partition' => 'Partition_1'),
);
&checkResponse($soapResponse);
$soapResponse = $GlobalPoolMember->get_wideip_pool
(
SOAP::Data->name('wide_ips' => [$sWip]),
);
&checkResponse($soapResponse);
my $poolList = $soapResponse->result->[0];
Search for the requested pool object from the response
my $poolObj;
my $found=0;
foreach my $pool (@$poolList) {
my $name = $pool->{'pool_name'};
if ($name =~ m/^$sPool$/) {
This is the pool we want.
$poolObj = $pool;
$found++;
last;
}
}
die ("Requested pool $sPool not found in $sWip.") unless $found;
Check to make sure we actually need to do something.
die ("Requested pool $sPool ($sWip) ratio is already set to $sRatio. Exiting.") if ($poolObj->{'ratio'} =~ /^$sRatio$/);
Now for the scary part.
Remove the pool...
$soapResponse = $GlobalPoolMember->remove_wideip_pool
(
SOAP::Data->name('wide_ips' => [$sWip]),
SOAP::Data->name('wideip_pools' => $poolObj),
);
&checkResponse($soapResponse);
Edit our pool object with the new settings
$poolObj->{'ratio'} = $sRatio;
Re-add it with the appropriate settings.
$soapResponse = $GlobalPoolMember->add_wideip_pool
(
SOAP::Data->name('wide_ips' => [$sWip]),
SOAP::Data->name('wideip_pools' => $poolObj),
);
&checkResponse($soapResponse);
Excerpts from the SOAP requests sent for remove_wideip_pool and add_wideip_pool:
(attached)
The output from remove_wideip_pool and add_wideip_pool:
(attached)
/e:envelope
- This is a very common mistake when dealing with the loosely typed languages like Perl and Python.
GlobalLB.WideIP.add_wideip_pool( in String [] wide_ips, in GlobalLB__WideIP__WideIPPool [] [] wideip_pools ) GlobalLB.WideIP.remove_wideip_pool( in String [] wide_ips, in GlobalLB__WideIP__WideIPPool [] [] wideip_pools )
On the server, we iterate through each of the wide_ips in the first parameter and then extract the list from the second parameter's associated 1-degree index. In your case, the second parameter isn't an array so it's treated as an array of size zero so it's essentially a no-op on the server. The same as if you passed in an empty size array.GlobalLB.WideIP.add_wideip_pool( in String [] wide_ips, in GlobalLB__WideIP__WideIPPool wideip_pools ) GlobalLB.WideIP.remove_wideip_pool( in String [] wide_ips, in GlobalLB__WideIP__WideIPPool wideip_pools )
Now for the scary part. Remove the pool... my $oldPoolObj = $poolObj; my @oldPoolObjA; push @oldPoolObjA, $oldPoolObj; my @oldPoolObjAofA; push @oldPoolObjAofA, [@oldPoolObjA]; $soapResponse = $GlobalPoolMember->remove_wideip_pool ( SOAP::Data->name('wide_ips' => [$sWip]), SOAP::Data->name('wideip_pools' => [@oldPoolObjAofA]), ); &checkResponse($soapResponse); Edit our pool object with the new settings $poolObj->{'ratio'} = $sRatio; my @newPoolObjA; push @newPoolObjA, $poolObj; my @newPoolObjAofA; push @newPoolObjAofA, [@newPoolObjA]; Re-add it with the appropriate settings. $soapResponse = $GlobalPoolMember->add_wideip_pool ( SOAP::Data->name('wide_ips' => [$sWip]), SOAP::Data->name('wideip_pools' => [@newPoolObjAofA]), ); &checkResponse($soapResponse);
- benhaw01_9110NimbostratusFantastic. Changing this:
- Sweet, I didn't realize you could double bracket a scalar to turn it into a 2-d array. Learn something new everyday!
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