ietf-ccamp-wg / transport-nbi

Transport NBI Design Team Discussion
3 stars 7 forks source link

Open Source Tools For Network Management #54

Closed italobusi closed 3 years ago

italobusi commented 5 years ago

An overview of some open-source tools has been provided during IETF 103 RTGWG meeting:

https://datatracker.ietf.org/meeting/103/materials/slides-103-rtgwg-sessa-open-source-tools-for-network-management-01

It woudl be worthwhile checking whether there are tools which may be useful for the DT work

For example, the presentation mentions a Libyang tool which “allows you to load and validate the YANG schemas and data”

Based on discussion in Prague, this could be spun out into a new effort: https://github.com/danielkinguk/transport-nbi/blob/master/Meetings/2019-03-23-29-IETF104/minutes-transport-nbi-dt-2019-03-27-ietf104.md

GianmarcoBruno commented 5 years ago

Here is a quick comparison between pyang 1.7.1 and libyang (yanglint 0.16.94). Comparison may be a bit unfair as the first dates back to April 2016 and the second to about September 2018.

Approach & Language

Pyang is a python library having at its core XML transformations to perform validations. It provides a set of commands to be called from shell or from scripts as we do. Libyang is written in C and it is exposed in two ways:

Experiments

So far I have built libyang from source and played with it. No binary seems available but installation goes smooth. You may need to install some development libraries if not already present in your environment. I successfully validated some toy models and documents produced in the transport NBI DT, i.e.: https://github.com/GianmarcoBruno/json-yang/tree/master/tests/dishwasher and https://github.com/GianmarcoBruno/transport-nbi-backoffice/tree/master/use-case-1-topology-data

I tested intentionally well- and badly-formed documents with the same outcomes so far from the two tools. Error messages from libyang are slightly more helpful to the user than those from pyang.

Libyang appears very much faster than pyang and this is consistent with the approach of using compiled code from C instead of python/XSLT.

Libyang, when used as yanglint, can be used in non-interactive mode just by piping a script. For example to validate the an OTN topology model prepare a file "script" like this:

add -i ietf-otn-topology@2017-10-30.yang
data mpi1-otn-topology.json

and then execute it like: cat script | path-to/yanglint

I haven’t still found a way to validate sub-tree or individual leaves - neither NETCONF nor RESTCONF messages. It seems that libyang only deals with documents representing the full datastore as pyang does. libyang seems to deal with features.

further work

GianmarcoBruno commented 5 years ago

Another note about pyang vs libyang

libyang validation of models is apparently stricter than pyang.

pyang --ietf ietf-eth-te-topology@2017-09-12.yang detects only dates mismatch: warning: unexpected latest revision "2018-03-01" in ietf-eth-te-topology@2017-09-12.yang, should be 2017-09-12

libyang validation detects date mismatch and two semantic validation: libyang[1]: Schema node "eth-tran-topology" not found (../../../ietf-network:network-types/ietf-te-topology:te-topology/eth-tran-topology) with context node "/ietf-network:networks/ietf-network:network/ietf-network-topology:link/te/te-link-attributes". libyang[1]: Schema node "eth-tran-topology" not found (../../ietf-network:network-types/ietf-te-topology:te-topology/eth-tran-topology) with context node "/ietf-network:networks/ietf-network:network/ietf-network:node/termination-point". libyang[1]: File name "ietf-eth-te-topology@2017-09-12.yang" does not match module revision "2018-03-01".

Still to be clearly understood whether these warnings are proper or due to my imprecise use of libpyang.

italobusi commented 5 years ago

Discussed during the DT call on January 16, 2019:

https://github.com/danielkinguk/transport-nbi/tree/master/Meetings/2019-01-16

Actions (Gianmarco):

Action (Italo):

italobusi commented 5 years ago

DT call on February 22, 2019:

Gianmarco has checked that libyang validates the JSON code taking the features into account while pyang assumes that all the features are supported

In order to use yanglint on Windows, Gianmarco has prepared a version which compile it within a Docker container:

https://github.com/GianmarcoBruno/docker-yanglint

A Docket container can be installed on Windows 10 using [Docker Desktop (https://www.docker.com/products/docker-desktop)]

Action (Italo/Sergio):