Input Variable is designed to receive the input from users during Qapp execution and the Qapp processes data and output results based on the input.

The Input Variable node is after the Start node and before the Canvas node. The variables can be called in the Output node of the Canvas node.

Defining an Input Variable

The variables, such as name, type, and default value, are defined with scripts in the JSON format.

Sample codes:

[
    { "name": "vlan", "type": "int", "label": "VLAN", "value": 1, "desc": "Please input a VLAN ID"},
    { "name": "map_vlan", "type": "bool", "label": "Map VLAN Swith", "value": false },
    { "name": "source_ip", "type": "string", "label": "Source IP", "value": "0.0.0.0" },
    { "name": "source_port", "type": "string", "label": "Source Port", "value": "UDP", "items": [ "TCP", "UDP", "IP" ] },
    { "name": "vrf", "type": "string", "label": "VRF", "value": "", "items": "$vrf" },
    { "name": "template_folder", "type": "string", "label": "Template Folder","style": "folder","desc":"Please select a folder" },
    { "name": "template_file", "type": "string", "label": "Template File","style": "file","desc":"Please select a file" }
]

A variable contains the following properties:

Property Name

Description

name*required

The name of the variable. The name should conform to the rules of a variable.

type*required

The value type of the variable. The supported type includes string, int, bool and double. The variable in the bool type shows as a checkbox at the GUI.

label*required

The display name of the variable in the Input GUI.

value

The default value of the variable. This property is optional. The value of a variable in the bool type is false or true.

items

Used to define the candidate values of the variable. This property shows a drop-down list with candidate values contained.

The candidate values can be manually specified or call the device properties in GDR.

style

This property is optional and used to receive a file or folder input. The value of the style is folder or file. It will generate a Select control when you run the Qapp.

desc

The description of the variable. This property is optional. The description will appear when you point to the icon next to the variable in the Input GUI.

Sample Case

Create a Qapp that sends alerts if a device CPU is higher than an input value.

1.Click the icon from the taskbar and select New Qapp from the drop-down menu to open the Qapp Editor.

2.Click the icon on the Start node, select Input Variables, and click Extend.

3.Rename the Node Name as inputCPU and define the input variable as follow:

[
    { "name""CPU_value""type""int""label""CPU Threshold""value""80"}
]

4.Click the icon on the inputCPU node, select Canvas, and click Extend.

5.Double-click the Canvas node and keep the default settings at the Device Queue node.

6.Extend a Device(this) node from the Device Queue node, and keep the default options.

7.Extend a CLI command node from the Device(this) node.

8.At the Command node, enter show process cpu and select the show processes cpu (Cisco IOS Switch, Cisco Router) parser.

9.Click the icon on the Command node, then select Device Data Table and click Extend.

10.Click the icon and export one_min_cpu_usage to the table node.

11. Extend a Basic Output node from the Table node and add a condition at the Basic Output node.
If $one_min_cpu_usage > $inputCPU.CPU_Value

12. Extend an Alert node from the Output node.

13. Enable the Device Alert checkbox and define the alert:

1)Select $_device as the target device.

2)Rename the alert name as High CPU.

3)In the Alert field, enter alert content, such as The CPU usage exceeds the $InputCPU.CPU_value, check the device.

14. Save and run the Qapp. For the demo purpose, set the input value to 1. A sample result is as follows: