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

    Using Wildcards with Configuration Groups

    You can use wildcards to identify names and allow one statement to provide data for a variety of statements. For example, grouping the configuration of the sonet-options statement over all SONET/SDH interfaces or the dead interval for OSPF over all Asynchronous Transfer Mode (ATM) interfaces simplifies configuration files and eases their maintenance.

    Using wildcards in normal configuration data is done in a style that is consistent with that used with traditional UNIX shell wildcards. In this style, you can use the following metacharacters:

    • Asterisk ( * )—Matches any string of characters.

    • Question mark ( ? )—Matches any single character.

    • Open bracket ( [ )—Introduces a character class.

    • Close bracket ( ]  )—Indicates the end of a character class. If the close bracket is missing, the open bracket matches a [ rather than introduce a character class.

    • A character class matches any of the characters between the square brackets. Within a configuration group, an interface name that includes a character class must be enclosed in quotation marks.

    • Hyphen ( - )—Specifies a range of characters.

    • Exclamation point ( ! )—The character class can be complemented by making an exclamation point the first character of the character class. To include a close bracket (]) in a character class, make it the first character listed (after the !, if any). To include a minus sign, make it the first or last character listed.

    Note: If used inside the groups hierarchy, an identifier name cannot start with < unless you are defining a wildcard statement, in which case the wildcard statement must have a closing >.

    Wildcarding in configuration groups follows the same rules, but < and > have a special meaning when used under the groups hierarchy. In the groups hierarchy, any term using a wildcard pattern must be enclosed in angle brackets <pattern> to differentiate it from other wildcarding in the configuration file.

    [edit]
    groups {
    sonet-default {
    interfaces {
    <so-*> {
    sonet-options {
    payload-scrambler;
    rfc-2615;
    }
    }
    }
    }
    }

    Wildcard expressions match (and provide configuration data for) existing statements in the configuration that match their expression only. In the previous example, the expression <so-*> passes its sonet-options statement to any interface that matches the expression so-*.

    The following example shows how to specify a range of interfaces:

    [edit]
    groups {
    gigabit-ethernet-interfaces {
    interfaces {
    "<ge-1/2/[5-8]>" {
    description "These interfaces reserved for Customer ABC";
    }
    }
    }
    }

    Angle brackets allow you to pass normal wildcarding through without modification. In any matching within the configuration, whether it is done with or without wildcards, the first item encountered in the configuration that matches is used. In the following example, data from the wildcarded BGP groups is inherited in the order in which the groups are listed. The preference value from <*a*> overrides the preference in <*b*>, just as the p value from <*c*> overrides the one from <*d*>. Data values from any of these groups override the data values from abcd.

    [edit]
    user@host# show
    groups {
    one {
    protocols {
    bgp {
    group <*a*> {
    preference 1;
    }
    group <*b*> {
    preference 2;
    }
    group <*c*> {
    out-delay 3;
    }
    group <*d*> {
    out-delay 4;
    }
    group abcd {
    preference 10;
    hold-time 10;
    out-delay 10;
    }
    }
    }
    }
    }
    protocols {
    bgp {
    group abcd {
    apply-groups one;
    }
    }
    }
    [edit]
    user@host# show | display inheritance
    protocols {
    bgp {
    group abcd {
    ##
    ## ’1’ was inherited from group ’one’
    ##
    preference 1;
    ##
    ## ’10’ was inherited from group ’one’
    ##
    hold-time 10;
    ##
    ## ’3’ was inherited from group ’one’
    ##
    out-delay 3;
    }
    }
    }

    Modified: 2018-06-20