Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yang-lab

A small, pragmatic NETCONF / YANG toolkit for people who write and validate YANG models for a living.

What it does:

  • yang-lab validate <file.yang> — Runs pyang-based structural validation plus a layer of opinionated checks (naming, revision hygiene, bad-leaf-type patterns) you won't get from stock pyang.
  • yang-lab tree <file.yang> — Pretty-prints the data-node tree with type annotations. Useful for code review and onboarding.
  • yang-lab mock <file.yang> --port 8300 — Spins up a tiny mock NETCONF-over-TCP target that echoes a schema derived from your YANG model. Handy for exercising client code without standing up a device.

Built as a practical companion to the MIB/YANG work behind RFC 9742 (Syslog YANG), RFC 7420 (PCEP MIB), and RFC 6445 (MPLS-TE FRR MIB) — see my IETF datatracker profile.

Install

Requires Python 3.10+. Under the hood this uses pyang, which is the standard IETF-blessed validator.

git clone https://github.com/koushik331/yang-lab.git
cd yang-lab
pip install -e .

Quick demo

# Validate one of the bundled examples
yang-lab validate examples/acl-simple.yang

# Print the tree
yang-lab tree examples/acl-simple.yang

# Spin up the mock server on port 8300
yang-lab mock examples/syslog-mini.yang --port 8300

What's bundled in examples/

File What it is
acl-simple.yang Tiny ACL model in the spirit of RFC 8519, kept small for teaching.
syslog-mini.yang Trimmed slice of RFC 9742-style syslog configuration; good for testing mock NETCONF clients.

Both are original simplified models — not the official RFC YANG files. For the real standard models use YangModels/yang.

Opinionated checks yang-lab validate adds on top of pyang

  • Revision statements in reverse-chronological order.
  • leaf types use string with a pattern rather than bare string, where possible.
  • Groupings prefixed with grp- and typedefs with t- for source-scan grep-ability.
  • Module prefix is <= 8 chars.
  • No tailf: annotations in models intended for multi-vendor NSO NED work.

These mirror the "MIB police" style review I used to do at Cisco — a small set of rules that catches 80% of real authoring mistakes before the spec leaves your laptop.

Layout

src/yang_lab/
  cli.py         # Click-based CLI entrypoint
  validator.py   # pyang wrapper + opinionated checks
  tree.py        # Pretty-print tree view
  mock_server.py # Tiny TCP-based mock NETCONF target
examples/        # Sample YANG models
tests/           # pytest

License

MIT.

Who built this

Kiran Koushik Agrahara Sreenivasa — IETF RFC author/editor (9742, 7420, 7257, 6445); former Distinguished Engineer at Verizon; currently doing large-scale network modeling & simulation.

About

NETCONF/YANG toolkit: validator, tree viewer, mock server

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages