Twig template examples➧
Overview
This page presents basic Macros submitted by our users, along with explanations.
Feel free to copy and try them out!
Attention
Commands may vary depending on your setup.
Refer to your device's manual for applicable commands.
Looking at ONU configuration➧
This example demonstrates a basic Template setup without any Parameters, that simply displays information.
Common tab➧
- Name:
Display ONU configuration
- Description: feel free to enter a descriptive overview of this macro
- Roles: feel free to select Roles appropriate to run this macro
- Model vendors filter: for the purpose of this demonstration we use the vendor
ZTE
- Models:
ZTE C320
- Display for:
ONU
- Display output:
All commands
Parameters tab➧
For this demonstration, we skip this tab since we don't need any Parameters.
Template tab➧
- Device and Interface: feel free to select a Device and/or an Interface applicable to this macro
- Parameters form: Since we don't have any Parameters, this section is not displayed.
- Variables: Here are the variables from the selected Device and Interface.
-
Template block:
Info
This is the input field that defines your macro, containing the specific CLI commands that are executed on the selected Device and/or Interface, combined with any Parameters you choose, if applicable.
Here we use the
iface
variable that the selected device provides.Info
Here you can see the result of this Template's compilation, the exact command that will run on your hardware.
For the purpose of this demonstration we selected a
ZTE C320
device andepon-onu_1/1/1:1
interface.Our
{{iface.name}}
variable evaluated toepon-onu_1/1/1:1
and the other static commands have been left unchanged.
Press the Create button and the macro is ready to use.
Running the macro➧
Navigate to a device and an interface applicable for this macro and find the macro we just created in the Macros tab.
Tip
Since we selected ONU
at the Display for step, the macro will only be visible on the appropriate sreen.
For this demonstration, we selected a ZTE 320
Device and it's gpon-onu_1/2/1:1
Interface.
Since we don't have any Parameters, the message This macro has no parameters is displayed instead.
When you press the Preview button, you can see it works the same way as shown in the Live preview on the Template tab.
The Execute button sends the commands to the selected device's interface, in this case gpon-onu_1/2/1:1
.
Changing the client's speed limit➧
Common tab➧
Fill out this tab according to your requirements.
Example
- Name:
Change client's speed limit
- Description:
Select a speed limit from the dropdown to be applied to the client's connection
- Roles:
Operator
- Model vendors filter:
ZTE
- Models:
ZTE C320
- Display for:
ONU
- Display output:
All commands
Parameters tab➧
- Add a new Parameter.
- Property:
speed
- Property display name:
Speed
- Required:
False
-
Parameter type:
Dropdown list from predefined
Info
Here we use predefined values to help the user choose the right one conveniently.
-
Predefined values list:
- Visibility condition: empty
Template tab➧
- Device and Interface: feel free to select a Device and/or an Interface applicable to this macro
- Parameters form: Here's the dropdown for the Speed parameter from the previous tab.
- Variables: Here are the variables from the selected Device and Interface, as well as
params
property which stores the values of the parameters we specified earlier. -
Template block:
Chosen template: Live result: Info
For the purpose of this demonstration we selected the Speed of
100MB
in the dropdown above and aZTE C320
device with an Interfaceepon-onu_1/1/1:1
.Similar to the previous example,
{{iface.name}}
evaluated toepon-onu_1/1/1:1
, and{{params.speed}}
stored the value we selected in the Speed dropdown.
The macro is now ready to use.
Running the macro➧
Navigate to a device and an interface applicable for this macro and find the macro we just created in the Macros tab.
Tip
Since we selected ONU
at the Display for step, the macro will only be visible on the appropriate sreen.
For this demonstration, we selected a ZTE 320
Device and it's epon-onu_1/1/1:1
Interface.
This time you can select the desired Speed from the dropdown and look at a Preview.
The Execute button sends the commands to the selected device's interface, in this case epon-onu_1/1/1:1
.
We will not actually Execute the macro in this demonstration for safety purposes.
Managing a VLAN➧
This macro involves more Parameters compared to the previous one.
Refer to the Parameter type options page as needed.
Common tab➧
- Name:
VLAN control
- Description:
Manage VLANs on a selected port
- Roles:
Operator, Engineer
- Model vendors filter:
D-Link
-
Models:
D-Link DES-1228/ME ...
feel free to select more appropriate devices, we will use this one for demonstration
-
Display for:
Device, Port
- Display output:
All commands
Parameters tab➧
-
Action parameter:
- Property:
action
- Property display name:
Action
- Required:
True
- Parameter type:
Dropdown list from predefined
- Predefined values list:
- Visibility condition: empty
- Property:
-
Type parameter:
- Property:
type
- Property display name:
Type
- Required:
False
- Parameter type:
Dropdown list from predefined
- Predefined values list:
-
Visibility condition:
Info
Here we reference the previous parameter, Action, and set the Type parameter to be shown only when the selected action is
'Add'
.
- Property:
-
VLAN parameter:
- Property:
vlan
- Property display name:
VLAN
- Required:
True
- Parameter type:
Dropdown list from variables
-
Value source:
data.vlans
Info
This device variable stores an array of objects, properties of which describe the VLANs we want to configure.
-
Visibility condition: empty
-
Item name:
${item.name} (${item.id})
Info
We choose the VLAN's
name
andid
properties to be shown in the drop-down for convenience.
- Property:
-
Port parameter:
- Property:
port
- Property display name:
Port
- Required:
False
- Parameter type:
Dropdown list from variables
- Value source:
interfaces_list
-
Visibility condition:
!iface
Info
This condition hides the parameter from screens that provide the
iface
variable from a device, such as selected interfaces.Therefore, when running this macro from a Device screen, we can select a specific interface from the drop-down, otherwise, it's not shown.
-
Item name:
${item.name}
- Property:
Template tab➧
-
Device and Interface: feel free to select a Device and/or an Interface applicable to this macro
Info
For this demonstration we select a
D-Link DES-1228/ME
device and no Interface. -
Parameters form:
For this demonstration we select:
- Action:
Add
- Type:
Untagged
- VLAN name:
sw802 (802)
- Port:
1/1
Info
You are presented with the parameters we specified in the previous step.
Type drop-down is only visible when the Action is set to
Add
, Port is only visible when we haven't selected an Interface. - Action:
-
Variables:
Here are the variables from the selected Device and Interface, as well as
params
property, which stores the values of ouraction
,type
,vlan
andport
parameters.Info
_display_name
property here is the Item name variable we specified in the previous step.We specified
${item.name}
for our Port parameter, but we could also leave it empty since it evaluates to this by default. -
Template block:
Live result
The macro is now ready to use.
Running the macro➧
Navigate to a device and/or an interface applicable for this macro and find the macro we just created in the Macros tab.
For this demonstration, we selected a D-Link DES-1228/ME
Device.
Preview:
Execution: