Skip to content

NSO-developer/yang-scan

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YANG scanner

Overview

This simple pyang plugin scans YANG modules for constructs that are likely to cause interoperability issues, especially when integrating with Cisco NSO. The constructs that it looks for are:

  • tailf:display-when used in a configuration node that refers operational nodes. Pyang checks this kind of reference for when or must statements, but not for this extension statement. Operational nodes are not part of the accessible data tree when checking references from configuration node, so such tailf:display-when statement would cause the parent node to be always hidden.

    Note that this check works only if you use a recent version of pyang, it is not supported with the version distributed with Cisco NSO.

    tag: XPATH_REF_CONFIG_FALSE

  • Duplicate prefixes. Two distinct YANG modules having the same prefix is not a YANG standard violation, but orchestration or configuration management systems may not be able to work with such modules.

    tag: SCAN_DUPLICATE_PREFIXES

  • tailf:hidden with any argument other than full. tailf:hidden full hides the node from all interfaces, other arguments cause the node to be hidden from interactive interfaces like CLI. This may cause interoperability issues, since some tools (like drned-xmnr) use them.

    tag: SCAN_HIDDEN

The plugin generates a warning for each occurrence of such construct. If needed, warnings can be turned off via --ignore-error.

Installation and running

This is a pyang plugin, so pyang must be available (e.g. via pip install pyang). With that, no installation is required, only clone the repository and use it like

$ pyang --plugindir /path/to/repo/yang_scan -f yang-scan /modules/*.yang

If convenient, you may install the plugin to your python environment though:

$ python setup.py install

and the argument --plugindir is not necessary then.

Installing the plugin from PyPI coming soon.

The plugin is always run through pyang, for running it please refer to its documentation or to pyang --help. Warnings generated by the plugin can be turned off using pyang's option --ignore-error <tag>, where tag is one of XPATH_REF_CONFIG_FALSE, SCAN_DUPLICATE_PREFIXES, or SCAN_HIDDEN. Note that ignoring XPATH_REF_CONFIG_FALSE turns off warnings for when and must statements too.