cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3700
Views
1
Helpful
2
Replies

NSO live-status: how to use this great, undocumented feature properly

rslaski
Spotlight
Spotlight

Hi developers,

 

For the new project, I'll have to deviate from NSO orchestration functions a little bit - the requirement is not only to deploy services, but also validate their operation. And yes, we could use any external custom-built system for that, but why duplicate things, while most of the required data is inside the NSO. That's how I found a feature called 'live-status', which triggers NED 'stats' module to retrieve some operational data (and of course, many f-words were spoken here, trying to find just anything in the documentation).

 

So my basic questions are:

 

1) How to trigger live-status from Python code?

I've found one quite good explanation in the forum, so let's consider that as explained a little:

https://community.cisco.com/t5/nso-developer-hub-discussions/how-do-i-call-the-devices-device-foo-config-exec-action-from/td-p/3750061

 

2) How to trigger live-status from API?

I probably should use POST over some never documented URI, something like:

http://{{NSO_IP}}:{{NSO_HTTP_PORT}}/restconf/data/tailf-ncs:devices/device=NX_LEAF111/live-status/tailf-ned-cisco-nx-stats:exec/any

However what should be put inside the body is still unknown to me, so I get:

"error-message": "External error in the NED implementation for device NX_LEAF111: missing argument(s) for subcmd=any",

3) Can we augment the NED stats tree with own fields, populated with values read from device with my own callback code?

 

thanks,
robert

 

1 Accepted Solution

Accepted Solutions

lmanor
Cisco Employee
Cisco Employee
For question #2 from RESTCONF:
The exec/any command is an action that is defined in the XE (and other) NED:
From XE NED yang:
container exec {
    tailf:info "Execute commands on device";
{…}
    // any [arg 1] .. [arg N]
    tailf:action any {
      tailf:info "Execute any command on device";
      tailf:actionpoint ncsinternal {
        tailf:internal;
      }
      input {
        leaf-list args {
          tailf:cli-drop-node-name;
          tailf:cli-flat-list-syntax;
          type string {
            tailf:info "WORD;;any <cmd> [option(s)], e.g: any event manager run my_applet (see README for more info)";
          }
        }
      }
      output {
        leaf result {
          type string;
        }
      }
    }

So you need to provide the 'input' to the action - here is a RESTCONF example from IOS-XR, XE should be same:

curl -i -u admin:admin  http://localhost:8080/restconf/operations/devices/device=xr-0/live-status/tailf-ned-cisco-ios-xr-stats:exec/any -X POST -H 'Accept: application/yang-data+json' -H 'Content-Type: application/yang-data+json' -T show-run-vrf.json
cat show-run-vrf.json
{
  "input":
  {
    "args": "show run vrf foo"
  }
}

 

View solution in original post

2 Replies 2

Jason Belk
Cisco Employee
Cisco Employee

Hi!

 

Yes, the exec live status is a wonderful feature that is often not talked about enough. 

 

I don't have a RESTCONF example handy, though I have a Python one:

 

https://github.com/NSO-developer/nso-5-day-training/blob/master/nso_python_api_examples.py#L134

 

Also if you are looking for other restconf examples, I made this postman collection:

https://github.com/NSO-developer/cisco-nso-postman

(though I admit it does not have the live status, I plan to add it soon)

lmanor
Cisco Employee
Cisco Employee
For question #2 from RESTCONF:
The exec/any command is an action that is defined in the XE (and other) NED:
From XE NED yang:
container exec {
    tailf:info "Execute commands on device";
{…}
    // any [arg 1] .. [arg N]
    tailf:action any {
      tailf:info "Execute any command on device";
      tailf:actionpoint ncsinternal {
        tailf:internal;
      }
      input {
        leaf-list args {
          tailf:cli-drop-node-name;
          tailf:cli-flat-list-syntax;
          type string {
            tailf:info "WORD;;any <cmd> [option(s)], e.g: any event manager run my_applet (see README for more info)";
          }
        }
      }
      output {
        leaf result {
          type string;
        }
      }
    }

So you need to provide the 'input' to the action - here is a RESTCONF example from IOS-XR, XE should be same:

curl -i -u admin:admin  http://localhost:8080/restconf/operations/devices/device=xr-0/live-status/tailf-ned-cisco-ios-xr-stats:exec/any -X POST -H 'Accept: application/yang-data+json' -H 'Content-Type: application/yang-data+json' -T show-run-vrf.json
cat show-run-vrf.json
{
  "input":
  {
    "args": "show run vrf foo"
  }
}