vADC Forum

Reply
Occasional Contributor
Posts: 11
Registered: ‎02-10-2014

Pass parameters for a rule

Is it possible to pass parameters for a rule. - i.e. Like we can provide init parameters for Java extensions?


i.e. I need to set a flag depending on my application status and use that flag in my rule and do different actions.

Brocadian
Posts: 227
Registered: ‎11-29-2012

Re: Pass parameters for a rule

Fahim,

can you be more specific on the use case? I can think of a few possible ways, but I would like to ensure I understand the problem properly first.

Cheers.

Aidan.

Occasional Contributor
Posts: 11
Registered: ‎02-10-2014

Re: Pass parameters for a rule

Hi Aidan,

I have one Virtual Server and there's no room add another. This VS receives requests for two host names (say www.one.mydomai.com and www.two.mydomai.com ). Also I have different applications deployed which are accessible from above domains (with different context roots).

When app1 is under maintenance I want to put up maintenance page for "www.one.mydomai.com/app1" requests and other apps must be accessible during this time. Also I do not want to have maintenance-rules for each domain/ app combination, but one generic maintenance rule.

So for this if theres any way to pass parameters to rules, I can have one maintenance rule which will accept the domain-name and app-name as parameters and put up the maintenance page.

Appreciate your thoughts here. Thanks.

Brocadian
Posts: 227
Registered: ‎11-29-2012

Re: Re: Pass parameters for a rule

Fahim,

Apologies for the delay in responding...

You could easily set this up with variables in the TS that can either be set in the script itself (ie: app1Mainenance = 1) or using a file on the STM or an HTTP call out to a web server somewhere to check for a file for example.

As example of the variables in the script could be:


# Static Variable Example:


# Change the appropriate app<n> prefix between "active" and "maintenance"


# to enable redirection to the maintenance page:



# $application_hash is a hash of URL prefixes and their desired state


# of either "active" or "maintenance"



$applications_hash = [ "/app1" => "active",


                       "/app2" => "maintenance"


                     ];



$path = http.getPath();



switch ($path) {


  case "/app1":


  if ( $applications_hash[$path] == "maintenance") {


  pool.use("pool_maintenance");


  }


  case "/app2":


  if ( $applications_hash[$path] == "maintenance") {


  pool.use("pool_maintenance");


  }


}


(note: the above script could be made easier to maintain by putting the switch statement into a for() loop iterating through the keys in $application_hash, but I opted not to for the sake of reading / understanding clarity.)

If you want to use a flat file or HTTP based lookup to an external resource (like files on a web server somewhere) the logic is the same, but instead of using the $application_hash[] hash, you would use a file in the "extra files" section using resource.get() or make the request to an external server using an http.request.get() call...

Does this help?

Cheers.

Aidan.

Brocadian
Posts: 227
Registered: ‎11-29-2012

Re: Pass parameters for a rule

Fahim,

How did you go with the details in my last post? Was it helpful? Did it solve your problem?

A.

Join the Community

Get quick and easy access to valuable resource designed to help you manage your Brocade Network.