The YANG models in this repo define the object model for all of the components in the SONiC NAS host adapter.
Applications/scripts can use existing and build new models for behaviour on the system. Read the Application Programming Guide for more information on the CPS interfaces.
Generally each YANG model is contained in a YANG prefix. In this prefix are all of the classes, types, enums, etc are defined.
The YANG class parser go through each file and generate the following items:
- C/C++ headerfiles with all of the class names and attributes, enums, typedefs, etc
- C++ metadata files that are compiled to loadable models which are then available to cps enabled apps
- xml files with metadata that can be used by other languages for which loadable models are not suitable
NOTE: In the documentation, we describe how we map YANG classes and attributes to C/C++ headers.
Good question... There are two main packages created from this source repository. libsonic-model-dev - model header files libsonic-model1 - model meta data in compiled format
After installing the libsonic-model-dev, the header files will be stored in the /usr/include/sonic folder (unless you change the prefix).
The library metadata files will be stored in the usr/lib/x86_64-linux-gnu/ directory (assuming defualt debian 64-bit build)
You can see the metadata from Python using the cps.type API or the cps.info API or one of the many other python extension APIs.
To add a new model to the system, add a model file into the yang-model directory you need to:
- Create a new YANG model (extension should be .yang)
- Copy the YANG model into the yang-model directory
- Update the Makefile.in with the approprate model
- Run a build
Adding attributes and deleting attributes are as easy as modifying the model, and recompiling.
The history files need to be kept in sync with the YANG model - that history file provides upgradability between model changes.
For example, using a class from the dell-base-pas.yang model.
The model prefix is base-pas. The class we want to use in this example is "entity".
Therefor the key for the entity class (within the dell-base-pas.yang) is base-pas/entity
For example, lets say that an application needs to get the LAG interfaces via script (ignoring that the LAG can be queried through the Linux bonding commands). The interface class that holds the LAG information is in the the dell-base-if.yang file.
In this file, the class is actually an augment of the /if:interfaces/if:interface.
Prefix in the file is dell-base-if-cmn.
Since the mode is an augment, normally you would communicate using the key from the augmented object which is in this case if/interfaces/interface.
But looking at the details in the YANG model (decription) itself (in dell-base-if.yang), the documentation states that access to the class can be through the dell-base-if-cmn/if/interfaces/interface model.
Therefore from a CPS perspsective, you can use the key "dell-base-if-cmn/if/interfaces/interface".
But it also states that to do a query of lags, you need to specify the ietf interface type.
Therefore.. using the cps_get_oid.py script you would use: cps_get_oid.py target dell-base-if-cmn/if/interfaces/interface if/interfaces/interface/type=ianaift:ieee8023adLag
dell-base-platform-common.yang
dell-base-env-tempctl.yang
dell-base-media.yang
dell-base-pas.yang
dell-base-mgmt-interface.yang
ACL and QoS Config dell-base-acl.yang
Networking Interfaces
The following set of models provides the Networking Access related models/classes.
dell-base-if.yang
dell-base-if-lag.yang
dell-base-if-phy.yang
dell-base-if-vlan.yang
dell-base-if-mgmt.yang
dell-base-if-linux.yang
dell-base-qos.yang
dell-base-ip.yang
dell-base-routing.yang
dell-base-l2-mac.yang
dell-base-sflow.yang
dell-base-lag.yang
dell-base-statistics.yang
dell-base-stg.yang
dell-base-switch-element.yang
dell-base-mirror.yang
dell-base-vlan.yang
dell-base-packet.yang
dell-interface.yang
Please see the instructions in the sonic-nas-manifest repo for more details on the common build tools. Sonic-nas-manifest
Development Dependencies:
- sonic-logging
- sonic-common-utils
- sonic-object-library
Package Dependencies: libsonic-logging1 libsonic-logging-dev libsonic-common1 libsonic-common-dev libsonic-object-library1 libsonic-object-library-dev sonic-yang-utils
BUILD CMD: sonic_build libsonic-logging1 libsonic-logging-dev libsonic-common1 libsonic-common-dev libsonic-object-library1 libsonic-object-library-dev sonic-yang-utils-dev -- clean binary