Expressions
$parameters.appname + "-mon"
appname, and concatenates it with the string -mon.
and, false, in, not, true, and or.
Arithmetic expressions
-
Addition (+)
-
Subtraction (-)
-
Multiplication (*)
-
Division (/)
-
Modulo (%)
-
Adding two numbers: $parameters.a + $parameters.b
-
Multiplying two numbers: $parameters.a * 10
-
Finding the remainder after division of one number by another:
15%10 Results in 5
String expressions
-
Concatenate two strings (+)
List expressions
Relational expressions
-
== : Tests if two operands are equal and returns true if they are equal, else returns false.
-
!= : Tests if two operands are different and returns true if they are different, else returns false.
-
\> : Returns true if the first operand is greater than the second operand, else returns false.
-
\>= : Returns true if the first operand is greater than or equal to the second operand, else returns false.
-
\< : Returns true if the first operand is lesser than the second operand, else returns false.
-
\<= : Returns true if the first operand is lesser than or equal to the second operand, else returns false.
-
Use of Equality operator:
$parameters.name = = "abcd" -
Use of Inequality operator:
$parameters.name != "default" -
Examples for other relational operators
-
10 > 9 -
10 >= 10 -
0 < 9 -
10 <= 9 -
10 == 10 -
10 != 1
-
Logical expressions - boolean
-
and: The logical 'and' operator. If both operands are true, the result is true, else it is false.
-
or: The logical 'or' operator. If one of the operands is true, the result is true, else it is false.
-
not: The unary operator. If the operand is true, the result is false, and the opposite way.
-
in: Tests whether the first argument is a substring of the second argument
-
in: Tests if an item is part of a list
tcp-port to a number (using the int() builtin function), and an IP address can be cast to a string (using the str() builtin function).
-
Before an operator:
space,tab,comma,(,),[,] -
After an operator:
space,tab,(,[
-
abc + def -
100 % 10 -
10 > 9 -
$item in $parameters.some-list
Splat expressions
[*] provides a simpler way to retrieve a certain attribute from a complex list for all the iterations. You can now include splat expressions in a StyleBook definition.
list[*].attribute
$parameters.server-members[*].hostname
$parameters.server-members[*].sub-domains[*].name
Verbatim string expressions
~{string}~
}~ in an input string because this sequence indicates the end of a verbatim string.
~{HTTP.REQ.COOKIE.VALUE("jsessionid") ALT HTTP.REQ.URL.BEFORE_STR("=").AFTER_STR(";jsessionid=") ALT HTTP.REQ.URL.AFTER_STR(";jsessionid=")}~
Target expressions
$current-target expression to refer the current target NetScaler instance. To specifically refer an IP address of the target NetScaler instance, use this expression as follows:
$current-target.ip
components:
-
name: lb-comp
type: ns::lbvserver
properties:
name: $current-target.ip + "-lbvserver"
lbvserver uses the IP address of the target NetScaler instance.
Expression Type Validation
lbvserver StyleBook is tcp-port. In NetScaler Console, the type validations happen at compile-time (import-time). The compiler finds that string and tcp-port are not compatible types and therefore, the StyleBook compiler displays an error and fails to import or migrate a StyleBook.
components:
-
name: lbvserver-comp
type: ns::lbvserver
properties:
name: mylb
ipv46: 10.102.190.15
port: str("80")
servicetype: HTTP
port: 80
lb-sg-binding-comp component is: $components.lbvserver-comp.properties.lbvservername. However, there is no property called lbvservername in component lbvserver-comp.
Components:
-
name: lbvserver-comp
type: ns::lbvserver
properties:
name: mylb
ipv46: 10.102.190.15
port: 80
servicetype: HTTP
-
name: sg-comp
type: ns::servicegroup
properties:
servicegroupname: mysg
servicetype: HTTP
-
name: lb-sg-binding-comp
type: ns::lbvserver_servicegroup_binding
condition: $parameters.create-binding
properties:
name: $components.lbvserver-comp.properties.lbvservername
servicegroupname: $components.sg-comp.properties.servicegroupname
Implicit typecasting of datatypes
-
Adding (+) two variables of type
stringandnumber, sets the output datatype tostring.
$parameters.appname + '_' + $parameters.app_instance_num
-
Adding (+) two variables of type
stringandipaddress, sets the output datatype tostring.
$parameters.appname + '_' + $parameters.instance_ip
-
Adding (+) two variables of type
ipaddressandnumber, sets the output datatype toipaddress.
$parameters.instance_ip + $parameters.number
-
Subtracting (-) two variables of type
ipaddressandnumber, sets the output datatype toipaddress.
$parameters.instance_ip - $parameters.number
-
Multiplying (*) two variables of type
stringandnumber, sets the output datatype tostring.
$parameters.dummy_str * $parameters.count
-
If a variable is defined as the
stringdatatype, the assigned value is converted to the defined datatype.
name: $parameters.port * 3
-
If a variable is defined as the
portnumberdatatype, the assigned value converted to theportnumberdatatype with exceptions.
port: $index + $parameters.lower_limit
Indexing Lists
| Expression | Description |
$components.test-lbs[0] |
Refers to the first item in thetest-lbs component |
$components.test-lbs[0].properties.p1 |
Refers to property p1 of the first item in the test-lbs component |
$components.lbcomps[0].outputs.servicegroups[1].properties.servicegroupname |
Refers to the property servicegroupname of the second item in the servicegroups component, which is an output from the first item of the lbcomps component |
Policy expressions in StyleBooks
Enable policy Expression Editor in StyleBooks GUI
is_policy_expression GUI attribute in the parameter definition. When enabled (set to true) this setting allows you the invoke the Expressions Editor when entering a value for this parameter.
parameters:
-
name: expression
type: string
label: Expression
required: true
gui:
is_policy_expression: true
Create and build policy expressions
-
Navigate to Applications > Configurations > StyleBooks. The StyleBooks page displays all the StyleBooks that are available in your NetScaler Console.
-
Select a StyleBook that includes policy expressions in its parameters.
-
Click Create Configuration. In the Create Configuration page, enter values for all the parameters defined in this StyleBook.
-
Click the icon next to the Expressions field. The Create an expression page appears.

-
In Create an expression, use the intuitive drop-downs to construct your policy expression. Click Submit.
If you want to create a custom policy expression, click on EPA Editor or Expression Editor to build your expressions. Review your expressions in Preview Expressions and then click Submit. -
Select the target NetScaler instance on which the configuration should be deployed and click Submit.
