### Build and Start Example for Manual Setup Source: https://github.com/nso-developer/nso-gitbook/blob/main/administration/advanced-topics/layered-service-architecture.md Builds and starts the example for manual setup, then enters the NSO CLI. ```bash $ make clean manual $ make start-manual $ make cli-upper-nso ``` -------------------------------- ### Build and Start NSO Example Source: https://github.com/nso-developer/nso-gitbook/blob/main/administration/management/ned-administration.md Command to build the NSO example project and start the NSO environment after adding necessary NED packages. ```bash make all start ``` -------------------------------- ### Example: Standard Local Install Output Source: https://github.com/nso-developer/nso-gitbook/blob/main/administration/installation-and-deployment/local-install.md This is an example output from a standard local NSO installation, showing the steps and information logged during the process. ```bash sh nso-6.0.darwin.x86_64.installer.bin --local-install ~/nso-6.0 # Output INFO Using temporary directory /var/folders/90/n5sbctr922336_ 0jrzhb54400000gn/T//ncs_installer.93831 to stage NCS installation bundle INFO Unpacked ncs-6.0 in /Users/user/nso-6.0 INFO Found and unpacked corresponding DOCUMENTATION_PACKAGE INFO Found and unpacked corresponding EXAMPLE_PACKAGE INFO Found and unpacked corresponding JAVA_PACKAGE INFO Generating default SSH hostkey (this may take some time) INFO SSH hostkey generated INFO Environment set-up generated in /Users/user/nso-6.0/ncsrc INFO NSO installation script finished INFO Found and unpacked corresponding NETSIM_PACKAGE INFO NCS installation complete ``` -------------------------------- ### Build and Start the Generic XML-RPC NED Example Source: https://github.com/nso-developer/nso-gitbook/blob/main/development/advanced-development/developing-neds/generic-ned-development.md Compile and start the example NED. This typically involves building the necessary components and launching the NSO environment. ```bash $ make all start ``` -------------------------------- ### Quick Start: Setting up Python Virtual Environment for NSO Package Source: https://github.com/nso-developer/nso-gitbook/blob/main/development/core-concepts/nso-virtual-machines/nso-python-vm.md This bash script demonstrates the quick setup for a Python virtual environment for an NSO package. It creates a virtual environment, installs dependencies from requirements.txt, and configures the package to use the virtual environment. ```bash cd $NCS_RUN_DIR # Or to the project run-time directory python3 -m venv ./pyvenv ./pyvenv/bin/pip install -r packages//python/requirements.txt echo "./pyvenv" > packages//python/use_venv ``` -------------------------------- ### Building and Running an Example Package Source: https://github.com/nso-developer/nso-gitbook/blob/main/development/advanced-development/developing-packages.md Shows the steps to build an example package, start the network simulation, and connect to the NSO CLI to verify device status and configuration. ```bash $ cd $NCS_DIR/examples.ncs/service-management/mpls-vpn-java $ make all .... $ ncs-netsim start ..... $ ncs $ ncs_cli -u admin ``` -------------------------------- ### Navigate and List Packages in Local Install Source: https://github.com/nso-developer/nso-gitbook/blob/main/administration/management/package-mgmt.md Demonstrates navigating to the NSO example directory and listing the contents of the packages directory to verify package installation. ```bash $ pwd examples.ncs/device-management/simulated-devices $ NONINTERACTIVE=1 ./demo.sh $ ls packages/ cisco-ios-netsim-cli-1.0 $ ls packages/cisco-ios-netsim-cli-1.0 doc load-dir netsim package-meta-data.xml private-jar shared-jar src ``` -------------------------------- ### Run CdbCfgSubscriber Example Source: https://github.com/nso-developer/nso-gitbook/blob/main/development/core-concepts/using-cdb.md This example demonstrates the build and run process for the CdbCfgSubscriber, including starting NSO, configuring devices, and committing changes. ```bash $ make clean all $ ncs-netsim start DEVICE ex0 OK STARTED DEVICE ex1 OK STARTED DEVICE ex2 OK STARTED $ ncs $ ncs_cli -u admin admin@ncs# devices sync-from suppress-positive-result admin@ncs# config admin@ncs(config)# no devices device ex* config r:sys interfaces admin@ncs(config)# devices device ex0 config r:sys interfaces \ > interface en0 mac 3c:07:54:71:13:09 mtu 1500 duplex half unit 0 family inet \ > address 192.168.1.115 broadcast 192.168.1.255 prefix-length 32 admin@ncs(config-address-192.168.1.115)# commit Commit complete. admin@ncs(config-address-192.168.1.115)# top admin@ncs(config)# exit ``` -------------------------------- ### CLI Command Info Example Source: https://github.com/nso-developer/nso-gitbook/blob/main/resources/man/clispec.5.md Example of a 'start' command with its descriptive 'info' element, shown in CLI autocompletion. ```xml Start displaying the system log or trace a file ... ``` -------------------------------- ### Start NSO as System Install Source: https://github.com/nso-developer/nso-gitbook/blob/main/administration/installation-and-deployment/post-install-actions/migrate-to-system-install.md Use these commands to stop the local NSO instance, set up the environment, navigate to the run directory, and start NSO as a system service. ```bash $ sudo systemctl stop ncs $ source $HOME/ncs-VERSION/ncsrc $ cd $HOME/ncs-run $ ncs ``` -------------------------------- ### Plain Subscriber Startup Commands Source: https://github.com/nso-developer/nso-gitbook/blob/main/development/core-concepts/using-cdb.md Compile and start the NSO Java example application. This involves using `make` to build the project and then starting the NSO netconf simulator and the NSO core. ```bash $ make clean all $ ncs-netsim start DEVICE ex0 OK STARTED DEVICE ex1 OK STARTED DEVICE ex2 OK STARTED $ ncs ``` -------------------------------- ### Setup NSO Directories and Populate Device Info Source: https://github.com/nso-developer/nso-gitbook/blob/main/operation-and-usage/operations/basic-operations.md Use this command to prepare directories for NSO and load information about simulated devices. Ensure you are in the correct example directory. ```bash $ ncs-setup --netsim-dir ./netsim --dest . ``` -------------------------------- ### Start NSO System Install Source: https://github.com/nso-developer/nso-gitbook/blob/main/administration/installation-and-deployment/post-install-actions/migrate-to-system-install.md Execute the NSO installer script with the --system-install flag to initiate the system installation process. Replace VERSION.OS.ARCH with your specific NSO version, operating system, and architecture. ```bash $ sh nso-VERSION.OS.ARCH.installer.bin --system-install ``` -------------------------------- ### Example: Netsim Project Metadata Source: https://github.com/nso-developer/nso-gitbook/blob/main/development/advanced-development/developing-packages.md Specify netsim devices within `project-meta-data.xml` to automatically generate NSO setup commands in the `setup.mk` file. ```xml cisco-ios ce 2 ``` -------------------------------- ### Run NSO with Different Installation/Example Directories Source: https://github.com/nso-developer/nso-gitbook/blob/main/administration/installation-and-deployment/local-install.md Demonstrates running NSO from one installation directory while using examples and configurations from another. This highlights the self-contained nature of the runtime directory. ```bash $ cd path/to/nso-6.4 $ . ncsrc $ cd path/to/nso-6.4.1/examples.ncs/service-management/datacenter-qinq $ ncs ``` -------------------------------- ### Full Demo Script for netsim-sshkey Example Source: https://github.com/nso-developer/nso-gitbook/blob/main/administration/installation-and-deployment/containerized-nso.md A comprehensive bash script that automates the entire process of setting up, building, and running the netsim-sshkey example with NSO using Docker Compose. It includes resetting containers, starting services, compiling packages, and showcasing the example. ```bash #!/bin/bash set -eu # Abort the script if a command returns with a non-zero exit code or if # a variable name is dereferenced when the variable hasn't been set GREEN='\033[0;32m' PURPLE='\033[0;35m' NC='\033[0m' # No Color printf "${GREEN}##### Reset the container setup ${NC}" docker compose --profile build down docker compose --profile example down -v docker compose --profile prod down -v rm -rf ./packages/NSO-1/* ./log/NSO-1/* printf "${GREEN}##### Start the build container used for building the NSO NED and service packages ${NC}" docker compose --profile build up -d printf "${GREEN}##### Get the packages ${NC}" printf "${PURPLE}##### NOTE: Normally you populate the package directory from the host. Here, we use packages from an NSO example ${NC}" docker exec -it build-nso-pkgs sh -c 'cp -r ${NCS_DIR}/examples.ncs/getting-started/netsim-sshkey/packages ${NCS_RUN_DIR}' printf "${GREEN}##### Build the packages ${NC}" docker exec -it build-nso-pkgs sh -c 'for f in ${NCS_RUN_DIR}/packages/*/src; do make -C "$f" all || exit 1; done' printf "${GREEN}##### Start the simulated device container and setup the example ${NC}" docker compose --profile example up --wait printf "${GREEN}##### Start the NSO prod container ${NC}" docker compose --profile prod up --wait printf "${GREEN}##### Showcase the netsim-sshkey example from NSO on the prod container ${NC}" if [[ $# -eq 0 ]] ; then # Ask for input only if no argument was passed to this script printf "${PURPLE}##### Press any key to continue or ctrl-c to exit ${NC}" read -n 1 -s -r fi docker exec -it nso1 sh -c 'sed -i.orig -e "s/make/#make/" ${NCS_DIR}/examples.ncs/getting-started/netsim-sshkey/showcase.sh' docker exec -it nso1 sh -c 'cd ${NCS_RUN_DIR}; ${NCS_DIR}/examples.ncs/getting-started/netsim-sshkey/showcase.sh 1' ``` -------------------------------- ### Start Netsim Container with Docker Compose Source: https://github.com/nso-developer/nso-gitbook/blob/main/administration/installation-and-deployment/containerized-nso.md Starts the netsim container using Docker Compose with the 'example' profile. This container generates configuration files for the NSO Production container. The --wait flag ensures the container is healthy before proceeding. ```bash docker compose --profile example up --wait ``` -------------------------------- ### Example: NSO Project Update Command Source: https://github.com/nso-developer/nso-gitbook/blob/main/development/advanced-development/developing-packages.md Execute the `ncs-project update` command to install packages and generate project setup files. Use the `-v` flag for verbose output. ```bash $ ncs-project update -v ncs-project: installing packages... ncs-project: found local installation of "mypack" ncs-project: unpacked tar file: /tmp/ncs-4.1.2-cisco-ios-4.1.5.tar.gz ncs-project: git clone "ssh://git@my-repo.com/foo.git" "/home/developer/dev/test_project/packages/cisco-ios" ncs-project: git checkout -q "stable" ncs-project: installing packages...ok ncs-project: resolving package dependencies... ncs-project: resolving package dependencies...ok ncs-project: determining build order... ncs-project: determining build order...ok ncs-project: determining ncs-min-version... ncs-project: determining ncs-min-version...ok The file 'setup.mk' will be overwritten, Continue (y/n)? ``` -------------------------------- ### Navigate to Example Directory Source: https://github.com/nso-developer/nso-gitbook/blob/main/development/introduction-to-automation/actions.md Change directory to the router-network example to set up simulated devices. ```bash $ cd $NCS_DIR/examples.ncs/device-management/router-network ``` -------------------------------- ### Build Nano Services Example Source: https://github.com/nso-developer/nso-gitbook/blob/main/development/core-concepts/nano-services.md Builds the nano services example. Navigate to the example directory and run 'make all'. ```bash $ cd examples.ncs/nano-services/link-migration $ make all ``` -------------------------------- ### System Installation Crypto Keys File Source: https://github.com/nso-developer/nso-gitbook/blob/main/administration/advanced-topics/cryptographic-keys.md Example content for the ncs.crypto_keys file used by the external command for system installations. Do not reuse these example keys. ```text AESCFB128_KEY=40f7c3b5222c1458be3411cdc0899fg AES256CFB128_KEY=5a08b6d78b1ce768c67e13e76f88d8af7f3d925ce5bfedf7e3169de6270bb6eg ``` -------------------------------- ### Navigate to Example Directory Source: https://github.com/nso-developer/nso-gitbook/blob/main/administration/installation-and-deployment/post-install-actions/running-nso-examples.md Change directory to the specific example you want to run. Ensure you are in the correct example's root directory. ```bash $ cd $NCS_DIR/examples.ncs/device-management/simulated-devices ``` -------------------------------- ### setup Source: https://github.com/nso-developer/nso-gitbook/blob/main/developer-reference/pyapi/ncs.application.md The setup() method should be implemented to register service- and action callbacks. This method is called by NCS when the package is loaded. ```APIDOC ## setup Method: ```python setup(self) ``` The setup() method should be implemented to register service- and action callbacks. This method is called by NCS when the package is loaded. ``` -------------------------------- ### Start NSO using systemd Source: https://github.com/nso-developer/nso-gitbook/blob/main/administration/management/system-management/README.md Starts the NSO service using systemd, which is common in System Install configurations. ```bash # systemctl nso start ``` -------------------------------- ### Running the DNS Service Demo Source: https://github.com/nso-developer/nso-gitbook/blob/main/development/core-concepts/implementing-services.md Navigate to the example directory and run the 'make demo' command to execute the DNS service example. ```bash $ cd $NCS_DIR/examples.ncs/service-management/implement-a-service/dns-v2.1 $ make demo ``` -------------------------------- ### Start Transaction RPC Request and Response Source: https://github.com/nso-developer/nso-gitbook/blob/main/development/core-concepts/northbound-apis/nso-netconf-server.md An example of the NETCONF RPC request to start a transaction and its successful response. ```xml ``` -------------------------------- ### Build and Copy Initial Configuration Source: https://github.com/nso-developer/nso-gitbook/blob/main/development/introduction-to-automation/actions.md Execute the make all command to build the example and copy the NSO CDB initialization file. ```bash $ make all $ cp ncs-cdb/ncs_init.xml $NSO_RUNDIR/ncs-cdb/ ``` -------------------------------- ### Start NSO Server Source: https://github.com/nso-developer/nso-gitbook/blob/main/administration/installation-and-deployment/system-install.md Commands to reload the systemd daemon and start the NSO service. This is typically done after a system installation. ```bash # systemctl daemon-reload # systemctl start ncs ``` -------------------------------- ### Setting and Getting C_DATETIME Source: https://github.com/nso-developer/nso-gitbook/blob/main/resources/man/confd_types.3.md Example of setting and getting a C_DATETIME value. The application is responsible for transforming the struct into UNIX-friendly formats. ```c #include confd_value_t myval; struct confd_datetime dt; struct tm *tm = localtime(time(NULL)); dt.year = tm->tm_year + 1900; dt.month = tm->tm_mon + 1; dt.day = tm->tm_mday; dt->hour = tm->tm_hour; dt.min = tm->tm_min; dt->sec = tm->tm_sec; dt.micro = 0; dt.timezone = CONFD_TIMEZONE_UNDEF; CONFD_SET_DATETIME(&myval, dt); dt = CONFD_GET_DATETIME(&myval); ``` -------------------------------- ### Setting and Getting C_DOUBLE Values Source: https://github.com/nso-developer/nso-gitbook/blob/main/resources/man/confd_types.3.md Example of setting and getting a double-precision floating-point number using the C_DOUBLE type and ConfD API macros. ```c double d; confd_value_t myval; CONFD_SET_DOUBLE(&myval, 3.14); d = CONFD_GET_DOUBLE(&myval); ``` -------------------------------- ### Setting and Getting C_UINT64 Values Source: https://github.com/nso-developer/nso-gitbook/blob/main/resources/man/confd_types.3.md Example of setting and getting an unsigned 64-bit integer using the C_UINT64 type and ConfD API macros. ```c uint64_t ival; confd_value_t myval; CONFD_SET_UINT64(&myval, 32); ival = CONFD_GET_UINT64(&myval); ``` -------------------------------- ### Setting and Getting C_UINT32 Values Source: https://github.com/nso-developer/nso-gitbook/blob/main/resources/man/confd_types.3.md Example of setting and getting an unsigned 32-bit integer using the C_UINT32 type and ConfD API macros. ```c uint32_t ival; confd_value_t myval; CONFD_SET_UINT32(&myval, 77732); ival = CONFD_GET_UINT32(&myval); ``` -------------------------------- ### Setting and Getting C_UINT16 Values Source: https://github.com/nso-developer/nso-gitbook/blob/main/resources/man/confd_types.3.md Example of setting and getting an unsigned 16-bit integer using the C_UINT16 type and ConfD API macros. ```c uint16_t ival; confd_value_t myval; CONFD_SET_UINT16(&myval, 3277); ival = CONFD_GET_UINT16(&myval); ``` -------------------------------- ### Run perf-trans Example with One Transaction per Device Source: https://github.com/nso-developer/nso-gitbook/blob/main/development/advanced-development/scaling-and-performance-optimization.md Execute the `perf-trans` example, dividing service creation and validation into separate transactions for each device. This allows work to be spread across multiple CPU cores. Ensure you are in the example's directory and have set up the environment. ```bash cd $NCS_DIR/examples.ncs/scaling-performance/perf-trans make stop clean NDEVS=2 python python3 measure.py --ntrans 2 --nwork 1 --ndtrans 1 --cqparam bypass --ddelay 1 python3 ../common/simple_progress_trace_viewer.py $(ls logs/*.csv) ``` -------------------------------- ### Start Simulated Network Source: https://github.com/nso-developer/nso-gitbook/blob/main/operation-and-usage/operations/managing-network-services.md Use this command to set up the environment and start the simulated network nodes. ```bash Copy$ ``` -------------------------------- ### Setting and Getting C_UINT8 Values Source: https://github.com/nso-developer/nso-gitbook/blob/main/resources/man/confd_types.3.md Example of setting and getting an unsigned 8-bit integer using the C_UINT8 type and ConfD API macros. ```c uint8_t ival; confd_value_t myval; CONFD_SET_UINT8(&myval, 32); ival = CONFD_GET_UINT8(&myval); ``` -------------------------------- ### Initial Device Setup and Auto-configuration Commit Source: https://github.com/nso-developer/nso-gitbook/blob/main/operation-and-usage/operations/nso-device-manager.md Shows the initial setup of a device and the subsequent commit that triggers auto-configuration, including logs of the process. ```cli admin@ncs% show packages package component ned device packages package router-nc-1.0 component router ned device vendor "Acme Inc." ned device product-family [ "Acme Netconf router 1.0" ] ned device operating-system [ AcmeOS "AcmeOS 2.0" ] [ok][2024-04-16 19:53:20] admin@ncs% set devices device mydev address 127.0.0.1 port 12022 authgroup default [ok][2024-04-16 19:53:34] [edit] admin@ncs% set devices device mydev auto-configure vendor "Acme Inc." operating-system AcmeOs [ok][2024-04-16 19:53:36] [edit] admin@ncs% commit | details ... 2024-04-16T19:53:37.655 device mydev: auto-configuring... 2024-04-16T19:53:37.659 device mydev: configuring admin state... ok (0.000 s) 2024-04-16T19:53:37.659 device mydev: fetching ssh host keys... ok (0.011 s) 2024-04-16T19:53:37.671 device mydev: copying configuration from device... ok (0.054 s) 2024-04-16T19:53:37.726 device mydev: auto-configuring: ok (0.070 s) ... ``` -------------------------------- ### Setting and Getting C_INT64 Values Source: https://github.com/nso-developer/nso-gitbook/blob/main/resources/man/confd_types.3.md Example of setting and getting a signed 64-bit integer using the C_INT64 type and ConfD API macros. ```c int64_t ival; confd_value_t myval; CONFD_SET_INT64(&myval, -32); ival = CONFD_GET_INT64(&myval); ``` -------------------------------- ### Setting and Getting C_INT32 Values Source: https://github.com/nso-developer/nso-gitbook/blob/main/resources/man/confd_types.3.md Example of setting and getting a signed 32-bit integer using the C_INT32 type and ConfD API macros. ```c int32_t ival; confd_value_t myval; CONFD_SET_INT32(&myval, -77732); ival = CONFD_GET_INT32(&myval); ``` -------------------------------- ### Setting and Getting C_INT16 Values Source: https://github.com/nso-developer/nso-gitbook/blob/main/resources/man/confd_types.3.md Example of setting and getting a signed 16-bit integer using the C_INT16 type and ConfD API macros. ```c int16_t ival; confd_value_t myval; CONFD_SET_INT16(&myval, -3277); ival = CONFD_GET_INT16(&myval); ``` -------------------------------- ### List Example Configurations Source: https://github.com/nso-developer/nso-gitbook/blob/main/administration/installation-and-deployment/post-install-actions/explore-the-installation.md List the example configurations available in the 'examples.ncs/' directory. These examples are useful for learning and testing NSO functionalities. ```bash $ ls -1 examples.ncs/ README.md aaa common device-management getting-started high-availability layered-services-architecture misc nano-services northbound-interfaces scaling-performance sdk-api service-management ``` -------------------------------- ### setup Source: https://github.com/nso-developer/nso-gitbook/blob/main/developer-reference/pyapi/ncs.application.md Application setup method. Override this method to perform custom initialization, such as registering actions and services. If an exception occurs during setup, teardown will be called immediately. ```APIDOC ## setup() ### Description Application setup method. Override this method to register actions and services. Any other initialization could also be done here. If the call to this method throws an exception the teardown method will be immediately called and the application shutdown. ``` -------------------------------- ### Setting and Getting C_INT8 Values Source: https://github.com/nso-developer/nso-gitbook/blob/main/resources/man/confd_types.3.md Example of setting and getting a signed 8-bit integer using the C_INT8 type and ConfD API macros. ```c int8_t ival; confd_value_t myval; CONFD_SET_INT8(&myval, -32); ival = CONFD_GET_INT8(&myval); ``` -------------------------------- ### Application Setup Method Source: https://github.com/nso-developer/nso-gitbook/blob/main/developer-reference/pyapi/ncs.application.md Override this method to perform application initialization, such as registering actions and services. If an exception occurs during setup, teardown will be called immediately. ```python setup(self) ``` -------------------------------- ### Start Network Simulator Source: https://github.com/nso-developer/nso-gitbook/blob/main/administration/management/package-mgmt.md Starts the network simulator, bringing all configured network devices online. ```bash $ ncs-netsim start DEVICE c0 OK STARTED DEVICE c1 OK STARTED DEVICE c2 OK STARTED DEVICE n0 OK STARTED DEVICE n1 OK STARTED ``` -------------------------------- ### Start NSO Transaction with Python Source: https://github.com/nso-developer/nso-gitbook/blob/main/development/introduction-to-automation/basic-automation-with-python.md Use a Python 'with' block to ensure automatic cleanup of NSO transactions. This example shows how to start a read-only transaction. ```python with ncs.maapi.single_read_trans('admin', 'python') as t: ... ``` -------------------------------- ### Get Schema Method Example Source: https://github.com/nso-developer/nso-gitbook/blob/main/development/advanced-development/web-ui-development/json-rpc-api.md Demonstrates how to use the 'get_schema' method to retrieve schema information for a specific path. Includes example request and response payloads. ```bash curl \ --cookie "sessionid=sess11635875109111642;" \ -X POST \ -H 'Content-Type: application/json' \ -d '{"jsonrpc": "2.0", "id": 1, "method": "get_schema", "params": {"th": 2, "path": "/aaa:aaa/authentication/users/user{admin}", "levels": -1, "insert_values": true}}' \ http://127.0.0.1:8008/jsonrpc ``` ```json {"jsonrpc": "2.0", "id": 1, "result": {"meta": {"namespace": "http://tail-f.com/ns/aaa/1.1", "keypath": "/aaa:aaa/authentication/users/user{admin}", "prefix": "aaa", "types": {"http://tail-f.com/ns/aaa/1.1:passwdStr": [{"name": "http://tail-f.com/ns/aaa/1.1:passwdStr"}, {"name": "MD5DigestString"}]}}}, "data": {"kind": "list-entry", "name": "user", "qname": "aaa:user", "access": {"create": true, "update": true, "delete": true}, "children": [{"kind": "key", "name": "name", "qname": "aaa:name", "info": {"string": "Login name of the user"}, "mandatory": true, "access": {"update": true}, "type": {"name": "string", "primitive": true}}, ...]}} ``` -------------------------------- ### Fetch, Install, and Reload Packages Source: https://github.com/nso-developer/nso-gitbook/blob/main/administration/management/package-mgmt.md Demonstrates the typical CLI commands for fetching a package from the file system, installing it (replacing an existing version if necessary), and then reloading the NSO packages to make the new version available. ```bash admin@ncs# software packages fetch package-from-file /tmp/package-store/router-nc-1.0.2.tar.gz admin@ncs# software packages install package router-nc-1.0.2 replace-existing admin@ncs# packages reload ``` -------------------------------- ### Run perf-stack Example Source: https://github.com/nso-developer/nso-gitbook/blob/main/development/advanced-development/scaling-and-performance-optimization.md Execute the showcase script for the perf-stack example to test concurrent service deployment. Adjust parameters like number of devices, transactions, workload, and commit queue usage. ```bash cd $NCS_DIR/examples.ncs/scaling-performance/perf-stack ./showcase.sh -d 2 -t 2 -w 1 -r 1 -q 'True' -y 1 ``` -------------------------------- ### register_trans_validate_cb Source: https://github.com/nso-developer/nso-gitbook/blob/main/developer-reference/pyapi/_ncs.dp.md Installs callback functions for the start and stop of the validation phase in a transaction. ```APIDOC ## register_trans_validate_cb ### Description Installs two callback functions for the daemon context: one called when the validation phase starts in a transaction, and another called when it stops. ### Method ```python register_trans_validate_cb(dx, vcbs) ``` ### Parameters #### Keyword Arguments - **dx** (daemon context) - A daemon context acquired through a call to `init_daemon()`. - **vcbs** (callback instance) - The callback instance. Should have methods like `cb_init` and `cb_stop`. ``` -------------------------------- ### Set up NSO instance with packages and simulated devices Source: https://github.com/nso-developer/nso-gitbook/blob/main/development/advanced-development/development-environment-and-resources.md The `ncs-setup` command initializes a new NSO instance directory (`ncs-run`). It specifies the directory for simulated devices (`--netsim-dir`) and includes necessary NED packages using the `--package` option. ```bash $ ncs-setup --dest ncs-run --netsim-dir ./netsim \ --package $NCS_DIR/packages/neds/cisco-ios-cli-3.8 \ --package $NCS_DIR/packages/neds/cisco-iosxr-cli-3.0 ``` -------------------------------- ### Prepare and Start Simulated Routers Source: https://github.com/nso-developer/nso-gitbook/blob/main/development/introduction-to-automation/basic-automation-with-python.md Clean previous builds, compile the network services, and start the network simulator. Ensure no NSO or netsim processes are running beforehand. ```bash make clean all && ncs-netsim start ``` -------------------------------- ### Enter Configuration Mode and Show Full Configuration Source: https://github.com/nso-developer/nso-gitbook/blob/main/operation-and-usage/cli/introduction-to-nso-cli.md Enters configuration mode and displays the full configuration for all devices, showing NSO-configured data before synchronization. ```bash admin@ncs# config Entering configuration mode terminal admin@ncs(config)# show full-configuration devices device devices device ce0 address 127.0.0.1 port 10022 ssh host-key ssh-dss ... ! devices device ce1 ... ! ... ``` -------------------------------- ### Setting and Getting C_BOOL Values Source: https://github.com/nso-developer/nso-gitbook/blob/main/resources/man/confd_types.3.md Example of setting and getting a boolean value using the C_BOOL type and ConfD API macros. Non-zero is true, zero is false. ```c int b; confd_value_t myval; CONFD_SET_BOOL(&myval, 1); b = CONFD_GET_BOOL(&myval); ``` -------------------------------- ### Show Installed NED Packages Source: https://github.com/nso-developer/nso-gitbook/blob/main/operation-and-usage/operations/neds-and-adding-devices.md Displays a list of currently installed NED packages, including their versions, descriptions, and directories. Note that the F5 BigIP package is not shown in this example. ```cli admin@ncs# show packages packages package cisco-ios package-version 3.0 description "NED package for Cisco IOS" ncs-min-version [ 3.0.2 ] directory ./state/packages-in-use/1/cisco-ios component upgrade-ned-id upgrade java-class-name com.tailf.packages.ned.ios.UpgradeNedId component cisco-ios ned cli ned-id cisco-ios ned cli java-class-name com.tailf.packages.ned.ios.IOSNedCli ned device vendor Cisco NAME VALUE --------------------- show-tag interface oper-status up packages package f5-bigip package-version 1.3 description "NED package for the F5 BigIp FW/LB" ncs-min-version [ 3.0.1 ] directory ./state/packages-in-use/1/bigip component f5-bigip ned generic java-class-name com.tailf.packages.ned.bigip.BigIpNedGeneric ned device vendor F5 oper-status up ! ``` -------------------------------- ### Run NSO Example Demo Source: https://github.com/nso-developer/nso-gitbook/blob/main/development/core-concepts/implementing-services.md Shell commands to navigate to the DNS service example directory and run the demo script. ```bash cd $NCS_DIR/examples.ncs/service-management/implement-a-service/dns-v1 make demo ``` -------------------------------- ### Get LeafList as List Source: https://github.com/nso-developer/nso-gitbook/blob/main/developer-reference/pyapi/ncs.maagic.md Returns leaf-list values in a list. Example use: root.model.ll.as_list() ```python as_list(self) ``` -------------------------------- ### CLI Commands for Report-All Example Source: https://github.com/nso-developer/nso-gitbook/blob/main/development/advanced-development/developing-neds/README.md These CLI commands demonstrate creating a list entry and comparing configurations, highlighting the NSO out-of-sync issue when a device reports default values. ```bash $ ncs_cli -C -u admin ``` ```bash admin@ncs# config ``` ```bash admin@ncs(config)# devices device a0 config interface myinterface ``` ```bash admin@ncs(config)# commit ``` ```bash admin@ncs(config)# top devices device a0 compare-config ``` ```diff diff devices { device a0 { config { interface myinterface { + treshold 20; } } } } ``` -------------------------------- ### Receive Notifications Source: https://github.com/nso-developer/nso-gitbook/blob/main/development/core-concepts/northbound-apis/restconf-api.md After establishing a subscription, use the provided URI in a GET request with the 'Accept: text/event-stream' header to start receiving notifications. This GET request acts as a long polling request. ```APIDOC ## GET /restconf/subscriptions/{subscriptionId} ### Description Retrieves notifications for an established subscription. This is a long-polling request that waits for notifications to arrive. ### Method GET ### Endpoint /restconf/subscriptions/{subscriptionId} ### Parameters #### Path Parameters - **subscriptionId** (string) - Required - The ID of the subscription for which to receive notifications. ### Request Headers - **Accept**: text/event-stream ### Response #### Success Response (200) - **data** (event-stream) - Contains notification messages prefixed with 'data:'. The connection remains open until notifications are sent or the session is closed. #### Response Example ```http HTTP/1.1 200 OK Content-Type: text/event-stream ...NOTE: we will be waiting here until a notification is generated... data: data: 2020-05-04T13:48:02.291816+00:00 data: data: notif1 data: data: ...NOTE: we will still be waiting here for more notifications to come... ``` ``` -------------------------------- ### Example Bundle project-meta-data.xml Configuration Source: https://github.com/nso-developer/nso-gitbook/blob/main/development/advanced-development/developing-packages.md This XML file demonstrates how to configure project metadata, including package definitions with local, URL, and Git sources, and bundle configurations for packaging project components. ```xml l3vpn-demo 1.0 l3vpn demo example_bundle my-package-1 my-package-2 http://localhost:9999/my-local.tar.gz my-package-3 ssh://git@example.com/pkg/resource-manager.git 1.2 my-package-1 my-package-2 my-package-3 ssh://git@example.com/pkg/resource-manager.git 1.2 ``` -------------------------------- ### Setting and Getting C_TIME Source: https://github.com/nso-developer/nso-gitbook/blob/main/resources/man/confd_types.3.md Example of setting and retrieving a C_TIME value. Timezone information is represented similarly to C_DATE. ```c confd_value_t myval; struct confd_time dt; dt.hour = 19, dt.min = 3, dt.sec = 31; dt.timezone = CONFD_TIMEZONE_UNDEF; CONFD_SET_TIME(&myval, dt); dt = CONFD_GET_TIME(&myval); ``` -------------------------------- ### Set up NSO directory with simulated network devices Source: https://github.com/nso-developer/nso-gitbook/blob/main/development/advanced-development/developing-packages.md Use `ncs-setup` to create an NSO directory and initialize it with devices from a `ncs-netsim` environment. Ensure `ncs-netsim create-network` is run before this command. ```bash $ ncs-setup --netsim-dir ./netsim --dest NCS; $ cd NCS $ cat README.ncs ....... $ ncs ``` -------------------------------- ### Start Network Simulator and NSO Source: https://github.com/nso-developer/nso-gitbook/blob/main/development/advanced-development/developing-services/service-development-using-java.md Starts the network simulator and the NSO instance. Verifies that devices are started successfully. ```bash $ ncs-netsim start DEVICE c0 OK STARTED DEVICE c1 OK STARTED DEVICE c2 OK STARTED $ ncs ``` -------------------------------- ### Setting and Getting C_DATE Source: https://github.com/nso-developer/nso-gitbook/blob/main/resources/man/confd_types.3.md Example of setting and retrieving a C_DATE value. The timezone fields indicate the offset from UTC. ```c confd_value_t myval; struct confd_date dt; dt.year = 1960, dt.month = 3, dt.day = 31; dt.timezone = CONFD_TIMEZONE_UNDEF; CONFD_SET_DATE(&myval, dt); dt = CONFD_GET_DATE(&myval); ``` -------------------------------- ### Initializing and Managing Service Plans Source: https://github.com/nso-developer/nso-gitbook/blob/main/development/core-concepts/api-overview/python-api-overview.md Demonstrates the pattern of creating a main service plan and individual component plans. It shows how to append states and set the initial state to reached for a service. ```python self_plan = PlanComponent(service, 'self', 'ncs:self') self_plan.append_state('ncs:init') self_plan.append_state('ncs:ready') self_plan.set_reached('ncs:init') route_plan = PlanComponent(service, 'router', 'myserv:router') route_plan.append_state('ncs:init') route_plan.append_state('myserv:syslog-initialized') route_plan.append_state('myserv:ntp-initialized') route_plan.append_state('myserv:dns-initialized') route_plan.append_state('ncs:ready') route_plan.set_reached('ncs:init') ``` -------------------------------- ### Navigate to Router Network Directory Source: https://github.com/nso-developer/nso-gitbook/blob/main/development/introduction-to-automation/basic-automation-with-python.md Change the current directory to the router-network example directory. This is a prerequisite for starting the simulated routers. ```bash cd $NCS_DIR/examples.ncs/device-management/router-network ``` -------------------------------- ### CLI Completion Meta-Info Example (alt1) Source: https://github.com/nso-developer/nso-gitbook/blob/main/resources/man/ncs.conf.5.md Demonstrates how completion alternatives are prefixed when completionMetaInfo is set to 'alt1'. Prefixes indicate containers ('>'), lists ('+'), and leaf-lists ('+'). ```text containers with > lists with + leaf-lists with + For example: Possible completions: ... > applications + apply-groups ... + dns-servers ... ``` -------------------------------- ### Display Installer Binary Help Source: https://github.com/nso-developer/nso-gitbook/blob/main/administration/installation-and-deployment/local-install.md View additional help for running NSO installer binaries by appending the --help flag to the binary name. This provides details on installation options. ```bash sh nso-VERSION.darwin.x86_64.installer.bin --help ``` -------------------------------- ### Get CDB Start Phase Source: https://github.com/nso-developer/nso-gitbook/blob/main/resources/man/confd_lib_cdb.3.md Retrieves the current start-phase of the Configuration Database. It also indicates if an initialization or upgrade session is in progress. ```c int cdb_get_phase( int sock, struct cdb_phase *phase); ``` -------------------------------- ### Example: Using confd_dotted_quad with ConfD API Source: https://github.com/nso-developer/nso-gitbook/blob/main/resources/man/confd_types.3.md Demonstrates how to set and get a dotted quad value using ConfD API functions. ```c struct confd_dotted_quad dquad; confd_value_t myval; dquad.quad[0] = 1; dquad.quad[1] = 2; dquad.quad[2] = 3; dquad.quad[3] = 4; CONFD_SET_DQUAD(&myval, dquad); dquad = CONFD_GET_DQUAD(&myval); ``` -------------------------------- ### Display NSO Installer Help Source: https://github.com/nso-developer/nso-gitbook/blob/main/administration/installation-and-deployment/local-install.md Run the NSO installer with the --help flag to view available installation options and usage instructions. This is useful for understanding the different installation modes and their parameters. ```bash sh nso-6.0.darwin.x86_64.installer.bin --help ``` -------------------------------- ### Setting and Getting Binary Data (C_BINARY) Source: https://github.com/nso-developer/nso-gitbook/blob/main/resources/man/confd_types.3.md Example demonstrating how to set and retrieve binary data using ConfD's C-API. ```c confd_value_t myval, myval2; unsigned char *bin; int len; bin = CONFD_GET_BINARY_PTR(&myval); len = CONFD_GET_BINARY_SIZE(&myval); CONFD_SET_BINARY(&myval2, bin, len); ``` -------------------------------- ### Create Device Group CLI Example Source: https://github.com/nso-developer/nso-gitbook/blob/main/operation-and-usage/operations/nso-device-manager.md Demonstrates the CLI commands to create a new device group and add devices to it. ```cli ncs(config)# devices device-group my-group device-name ce0 ncs(config-device-group-my-group)# device-name pe Possible completions: pe0 pe1 pe2 pe3 ncs(config-device-group-my-group)# device-name pe0 ncs(config-device-group-my-group)# device-name p0 ncs(config-device-group-my-group)# commit ``` -------------------------------- ### Setting and Getting C_DURATION Source: https://github.com/nso-developer/nso-gitbook/blob/main/resources/man/confd_types.3.md Example of setting and retrieving a C_DURATION value, specifically for a duration of 3 seconds. Uses memset for initialization. ```c confd_value_t myval; struct confd_duration dt; memset(&dt, 0, sizeof(struct confd_duration)); dt.secs = 3; CONFD_SET_DURATION(&myval, dt); dt = CONFD_GET_DURATION(&myval); ``` -------------------------------- ### Running the DNS Service Demo Source: https://github.com/nso-developer/nso-gitbook/blob/main/development/core-concepts/implementing-services.md Command to navigate to the DNS service example directory and run the demo. ```bash $ cd $NCS_DIR/examples.ncs/service-management/implement-a-service/dns-v2 $ make demo ``` -------------------------------- ### Get Objects from List Source: https://github.com/nso-developer/nso-gitbook/blob/main/developer-reference/pyapi/ncs.maapi.md Reads a specified number of values from object lists starting at a cursor. Returns a list of Value objects. ```python get_objects(self, mc, n, nobj) ``` -------------------------------- ### Start the Simulation Network Source: https://github.com/nso-developer/nso-gitbook/blob/main/development/advanced-development/developing-packages.md After creating the network, use `ncs-netsim start` to bring up all simulated devices. ```bash $ ncs-netsim start ``` -------------------------------- ### Change Directory to Package Source: https://github.com/nso-developer/nso-gitbook/blob/main/development/introduction-to-automation/cdb-and-yang.md Navigate into the newly created package directory to start working on your data models and services. ```bash $ cd $NSO_RUNDIR/packages/my-data-entries ``` -------------------------------- ### Setting and Getting IPv6 Prefix (C_IPV6PREFIX) Source: https://github.com/nso-developer/nso-gitbook/blob/main/resources/man/confd_types.3.md Example demonstrating how to set and retrieve an IPv6 prefix value using ConfD's C-API. ```c struct confd_ipv6_prefix prefix; confd_value_t myval; inet_pton(AF_INET6, "2001:DB8::1428:57A8", &prefix.ip6); prefix.len = 125; CONFD_SET_IPV6PREFIX(&myval, prefix); prefix = CONFD_GET_IPV6PREFIX(&myval); ``` -------------------------------- ### Example of exec callback with cp command Source: https://github.com/nso-developer/nso-gitbook/blob/main/resources/man/clispec.5.md Demonstrates how to configure an 'exec' callback to run the 'cp' command with specific options like user and working directory. ```xml cp ncs /var/tmp ... ``` -------------------------------- ### Setting and Getting IPv4 Prefix (C_IPV4PREFIX) Source: https://github.com/nso-developer/nso-gitbook/blob/main/resources/man/confd_types.3.md Example demonstrating how to set and retrieve an IPv4 prefix value using ConfD's C-API. ```c struct confd_ipv4_prefix prefix; confd_value_t myval; prefix.ip.s_addr = inet_addr("10.0.0.0"); prefix.len = 8; CONFD_SET_IPV4PREFIX(&myval, prefix); prefix = CONFD_GET_IPV4PREFIX(&myval); ```