Extended Syntax

The syntax in the YANG model is extended based on industry standards to describe more detailed service function attributes in the YANG model file.

The syntax is defined in huawei-extension.yang and is expressed in the format of ext: syntax name parameter.

Table 1 Extended syntax description

Syntax Name

Description

YANG Model Example

support-filter

For non-key leaf nodes under the list node, if the support-filter value is true, filtering is supported.

The support-filter value can be true or false.

If support-filter is not set for a node, the node does not support filtering.

leaf type {
type group4-type;
mandatory true;
ext:support-filter "true";
}

Model description: The type node supports filtering.

value-meaning

If one or more values of a leaf node have special meanings, the value-meaning syntax with item, meaning, and description parameters is added to describe the special meanings.

leaf protocol {
type uint8{
ext:value-meaning {
ext:item  "0" {
ext:meaning "IP";

Model description: The item value 0 of the protocol node indicates the IP protocol.

case-sensitivity

By default, the value of a string-type node is case-sensitive. If the value of a string-type node or its derivative node is case-sensitive under special restrictions, the case-sensitivity syntax is used to describe the special restrictions as follows:

  • lower-and-upper: The value is case-sensitive.
  • lower-or-upper: The value is case-sensitive. The device ignores the case when performing the repetition check.
  • lower-only: Only lowercase letters are supported.
  • upper-only: Only uppercase letters are supported.
  • lower2upper: The value is case-insensitive. When the configuration is delivered, the device automatically converts lowercase letters to uppercase letters for storage.
  • upper2lower: The value is case-insensitive. When the configuration is delivered, the device automatically converts uppercase letters to lowercase letters for storage.
leaf def {
type string {
length "1..63";
}
ext: case-sensitivity upper2lower;
}

Model description: The def node is case-insensitive. When delivering configurations through XML packets, the device saves uppercase letters as lowercase letters.

value-range

When a node uses id-range and its derivative types in huawei-pub-type.yang to define data types, this extended syntax can be used to describe the range of values that can be entered.

leaf dscp-value {
              when "not(../default='true')";
              type pub-type:id-range {
                ext:value-range "0..63";
              }

Model description: The value of dscp-value ranges from 0 to 63.

task-name

Each YANG module uses this syntax to describe the task to which the YANG module belongs. Users can use tasks to authenticate modules.

The value of task-name is a specific task name.

module huawei-aaa {
namespace "urn:huawei:yang:huawei-aaa";
prefix aaa;
...
ext:task-name "aaa";
container aaa {
...
}
}

Model description: The task name of the huawei-aaa module is aaa.

node-ref

This syntax defines a data node that is operated by the RPC node.

The syntax value is a specific XPath.

rpc clear-startup {
description
"Cancel the startup file settings. The current and next startup file settings will be empty.";
ext:node-ref "/cfg/cfg-files/cfg-file"

Model description: The object that is operated by the clear-startup node is /cfg/cfg-files/cfg-file.

dynamic-default

This syntax identifies a leaf node's default value that varies in different conditions.

This syntax can use default-value as a clause. The parameter specified for the syntax can be a specific value or expression. The clause of default-value can be:

  • when clause: describes the specific condition for the default value. For details, see the standard when syntax.
  • description clause: describes the scenario of default-value.

When multiple default values are available, the default values are matched from top to bottom. That is, when the first default value is matched, it is used, and no more values are matched against. If the default values in the other scenarios are the same, the last default-value can have no when clause, indicating other scenarios rather than the preceding scenarios.

leaf cost {
              type uint32 {
                range "1..65535";
              }
              ext:dynamic-default {
                ext:default-value "10" {
                  when "../slave-flag = 'false'";
                description
                  "The default value is 10 when slave-flag is false.";
                }
                ext:default-value "20" {
                  when "../slave-flag = 'true'";
                  description
                    "The default value is 20 when slave-flag is true.";
                }

Model description: When the when "../slave-flag = 'false'" condition is met, the default value of the leaf cost node is 10.

operation-exclude

This syntax describes the operations that are not supported, such as the create, update, or delete operation. The parameter value can be create, update, delete, or a combination of these operations.

The extended syntax's create, update, and delete capabilities correspond to the NETCONF operations.

  • operation-exclude create: indicates creation and corresponds to the following NETCONF operations:

    create/merge (when the node or the entire tree does not exist)/replace (when the node or the entire tree does not exist)

  • operation-exclude update: indicates update and corresponds to the following NETCONF operations:

    merge (change one value to another when the node or the entire tree exists)/replace (change one value to another when the node or the entire tree exists)

  • operation-exclude delete: indicates deletion and corresponds to the following NETCONF operations:

    delete/remove/replace (If a node or the entire tree exists but does not exist in the request packet, the node or the entire tree needs to be deleted.)

This syntax contains the following clauses:

  • when clause: describes the specific condition for the unsupported capability. For details, see the standard when syntax.
  • filter clause: indicates the filtering criterion for the unsupported capability.
  • description clause: describes the operation-exclude scenario in detail.
list aaa {
ext:operation-exclude create|delete {
ext:filter "name = '_public_'";
description "The instances whose name is '_public_' cannot be created, deleted.";
}

Model description: When the instance name of the aaa node is _public_, the node does not support the create and delete capabilities. If the instance name is otherwise specified, create and delete capabilities are supported.

generated-by

This syntax describes the list/leaf-list/presence container created when the system starts or based on the association with other configurations.

This syntax indicates both node creation when the conditions are met and deletion when the conditions are not met.

This syntax indicates only the list/leaf-list/presence container that is created. The value of each node in the list and presence container is not expressed.

The syntax value can be user or system. The default value is user.

The syntax contains the following clauses:

  • when clause: describes the specific condition for creating or deleting a list or presence container. For details, see the standard when syntax.
  • filter clause: describes the filtering criterion for creating or deleting a list or presence container.
  • description clause: describes the generated-by scenario in detail.
list af {
            key "type";
            description
              "Configure BGP address family instance. In public network instances, 
all types of address families can be configured. 
In IPv4 VPN instances, the IPv4 unicast, IPv4 flow, 
and IPv4 labeled unicast address families can be configured. In IPv6 VPN instances, the IPv6 unicast 
and IPv6 flow address families can be configured. 
The IPv4 address family in the BGP _public_ VPN
instance cannot be deleted.";
            ext:generated-by system {
              when "../../../../ni:name = '_public_'";
              ext:filter "type = 'ipv4uni'";
              description "The public instances is generated automatically when BGP is enabled.";
            }

Model description: When the when clause ../../../../ni:name = '_public_' is met, the system automatically creates a unicast address family of the ipv4uni type.

refine-ext

This syntax is used if the extended syntax operation-exclude and generated-by cannot be directly added under a node and needs to be added to other files in extended mode.

The clauses of this syntax can only be operation-exclude or generated-by.

ext:refine-ext "/ifm:ifm/ifm:interfaces/ifm:interface"{
ext:generated-by "system" {
description
"The interface is create by DCN.";
when "/dcn:dcn/dcn:site/dcn:enable = 'true'";
ext:filter "ifm:create-type = 1";
}
ext:operation-exclude "create|delete " {
description
"The interface is create by DCN, cannot be deleted. ";
when "/dcn:dcn/dcn:site/dcn:enable = 'true'";
ext:filter "ifm:create-type = 1 and ifm:type = 'Loopback'";
}
}

Model description: The extended syntax generated-by "system" and operation-exclude "create|delete" are added to the /ifm:ifm/ifm:interfaces/ifm:interface node.

deviation-ext

This syntax and its clauses can be used when you need to tailor the extended syntax defined on a node for different device models.

deviate-ext (an extended syntax) is a clause of deviation-ext. The parameter value is add, delete, or replace, indicating that the extended syntax needs to be added, deleted, or replaced for the XPath.

The clauses of deviate-ext are support-filter, case-sensitivity, node-ref, dynamic-default, operation-exclude, and generated-by.

ext:deviation-ext"/ifm:ifm/ifm:interfaces/ifm:interface"{
ext:deviate-ext add {
ext:generated-by "system" {
description
"The interface is create by DCN.";
when "/dcn:dcn/dcn:site/dcn:enable = 'true'";
ext:filter "ifm:create-type = 1";
}
}
}

Model description: The ext:generated-by "system" extended syntax needs to be added for the current device model when the /ifm:ifm/ifm:interfaces/ifm:interface node is tailored for different device models.

Copyright © Huawei Technologies Co., Ltd.
Copyright © Huawei Technologies Co., Ltd.
< Previous topic