Defining Abstract YANG Data

YANG can be used to define abstract data that can be used within server SIL callbacks and system callbacks. This sort of data is commonly used to read/write files containing YANG data or protocol messages defined in YANG.

This functionality replaces the deprecated ncx:abstract extension, because it is based on standards. There are 4 YANG extensions available that can be used to define abstract data structures in YANG modules.

Extension

Source

Module

Description

sx:structure

RFC 8791

ietf-yang-structure-ext.yang

Define a YANG data structure (current)

sx:augment-structure

RFC 8791

ietf-yang-structure-ext.yang

Augment a YANG data structure (current)

rc:yang-data

RFC 8040

ietf-restconf.yang

Define a YANG data structure (deprecated)

yd:augment-yang-data

none

yang-data-ext.yang

Augment a YANG data structure (deprecated)

sx:structure

The YANG Data Structures (RFC 8791) includes this YANG extension definition. It is not the same as the RESTCONF version.

The structure name defines the abstract YANG container.
There is no restriction on the child data nodes.

The following example shows how the abstract container test1 would be created with this extension:

module foo {
   // header
   import ietf-yang-structure-ext { prefix sx; }

   sx:structure test1 {
      leaf leaf1 { type string; }
      leaf leaf2 { type int32; }
   }
}

sx:augment-structure

The YANG Data Structures (RFC 8791) includes this YANG extension definition. It is not the same as the YumaPro version.

The structure name defines the abstract YANG container.
The first node in the augment path is the structure name.

The following example shows how the abstract container test1 would be augmented with this extension:

module bar {
   // header
   import ietf-yang-structure-ext { prefix sx; }
   import foo { prefix f; }

   sx:augment-structure "/f:test1"  {
      leaf leaf3 { type uint32; }
      leaf leaf4 { type boolean; }
   }
}

rc:yang-data

The RESTCONF Protocol (RFC 8040) includes the YANG extension definition for yang-data. It is used within ietf-restconf.yang and ietf-yang-patch.yang. Any module can define YANG data structures;

Restrictions:

  • YANG does not allow multiple top-level nodes with the same name to be defined in the same module.

    Make sure that the top-level nodes defined within the yang-data statement do not conflict with other top-level object names.

  • The data defined within the yang-data statement must be 1 container statement or 1 uses statement where the grouping contains one container.

Note

This extension is deprecated. Use sx:structure instead.

module foo {
   // header
   import ietf-restconf { prefix rc; }

   rc:yang-data test1 {
      container test1 {
        leaf leaf1 { type string; }
        leaf leaf2 { type int32; }
      }
   }
}

yd:augment-yang-data

The yang-data-ext.yang module defines a YANG extension to allow yang-data nodes to be augmented from a different module.

  • This is not supported by the RESTCONF standard, just supported in netconfd-pro.

  • The plain augment statement can be used instead of this extension, but this should be avoided because a standard YANG compiler is not required to support the RESTCONF yang-data extension (so it will not find the augmented node)

Note

This extension is deprecated. Use sx:augment-structure instead.

module bar {
   // header
   import yang-data-ext { prefix yd; }
   import foo { prefix f; }

   yd:augment-yang-data /f:test1 {
      leaf test2 { type string; }
   }
}