Forum Discussion
brice_11994
Nimbostratus
Aug 12, 2008Perl LocalLB/VirtualServer - Changing iRules on a VIP
Hey guys,
My end state is to have a script to list the iRules of a VIP, remove iRules from a VIP, and add iRules to a VIP. I am having all kinds of trouble referencing the elements of the array returned with the get_rule function. When I go to reference the returned data I get the following error...
"Bad index while coercing array into hash"
Here is my code
$soapResponse = $VirtServ->get_rule(SOAP::Data->name(virtual_servers => [$sVirt]));
&checkResponse($soapResponse);
@StringRuleList = @{$soapResponse->result};
foreach $StringRule (@StringRuleList)
{
$rule_pri = $StringRule->{"priority"}; <-- This is the line it errors on
$rule_name = $StringRule->{"rule_name"};
print "$rule_name\n$rule_pri\n\n";
}
I have tried to use the Data:Dumper, and I can see the data is being collected, but it will not reference it according to the documentation. Here is the output from Data:Dumper.
$VAR1 = bless( [
bless( {
'priority' => '0',
'rule_name' => 'rule_test'
}, 'LocalLB::VirtualServer::VirtualServerRule' )
], 'LocalLB::VirtualServer::VirtualServerRule[]' );
What am I doing wrong?
- You are treating the response like a 1-d array while it is in reality a 2-d array.
VirtualServerRule [] [] get_rule(
- I just whipped a sample up for you and put it in the iControl codeshare.
http://devcentral.f5.com/wiki/default.aspx/iControl/PerlVirtualServerRule.html
$ ./VirtualServerRule.pl bigip port user pass list [virtual]
- brice
Nimbostratus
Wow! You rock! Thanks a bunch. I will test it out tomorrow and report back. - Glad to help! Please do report back and don't be a stranger...
- brice
Nimbostratus
Well, what can I say. The script works great for all three scenarios. I am going to actually hardcode some values and duplicate the script with a php front end, but this is great.
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