Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Navigation
Guide That Contains This Content
[+] Expand All
[-] Collapse All

    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

    interfaces {$INTERFACE{description “$DESC”;}}

    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

    interfaces {ge-0/1/3{description “TEST DESC”;}}

    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

    interfaces {$INTERFACE {vlan-tagging;unit $UNIT{vlan-id $VLANID.get(0);}}}

    ##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

    interfaces {ge-0/1/3 {vlan-tagging;unit 3{vlan-id 2;}}}

    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

    interfaces {#foreach($INTERFACENAME in $INTERFACENAMES)$INTERFACENAME {description “$DESC”;}#end}

    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).

    interfaces {ge-0/0/0 {description “TEST DESC”;}ge-0/0/1 {description “TEST DESC”;}ge-0/0/2 {description “TEST DESC”;}}

    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

    #set( $HIERARCHY = [] )
    #set( $LOCALARRAY = [])
    #foreach ( $ELEMENT in $ELEMENTS )
    #if($ELEMENT.startsWith("FPC"))
    ## Create a new array for each FPC with the first element as FPC
    #set( $LOCALARRAY = [$ELEMENT])
    #set( $result = $HIERARCHY.add($LOCALARRAY))
    #elseif($ELEMENT.startsWith("PIC"))
    ## Add the PIC in the current Local array., This is the array of the parent FPC
    #set( $result = $LOCALARRAY.add($ELEMENT))
    #end
    #end
    
    chassis {redundancy {failover on-disk-failure;graceful-switchover;}aggregated-devices {ethernet {device-count 16;}}
     #foreach ($HIERARCHYELEMENT in $HIERARCHY )
     $HIERARCHYELEMENT.get(0) {
     #set($HIERARCHYELEMENTSIZE = $HIERARCHYELEMENT.size() - 1)
     #foreach ($HIERARCHYELEMENTINDEX in [1..$HIERARCHYELEMENTSIZE] )
     $HIERARCHYELEMENT.get($HIERARCHYELEMENTINDEX){ 
    
     ## Set the tunnel services setting for the first PIC in FPC 0 
     #if($HIERARCHYELEMENTINDEX == 1 && $HIERARCHYELEMENT.get(0) == "FPC 0")
    
    tunnel-services {bandwidth 1g;}#endtraffic-manager {ingress-shaping-overhead 0;egress-shaping-overhead 0;mode ingress-and-egress;}}#end}#end}

    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

    chassis {redundancy {failover on-disk-failure;graceful-switchover;}aggregated-devices {ethernet {device-count 16;}}fpc 1 {pic 0 {tunnel-services {bandwidth 1g;}traffic-manager {ingress-shaping-overhead 0;egress-shaping-overhead 0;mode ingress-and-egress;}}pic 1 {traffic-manager {ingress-shaping-overhead 0;egress-shaping-overhead 0;mode ingress-and-egress;}}}fpc 2 {pic 0 {traffic-manager {ingress-shaping-overhead 0;egress-shaping-overhead 0;mode ingress-and-egress;}}pic 1 {traffic-manager {ingress-shaping-overhead 0;egress-shaping-overhead 0;mode ingress-and-egress;}}}}

    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

    interfaces {#if( $INTERFACENAME == 'ge-0/0/0')#terminate('Should not change description for ge-0/0/0 interfaces.')#{else}$INTERFACENAME {unit 0 {description "Similar desc";family ethernet-switching;}}#end}

    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

    protocols {oam {ethernet {link-fault-management {delete: interfaces ge-0/0/0;}}}}

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

    Modified: 2016-06-22