Code Monkey home page Code Monkey logo

pyang-docker's Introduction

PYANG docker image

This repo contains the dockerfile to build an image with the PyYANG tool installed inside.

As well as the following plugins are included:

How to install

Pull the hellt/pyang image from GitHub container registry with docker pull ghcr.io/hellt/pyang.

To locally build the image, clone the repo and use docker build -t <your_repo>/<project>:<tag> -f <Dockerfile> . command.

Image tags

The repo contains two Dockerfiles, one is based on Alpine Linux and has a smaller size, the other one is based on PyPy and has faster execution time.

Starting from pyang 2.5.3, we tag with latest tag the PyPy image, and with alpine tag the Alpine Linux image.

Check available tags here - https://github.com/hellt/pyang-docker/pkgs/container/pyang/versions

Usage

hellt/pyang image expects you to mount a directory with YANG models (aka working directory) by the path /yang/. The following example demonstrates how to use the tools that are part of the PyYANG project with this configuration in mind:

# pyang tool example

# navigate to a dir with the YANG model(s) and run the container
# assuming the nokia-conf-combined.yang model is in the current directory
## create a tree representation of a yang model
docker run --rm -v $(pwd):/yang ghcr.io/hellt/pyang pyang -f tree nokia-conf-combined.yang

Along with pyang, the following tools are part of the image:

  • json2xml
  • pyang
  • yang2dsdl
  • yang2html

Additional enhancements

XML skeleton wrapper

To simplify the process of getting the XML skeleton for the data modelled in YANG and referenced by its model path the xmlsk.sh wrapper has been created. The sole purpose of this wrapper is to remove the prefix from the path string, since pyang's XML_SKELETON does not digest them.

With xmlsk.sh wrapper the workflow of getting the XML skeleton boils down to the following steps:

  1. Take a YANG module's M.yang jstree (HTML) representation and get the node path (P) from the column named Path. To make an example: /state:state/state:users/state:session/state:session-id;

  2. run the xmlsk.sh wrapper with the both the node path and the YANG module referenced as follows:

    # using the node path and the model from step 1
    docker run --rm -v $(pwd):/yang hellt/pyang xmlsk.sh "/state:state/state:users/state:session/state:session-id" nokia-state-combined.yang
  3. As a result, you will be presented with an XML skeleton that you can use in your subtree filters.

Under the hood, the following command is executed inside the container:

pyang -f sample-xml-skeleton --sample-xml-skeleton-path "/state/users/session/session-id" nokia-state-combined.yang

pyang-docker's People

Contributors

hellt avatar rski avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pyang-docker's Issues

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.