Contents
Variables........................................................................................................
10
11
Variables
The NetScaler appliance supports creation of variables of the following types:
Singleton variables. Can have a single value of one of the following types: ulong and
text (max-size). The ulong type is an unsigned 64-bit integer, the text type is a
sequence of bytes, and max-size is the maximum number of bytes in the sequence.
Map variables. Maps hold values associated with keys: each key-value pair is called a
map entry. The key for each entry is unique within the map. Maps are specified as
follows:
map (key_type, value_type, max-values).
where,
value_type is the data type of the values of the map. It can be of type ulong or text
(max-size).
max-values is the maximum number of entries that the map can contain. It is of
type ulong.
Values for these variables are set using assignments which must be invoked on policy
actions.
add ns assignment
name
Name for the assignment. Must begin with a letter, number, or the underscore character
(_), and must contain only letters, numbers, and the hyphen (-), period (.) hash (#),
space ( ), at (@), equals (=), colon (:), and underscore characters. Can be changed after
the assignment is added.
The following requirement applies only to the NetScaler CLI:
If the name includes one or more spaces, enclose the name in double or single quotation
marks (for example, "my assignment" or 'my assignment).
variable
Left hand side of the assigment, of the form $variable-name (for a singleton variabled) or
$variable-name[key-expression], where key-expression is a default syntax expression that
evaluates to a text string and provides the key to select a map entry
set
Right hand side of the assignment. The default syntax expression is evaluated and
assigned to theleft hand variable.
add
Right hand side of the assignment. The default syntax expression is evaluated and added
to the left hand variable.
sub
Right hand side of the assignment. The default syntax expression is evaluated and
subtracted from the left hand variable.
append
Right hand side of the assignment. The default syntax expression is evaluated and
appended to the left hand variable.
clear
Clear the variable value. Deallocates a text value, and for a map, the text key.
comment
Comment. Can be used to preserve information about this rewrite action.
View description(s) in command reference Top
10
Create an entry for the sessionid and set that value to 1 (this value is not actually
used).
> add ns assignment add_session -variable '$session_map[http.req.cookie.value("sessionid")]' -set 1
Deallocate the entry for a session ID, which implicitly decrements the value count
for session_map.
To check if a map entry exists for that sessionid in the HTTP request. The
add_session assignment is executed if the map entry does not exist.
To check for login requests and if the number of active sessions exceed 100. If
these conditions are satisfied, in order to limit the number of sessions, the user is
redirected to a page that indicates that the server is busy.
12