NSO

Enable RESTCONF

  • RESTCONF is enabled by default ncs.conf

  • To verify: send a get request to https://nso/restconf:

    • curl https://sandbox-nso-1.cisco.com -u developer

    • password is Services4Ever

  • Add headers to JSON encoding

    • Accept header instructs NSO to return data in the selected format

    • Content-Type corresponds to the format of the data in the request

    curl  https://sandbox-nso-1.cisco.com/restconf -u developer -H "Accept:application/yang-data+json" -H "Content-Type:application/yang-data+json" 
      Enter host password for user 'developer':
      {"ietf-restconf:restconf":{"data":{},"operations":{},"yang-library-version":"2019-01-04"}}

    Finding the data

    • In below response, all data is located under "data" key, all RPC operations are found under "operation" key

      {"ietf-restconf:restconf":{"data":{},"operations":{},"yang-library-version":"2019-01-04"}}
    • RESTCONF responses by default include both configuration and noon-configuration (operational) data which means the actual returned data is from both of the following commands, for example:

      • admin@ncs# show running-config devices device-group IOS-DEVICES

      • admin@ncs# show devices device-group IOS-DEVICES

    Some Examples

    Listing device groups

  • Commands: show running-config devices device-group

  • Restconf: Get /restconf/data/tailf-ncs:devices/device-group (tailf-ncs: namespace)

Listing a single device group

  • GET /restconf/data/tailf-ncs:devices/device-group=IOS-DEVICES

Filtering returned data

  • Using ?content= query parameter, valid values are config, nonconfig and all

  • Using &depth=1 to limit the level of returned data

Listing device interfaces

  • Device configuration is kept under "devices device config" path

  • To view interfaces on a devices, use commands: show running-config devices device $name config ios:inetrface (ios is the name space)

  • For RESTCONF, the name space doesn't match those on CLI, to get the list of name space using depth=1: GET /restconf/data/tailf-ncs:devices/device=dist-rtr01/config?depth=1

  • After getting the name space, the request should be: https://sandbox-nso-1.cisco.com/restconf/data/tailf-ncs:devices/device=dist-rtr01/config/tailf-ned-cisco-ios:interface

Making Changes

  • Using Put method (create or replace resource), and defines the field names and constrain of content in RESTCONF messages

  • Using Patch will merge the provided and existing data

  • Using Post will create, but if item already exists, it will fail

  • To get YANG model, Whatever read from NSO can be used to make changes,

  • Don't send operational data -> use ?content=config

  • For this request: GET /restconf/data/tailf-ncs:devices/device-group=IOS-DEVICES?content=config

  • Create a PUT request to makes changes:

  • Server will response 201 Created response

  • If 204 No Content Response -> group already exists

  • The request to Remove a device from above group will be:

Check Sync

  • CLI: devices device-group IOS-DEVICES check-sync

  • RESTCONF: POST /restconf/data/tailf-ncs:devices/device-group=IOS-DEVICES/check-sync

  • To suppress those devices in sync, add this to POST request body: { "tailf-ncs:suppress-positive-result": [null] }

  • It is the same as support-positive-result in CLI

Reference

Last updated