My Cheat on Yang-Explorer

Home

1 Yang Suite Overview

Yang Suite, formerly Yang Explorer is an open-source Yang Browser and RPC Builder Application developed/written by Cisco. It is a tool to let you experiment with Yand Data Models. From the github description:

It is based on Django. Django is a Python-based free and open-source web framework, which follows the model-template-view architectural pattern. It is maintained by the Django Software Foundation, an independent organization established as a 501 non-profit. Django's primary goal is to ease the creation of complex, database-driven websites.

Check out this 2022 blog: Cisco blog on Yang Suite

This youtube link also shows the above blog:

1.1 Features:

  • Upload / Compile yang models from User Interface Or Command Line
  • Build NetConf RPC
  • Generate Python example code [new]
  • Search yang xpaths [new]
  • Execute RPC against real netconf server
  • Save created RPCs to collections for later use
  • Build dependency graph for models
  • Browse data model tree and inspect yang properties

1.2 Requirements

Yang Suite uses python 3.6 and specific python modules so must be run in a python virtual enviroment. See Installation bellow.

It also does a decent job describing what one needs to set up a virtual environment, so a good example for somewhat looking to learn how to set up virtual environments.

1.3 Documentation and Installation Guides

A good place to start is in DevNet code repository on Yang Explorer

2 Yang Explorer Installation (personal)

2.1 Directory and Install Logs

My yang explorer is installed in ~/bin/yang-explorer: The install logs are in the same directory *.log

This folder is the root folder for the virtual enviroment as well.

2.2 Virtual Environement

yang-explorer needed python 2.7, but as of 2022 Yang Suite needs pytyon 3.6 Best to create a virtual environment with the modules you need. Or, simply use the docker image available from Cisco.

2.2.1 For older Yang Explorer

These steps are now obsoleted with Yang Suite. Included here though: A venv is created using virtualenv (so as to use a python 2.7 library) That has been done and is saved in /bin/yang-explorer/v

Under the root folder /bin/yang-explorer/v Activate script is ~~/bin/yang-explorer/v/bin/activatse.csh (for tcsh shells) otherwise the usual source ~~/bin/yang-explorer/v/bin/activate

Note, yang-explorer is installed and started/stopped using bash scripts. i.e. In this case bash ~/bin/yang-explorer/start.sh (Do I have to be in the virtual environment? No, as the script itself will activate the virutal environment for you. - read on)

Using this bash start script should be done as it checks that the database is initialzed, and then activates the virtual evironment using bash (not tcsh) and I am not sure if that matters or more accurately what I have to tweak to make sure using tcsh manually will work properly.

starth.sh then check whether pyang is properly installed.

Finally, the actual web server is run through the last command: "python manage.py runserver $HOST:$PORT"

3 Using Yang Explorer

3.1 Starting Yang Explorer Server

bash ~/bin/yang-explorer/start.sh

Finally stop using is as easy as running yang-halt.py and following instructions

When running start.sh, you should see this:

   
   /Users/zintis/bin/yang-explorer[5] % bash start.sh

Activating virtualenv ..
Starting YangExplorer server ..
Use http://localhost:8088/static/YangExplorer.html

Performing system checks...

System check identified no issues (0 silenced).
June 10, 2019 - 15:59:54
Django version 1.8.3, using settings 'server.settings'
Starting development server at http://localhost:8088/
Quit the server with CONTROL-C.
[10/Jun/2019 16:34:39]"GET /static/YangExplorer.html HTTP/1.1" 200 6730
[10/Jun/2019 16:34:39]"GET /static/history/history.css HTTP/1.1" 200 1209
[10/Jun/2019 16:34:39]"GET /static/history/history.js HTTP/1.1" 200 26166
[10/Jun/2019 16:34:39]"GET /static/swfobject.js HTTP/1.1" 200 10220
[10/Jun/2019 16:34:41] WARNING [django.request] Not Found: /favicon.ico
WARNING:django.request:Not Found: /favicon.ico
[10/Jun/2019 16:34:41]"GET /favicon.ico HTTP/1.1" 404 2546
[10/Jun/2019 16:34:47]"GET /static/YangExplorer.html HTTP/1.1" 304 0
[10/Jun/2019 16:34:48]"GET /static/YangExplorer000800.swf HTTP/1.1" 200 1468533
[10/Jun/2019 16:34:50]"GET /explorer/session HTTP/1.1" 200 97



3.2 Opening Chrome Browser to Yang-explorer:

Browse to http://$HOST:$PORT/static/YangExplorer.html using chrome In my case that was: http://localhost:8088/static/YangExplorer.html

Will have to login to the Yang-Explorer App from the browser (top right login) username:password is guest:guest or id you create as admin.

This login is needed because Yang-explorer uses user acvcounts to manage workspaces.

Yang-explorer-webpage.png

Figure 1: Navigating Yang-explorer Webpage

Once logged in as guest I can generate python code against a device with a defined Yang model, by opening a collection, populating the username password, device ip, port, etc, then clicking generate code (under Python) to get a sample code snippet that I fcan then downlaod and use (modify and run) in my own programs

3.3 Use Cases

3.3.1 Generate Python Code

3.4 Home