NSO hello world using Restconf

Simple hello world in NSO using Restconf.

The script prints the status of the NCS deamon and the NCS version. Validates the deamon is in "started" state. If the deamon is not in "started" status, the script will raise an exception.

This script can be useful to monitor continously the status of NSO.

For real use, consider using environment variables rather than hardcoding credentials for your NSO instance.

For demo purposes, the script connects to the NSO always-On sandbox, so you can test it right away.

Below are the restconf paths used to get the data.

/restconf/data/tailf-ncs-monitoring:ncs-state/daemon-status
/restconf/data/tailf-ncs-monitoring:ncs-state/version

How to use it

Install dependencies

pip install -r requirements.txt

To run the script do:

python hello_world.py

Output printed

❯ python hello_world.py

NSO version: 5.4.3.3
NSO daemon running. Status: STARTED
❯
View code on GitHub

Code Exchange Community

Get help, share code, and collaborate with other developers in the Code Exchange community.View Community
Disclaimer:
Cisco provides Code Exchange for convenience and informational purposes only, with no support of any kind. This page contains information and links from third-party websites that are governed by their own separate terms. Reference to a project or contributor on this page does not imply any affiliation with or endorsement by Cisco.