DataScript: avi.pool.select

DataScript

Function avi.pool.select( pool [, server [, port]] )
Description Selects a pool or a specific server within a pool for the current request. The selection does not take effect if an HTTP request policy was also configured with a switching action to select a pool or a specific server in a pool. The switching action of the HTTP request policy takes precedence over the DataScript's pool selection.
Events HTTP_REQ
Parameter pool can be a specific pool name or an expression that evaluates to a valid pool name.


The server parameter (a string) is the IPv4 address of the server, in quotes. Starting with release 17.2.4, a server name may be supplied.

The optional port parameter (an integer) forwards the connection to a specific service port of the server. The port must be a number between 0 and 65536, or an expression that evaluates to a valid port number.

Caveats The pool name, server name or IP, and the server port may be called explicitly, or dynamically determined based on a Lua expression. If the pool name, server, or server port do not exist or are not able to be referenced by the virtual service, an error is generated.

  • Explicit reference: A configuration error will be generated while saving the DataScript.
  • Dynamically generated reference: A runtime error is generated, which results in a 500 error return to the client.
Returns No value returned
Related avi.poolgroup.select() Selects a pool group for the current request.
Example 1 Forward the request to an explicit destination.
if avi.http.get_path() == "/sales/" then
   avi.pool.select("sales-pool")
elseif avi.http.get_path () == "/engineering/" then
   avi.pool.select("engineering-pool", "apache1")
elseif avi.http.get_path () == "/marketing/" then
   avi.pool.select("marketing", "10.10.31.201")
end
Example 2 Forward the request to a dynamically generated destination.
www.avi.com/support/index.htm would go to the support pool
www.avi.com/sales/apac/index.htm would go to the sales pool
avi.pool.select(avi.http.get_path_tokens(1, 1))
Example 3 Forward the request to a named server.

var = "abcd"
avi.pool.select("poolx", var)

Note: Datascript Avi pool select feature is not supported for IPv6.