Getting started with YANG MODEL
In nutshell, YANG is a data modelling language, by which you can define the semantic and syntactic of your data file.
- pyang is a tool that helps to validate YANG model, as well as validate corresponding data file against its YANG model:
$ sudo apt install python-setuptools
$ git clone https://github.com/mbj4668/pyang
$ cd pyang
$ source env.sh
make sure all environment variables are set correctly
To start validate a very simple YANG model and its data file go to:
http://www.yang-central.org/twiki/bin/view/Main/DSDLMappingTutorial
Fortunately, this example is already exist in pyang/doc/tutorial, run this command while you are in this direcoty:
$ yang2dsdl -b aug-acme-system acme-system.yang extra-interface-nodes.yang
Then this command to verify that xml file is complied with the YANG model
$ yang2dsdl -s -b aug-acme-system -v aug-acme-system-data.xml
A simple example of YANG model would be: acme-system.yang file
module acme-system {
namespace "http://acme.example.com/system";
prefix "acme";
organization "ACME Inc.";
contact "joe@acme.example.com";
description
"The module for entities implementing the ACME system.";
revision 2007-11-05 {
description "Initial revision.";
}
container system {
leaf host-name {
type string;
description "Hostname for this system";
}
leaf-list domain-search {
type string;
description "List of domain names to search";
}
}
}
To validate it:
$ yang2dsdl acme-system.yang
and acme-system-data.xml is a sample file based on acme-system.yang model
<?xml version="1.0" encoding="utf-8"?>
<nc:data xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
<system xmlns="http://acme.example.com/system"
xmlns:ein="http://foo.example.com/basic-nodes">
<host-name>katz</host-name>
<domain-search>acme.example.com foo.example.com</domain-search>
</system>
</nc:data>
To check it against acme-system.yang
yang2dsdl -s -b acme-system -v acme-system-data.xml
MUD YANG model
https://github.com/YangModels/yang/tree/master/experimental/ietf-extracted-YANG-modules
MUD IETF draft
https://tools.ietf.org/html/draft-ietf-opsawg-mud-07
Hello, nc:data xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"> what represents nc here ?
ReplyDelete