Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 

CLI Configlet Examples

 

Default Configlets are added during server start up or data migration. These default configlets are added only on the initial server start up and during data migration. The user can perform all the usual operations on the default Xpath and Regex, including delete operation.

Adding default configlets during migration has the following conditions:

  • 13.1 to 13.3:

    • Default Configlets are added if an entity with the same name does not exist in 13.1.

    • Default Configlets are over written if an entity with the same name exists in 13.1.

  • 13.3 to later releases:

    • Default Configlets are not added or overwritten, if the default Configlet is modified or deleted by the user in 13.3.

Example 1: Setting the description of a physical interface

Context: /device/interface-information/physical-interface This configlet is targeted for physical interface.

Configlet

Parameters

Parameter

Details

$INTERFACE

This is a default variable and the value would be the name of the interface which the configlet is invoked from. This would be null if the configlet is invoked from CLI Configlets workspace as the execution is not associated to a specific interface.

$DESC

A text field to get the description string. The value is got at the time of execution.

On applying the CLI Configlet, the user needs to input the parameters. For our example, user needs to input a value for $DESC.

Consider our example being applied to an interface ge-0/1/3 and the following values are given as input.

Parameter

Value

$DESC

TEST DESC

The generated configuration string would be

Example 2: Setting the vlan of a logical interface, where the vlan id is chosen from a predefined set of values

Context: /device/configuration/interfaces/interface/unit This CLI Configlet is targeted for logical interface

CLI Configlet

##Since VLAN id will be given as a selection field, the value would be a collection and to get the first selected value, use .get(0)

Parameter

Details

$INTERFACE

This is a default variable and the value would be the name of the interface which the CLI Configlet is invoked from. This would be null if the CLI Configlet is invoked from CLI Configlets workspace as the execution is not associated to a specific interface.

$UNIT

This is a default variable and the value would be the unit name of the logical interface which the CLI Configlet is invoked from. This would be null if the CLI Configlet is invoked from CLI Configlets workspace as the execution is not associated to a specific logical interface.

$VLANID

This is a selection field and the value would be chosen at the time of execution.

Type: Selection Field

Selection Values: 0,1,2,3

Default Value: 3

On applying the CLI Configlet, the user needs to input the parameters. For our example, user needs to input a value for $VLANID.

Consider our example being applied to an interface ge-0/1/3.3 and the following values are given as input.

Note

Since $VLANID is defined as a selection field, the user has to select one value form a list. The list of options are either specified by Selection Values Xpath or in Selection Values field. The default selection in the list would be 3 as defined in the default value field.

Parameter

Value

$VLANID

2

The generated configuration string would be

Example 3: Setting a description on all the interfaces of a device

Context: NULL or /device. Targeted to a device, the context of a device can either be null or /device

CLI Configlet

Parameter

Details

$INTERFACENAMES

An invisible variable with an XPath configured to fetch all the interface names.

Configured values XPath: /device/interface-information/physical-interface/name/text()

$DESC

A text field to get the description string. The value is got at the time of execution.

The following input is given while executing the CLI Configlet

Parameter

Value

$DESC

TEST DESC

The generated configuration string would be (when the device has three physical interfaces, ge-0/0/0, ge-0/0/1 and ge-0/0/2).

Example 4: Setting a configuration in all the PICs belonging to a device and certain configuration only on the first PIC of FPC 0

Context: NULL or /device. Targeted to a device, the context of a device can either be null or /device

##$ELEMENTS : /device/chassis-inventory/chassis/chassis-module[starts-with(name,"FPC")]

/name/text() | /device/chassis-inventory/chassis/chassis-module

[starts-with(name,"FPC")]/chassis-sub-module[starts-with(name,"PIC")]/name/text()

##this will contain the list of all FPCs and PICs in Depth-first traversal‎ order.

##Hierarchy array is a 2 dimensional array used to store FPC-PIC hierarchy, with each row containing PICs belonging to a single FPC. The first element is the FPC.

CLI Configlet

Parameters

Parameter

Details

$ELEMENTS

This is an invisible field and the value cannot be set by the user at the time of execution. The values are taken form a predefined XPath

Type: Invisible field

Configured Value XPath: /device/chassis-inventory/chassis/chassis-module[starts-with(name,"FPC")]

/name/text()/device/chassis-inventory/chassis/chassis-module[starts-with

(name,"FPC")]/chassis-sub-module[starts-with(name,"PIC")]/name/text()

This XPath returns the list of FPCs and PIC is Depth First Traversal order.

While executing this CLI Configlet, the XPath of $ELEMENTS param will return the list of FPCs and PIC present in the device. The values for instance would be [FPC 0,PIC 0,PIC 1, FPC 1, PIC 0, PIC 1] This order implies the association

FPC 0

PIC 0

PIC 1

FPC 1

PIC 0

PIC 1

When the CLI Configlet is executed, we get the following configuration string

Example 5: Halting the description of a physical interface

Context: /device/interface-information/physical-interface This CLI Configlet is targeted for physical interface

CLI Configlet

Parameter

Details

$INTERFACENAME

A variable with an XPath configured to fetch all the interface names.

Configured Value XPath: //device/interface-information/physical-interface/name/text()

Note

When using $INTERFACE, $UNIT, Configured Value Xpath, Invisible Params, Selection fields; the variable definition in the configlet editor should contain .get(0) in orderinorder to fetch the value from the array. Eg: $INTERFACE.get(0)

Example 6: Deleting configuration from a physical interface

Context: /device/interface-information/physical-interface This CLI Configlet can be used to delete the configuration enabled on the physical interface to support IEEE 802.3ah link fault management.

CLI Configlet

Note

Ensure that you insert the delete: statement at the proper hierarchy level to avoid necessary configuration being deleted from the device.