Forum Discussion
Anthony_Gerace_
Nov 15, 2004Historic F5 Account
How to retrieve the rule details with query_all_rules
Hi!
I am attempting to write a script that will display the contents of all rules on a given system. In trying to use the query_all_rules method I'm having difficulty with retrieving the details for a given rule.
From the 4.5 SDK
void query_all_rules(
in SessionCredentials creds, <== CORBA Specific
out String[] rule_names,
out String[] rule_details
);
I used the $soap_response-> result to get the rule names and $soap_response->paramsout to get the rule_details. Where I'm having problems is tying the rule detail to a specific rule name. Can someone explain what type of structure rule_details is and how do I access only a specific rule's detail?
Thanks.
Anthony
- Loc_Pham_101863Historic F5 AccountEach "rule_details" in the returned list is just a string representation of the rule text, with each rule detail string corresponding to the same rule name at a particular index. For example:
- Anthony, here is code illustrating the use of ITCMLocalLB::Rule::query_all_rules in Perl:
sub getRules() { $soapResponse = $LocalLBRule->query_all_rules(); if ( $soapResponse->fault ) { print $soapResponse->faultcode, "(faultstring) ", $soapResponse->faultstring,"\n"; print $soapResponse->faultcode, "(faultdetail) ", $soapResponse->faultdetail, "\n"; } else { @rule_names = @{$soapResponse->result}; @params = $soapResponse->paramsout; @rule_details = @{@params[0]}; $i = 0; foreach $rule_name (@rule_names) { $rule_detail = @rule_details[$i]; print "Rule $i\n"; print "Name: $rule_name\n"; print "Details: $rule_detail\n"; print "----------------------\n"; $i++; } } }
- Anthony_Gerace_Historic F5 AccountThanks for the help. It worked.
- Scott_Augustus_
Nimbostratus
Is there an example for v9? I'm able to properly query all rules but can't seem to parse the results and print them. I know the syntax has changed for the results (rule_names --> rule_name, rule_detail --> rule_definition), I made appropriate changes but I get out of memory errors in perl and I'm kinda new to perl so I'm at a loss. - In 9.x the signature for the query_all_rules() method is:
struct RuleDefinition { string rule_name; string rule_definition; }; RuleDefinition[] query_all_rules();
sub getRules() { $soapResponse = $LocalLBRule->query_all_rules(); if ( $soapResponse->fault ) { print $soapResponse->faultcode, "(faultstring) ", $soapResponse->faultstring,"\n"; print $soapResponse->faultcode, "(faultdetail) ", $soapResponse->faultdetail, "\n"; } else { $i = 0; @RuleDefinitionList = @{$soapResponse->result}; foreach $RuleDefinition (@RuleDefinitionList) { $rule_name = $RuleDefinition->{"rule_name"}; $rule_definition = $RuleDefinition->{"rule_definition"}; print "Rule $i\n"; print "Name: $rule_name\n"; print "Details: $rule_definition\n"; $i++; } } }
- Anytime!
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