cancel
Showing results for 
Search instead for 
Did you mean: 

How to get current configuration location in TrafficScript

SOLVED
jamiecon
New Contributor

How to get current configuration location in TrafficScript

I would like to get the current configuration location of an executing script in TrafficScript. However, I can't find anything in the docs to point me in the right direction.

The backgroud to this requirement is that I would like to push incoming traffic on a particular virtual server to specific nodes within a pool, based on some characteristic of the request.

This particular virtual server and pool run across two configuration locations. The nodes in the pool are split by configuration location, e.g. Location 1 has nodes L1Web01, L1Web02 and Location 2 has nodes L2Web01, L2Web02.

I can select a specific node using pool.use(...) however my choice of node also depends on the location that the request is coming in on - if we're in L1, I want to use an L1 node, if we're in L2, I want to use an L2 node.

Ideally I would be able to get the configuration location, but I'm also open to alternative suggestions.

Thanks in advance for any help

1 ACCEPTED SOLUTION

Accepted Solutions
jochenmaurer
Contributor

Re: How to get current configuration location in TrafficScript

you can use the trafficscript function geo.getLocation() to get the current location of the trafficmanager

something like this should do the job


if (geo.getLocation() == "Location1") {


# do something and choose L1-Node


} else {


# do something else and choose L2 Node


}


View solution in original post

2 REPLIES 2
jochenmaurer
Contributor

Re: How to get current configuration location in TrafficScript

you can use the trafficscript function geo.getLocation() to get the current location of the trafficmanager

something like this should do the job


if (geo.getLocation() == "Location1") {


# do something and choose L1-Node


} else {


# do something else and choose L2 Node


}


jamiecon
New Contributor

Re: How to get current configuration location in TrafficScript

I'm an idiot, sorry - not sure how I missed this!

Thanks