Forum Discussion
Michel_van_der_
Nimbostratus
Jan 10, 2006LocalLB.VirtualServer.add_rule question
I tried to apply a rule to a virtual server, but it does not seem to work.
What format should the parameter 'virtual_servers' take. Is that '1.2.3.4:80' or the name of the virtual server?
12 Replies
- The API's use the name of your virtual server, not the IP:port.
-Joe - Michel_van_der_
Nimbostratus
To answer (part of my) own question, I fixed the perl code (not an array of servers passed in.
But the trace questions remains... - You may need to update your syslog-ng configuration as follows:
The local4 facility level needs to be set to debug
local4.* /var/log/ltm
filter f_local4 {
facility(local4) and level(debug..emerg);
};
Issue a "bigstart restart syslog-ng" and you should be set.
BTW, all the iControl tracing will do is print out input parameters that you can easily do with SOAP::Lites built in tracing. I guess it's good to show how the SOAP inputs are converted to local format though...
-Joe - Cindy_127211
Nimbostratus
Hello, I saw your code example and am 'very' interested in trying to get this to work in my enviornment. I'd like to use it to activate a rule to display a specific page during a maintenance window. It looks like it could add a rule to the list to do this. But, I can't seem to get it to work. I can see that it connects properly and executes the add_rule method; however, I don't see that it ever makes any configuration changes. I handed it the appropriate virtual server name, bigip IP and rule name. Any ideas? - Michel_van_der_
Nimbostratus
The code as posted is wrong.
Not sure I quite understand your question. Did you fix the code and does iControl return success, but yet, you don't see the rule? - What do you mean when you said that you don't see that it ever makes any configuration changes? After you execute the add_rule() method, the rule should show up in the virtual servers resource list. If it is not showing up there, then odds are there is an issue with the rule itself. I'd try adding the rule manually through the GUI. Odds are that won't work as well.
If you mean that after you reboot your configuration changes are not persisted, then that's an issue with the way iControl works. All iControl calls are made to the systems running configuration. To persist across loads, you will need to call the System::ConfigSync:::save_configuration() method to persist your changes to disk.
-Joe - Cindy_127211
Nimbostratus
Sorry, I don't really understand what needed to be fixed in the code. My code looks like the following, and it is just not adding the 'rule' to the virtual server, as expected. Can you clarify for me what needs to be fixed?
! perl
use strict;
use SOAP::Lite +trace => qw(all);
sub usage { print STDERR "testCaseForF5 \n"; }
----------------------------------------------------------------------------
SOAP Transport Information
----------------------------------------------------------------------------
sub SOAP::Transport::HTTP::Client::get_basic_credentials { return "user" => "pwd"; }
sub main {
my ($ip, $n, $soap, $soapResponse, $r);
return usage() if @ARGV != 2;
$ip = $ARGV[0]; $n = $ARGV[1];
$soap = SOAP::Lite->uri("urn:iControl:LocalLB/VirtualServer")
->proxy("https://$ip/iControl/iControlPortal.cgi") ||
die "Can't create SOAP object for $ip\n";
$soapResponse = $soap->add_rule(
SOAP::Data->name('virtual_servers' => $n),
SOAP::Data->name('rules' => [ [
{ 'rule_name' => "IPRO_NONSSL",
'priority' => 1 } ] ]),
);
if ( $soapResponse->fault ) {
print "SOAP Error: ",
$soapResponse->faultcode, "; ",
$soapResponse->faultstring , "\n";
return 0;
}
}
main;
1; - Yep that's it. the virtual_servers parameter is expected to be an array and without enclosing it in brackets, a literal string is passed to the server. The server then looks for the array and finds a size of 0 (a literal isn't automatically cast to an array) it simply returns without an error.
-Joe - Cindy_127211
Nimbostratus
Thank you all for your quick responses to this. I realize the information was there from an earlier post....I just didn't understand it (not really much of a programmer type, unfortunately). Anyway, I got the code to work and it adds a rule as expected. The next thing I need to do is figure out if there is a way to make the rule the first in the list of rules. I thought 'priority' might do that...but, it didn't. Any ideas? - There is no way to control what order the rules show up in the GUI. The Priority specifies what order the rules are processed. The default value is 500. The rules will be processed from lowest priority number to highest. So, a rule with priority 100 would be processed before all other default priority rules.
Make sense?
-Joe
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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