Giter VIP home page Giter VIP logo

yangpath's Introduction

github release Github all releases Go Report Doc build


yangpath is an XPATH/RESTCONF-styled schema paths exporter with superpowers.

The exported paths can be immediately used in your NETCONF/RESTCONF or gNMI applications.

Documentation available at https://yangpath.netdevops.me

XPATH paths

$ yangpath export --yang-dir ~/openconfig/public/ \
                    --module ~/openconfig/public/release/models/interfaces/openconfig-interfaces.yang
[rw]  /interfaces/interface[name=*]/config/description  string
[rw]  /interfaces/interface[name=*]/config/enabled  boolean
[rw]  /interfaces/interface[name=*]/config/loopback-mode  boolean
[rw]  /interfaces/interface[name=*]/config/mtu  uint16
[rw]  /interfaces/interface[name=*]/config/name  string
[rw]  /interfaces/interface[name=*]/config/type  identityref->ietf-if:interface-type
<SNIPPED>

RESTCONF paths

$ yangpath export --yang-dir ~/openconfig/public/ \
                    --module ~/openconfig/public/release/models/interfaces/openconfig-interfaces.yang
                    --style restconf
[rw]  /interfaces/interface=name/config/description  string
[rw]  /interfaces/interface=name/config/enabled  boolean
[rw]  /interfaces/interface=name/config/loopback-mode  boolean
[rw]  /interfaces/interface=name/config/mtu  uint16
[rw]  /interfaces/interface=name/config/name  string
[rw]  /interfaces/interface=name/config/type  identityref->ietf-if:interface-type

Features

  • Preserved list keys
    The exported paths have the list keys present.
    Knowing the key names makes it very easy to create XPATH/RESTCONF filters targeting a particular node.
  • Readily available for gNMI
    The exported paths are fully compatible with the gNMI paths, thanks to the keys being present and set to the wildcard * value.
  • RESTCONF-ready
    With a matter of a single flag value switch yangpath will export the paths in a RESTCONF style. Paste them in Postman and you're good to go!
  • Type information
    A unique yangpath feature is its ability to provide the type of a given path. Types give additional context when you retrieve the data, but they are of utter importance for edit the configuration operations.
  • Fast
    Path export with yangpath is quite fast, working with massive models is no longer a problem!
  • User friendly
    As always, we strive to publish the tools which spark joy, therefore pre-built images with an effortless installation and a beautiful and extensive documentation comes included.

Quick Start

Install

Use the following installation script to install the latest version.

sudo curl -sL https://github.com/hellt/yangpath/raw/master/install.sh | sudo bash

Alternatively, leverage the system packages or docker images.

Export paths

To export the paths from a given module:

# assuming cur working dir is the root of openconfig repo
yangpath export -m release/models/interfaces/openconfig-interfaces.yang

Generate HTML path browser

To create HTML with paths out of template, leverage templating capabilities of yangpath.

yangpath's People

Contributors

hellt avatar karimra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

alipatt

yangpath's Issues

check `augment` support in a module

Its been discovered that if a module augments another one, then goyang doesn't export path from it.
Check with goyang if augmentation works and in what scenarios

add colors for key elements

To make schema path keys more visible the proposal is to style them with an accent color.
A flag --no-color should be added to disable the colors

support for --ignore-errors

tx for the good work on this Roman. Can i ask to have an option added to ignore errors pls?

Specific issue at hand: working with some YANG 1.1 models that have a 'default' statement. Right now yangpath reports a fatal error as goyang is YANG 1.0 only. Given it's 'default' statement only, it would be good to be able to ignore and still be able to browse the rest of the model.

implement nil pointer check for nokia submodules

yangpath export -m nokia-conf-router-bgp.yang

panic: runtime error: invalid memory address or nil pointer dereference

[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x510a78]

goroutine 1 [running]:
github.com/openconfig/goyang/pkg/yang.ToEntry(0xa2bce0, 0xc00031a000, 0xc0000a2300)
        /home/runner/go/pkg/mod/github.com/openconfig/[email protected]/pkg/yang/entry.go:699 +0x33d8
github.com/openconfig/goyang/pkg/yang.(*Modules).Process(0xc0000e9350, 0xc0000e9380, 0xc000115cd0, 0x0)
        /home/runner/go/pkg/mod/github.com/openconfig/[email protected]/pkg/yang/modules.go:332 +0x3a6
github.com/hellt/yangpath/cmd.glob..func1(0xd5d4c0, 0xc0000cd060, 0x0, 0x2, 0x0, 0x0)
        /home/runner/work/yangpath/yangpath/cmd/export.go:51 +0x30c
github.com/spf13/cobra.(*Command).execute(0xd5d4c0, 0xc0000cd040, 0x2, 0x2, 0xd5d4c0, 0xc0000cd040)
        /home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:842 +0x460
github.com/spf13/cobra.(*Command).ExecuteC(0xd5d760, 0x43b3aa, 0xd22100, 0xc00004c750)
        /home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:950 +0x349
github.com/spf13/cobra.(*Command).Execute(...)
        /home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:887
github.com/hellt/yangpath/cmd.Execute()
        /home/runner/work/yangpath/yangpath/cmd/root.go:33 +0x31
main.main()
        /home/runner/work/yangpath/yangpath/main.go:20 +0x20

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.