cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2572
Views
8
Helpful
5
Replies

NSO - How to get device list using json-rpc?

vgujuluv
Cisco Employee
Cisco Employee

Hi,

I'm trying to get device list using json-rpc. I didn't find a method like "get_devices" in the documentation https://cisco.jiveon.com/docs/DOC-1709569

Is there any method to get devices?  I also tried using "get_value" method but I don't know the path param to fetch details.

Thank you

-Vishnu

1 Accepted Solution

Accepted Solutions

Well, you need to obtain the th handle from what's returned from a new_trans operation. Just cutting+pasting from sample calls will not work. And before new_trans, you need to call login.

View solution in original post

5 Replies 5

Jan Lindblad
Cisco Employee
Cisco Employee

No, there is no method to "get devices". NSO is data model driven, so *everything* you can get is described by a YANG model, and you get any/all that data using the same basic set of calls. So you won't be able to progress unless you figure out the path(s) you're interested in.

The list of devices are under /ncs:devices/device/... as described in the YANG module  .../nso/4.4.2/src/ncs/yang/tailf-ncs-devices.yang .


One popular way of finding out the right paths is to go into the NSO CLI and run some show commands. Then, when you've found what you're looking for, run    show running-config ...whatever... | display xpath | display prefixes

E.g.

# show running-config devices device | display xpath | display prefixes

/ncs:devices/ncs:device[ncs:name='ce0']/ncs:address 192.168.50.50

/ncs:devices/ncs:device[ncs:name='ce0']/ncs:authgroup vagrant

/ncs:devices/ncs:device[ncs:name='ce0']/ncs:device-type/ncs:netconf

/ncs:devices/ncs:device[ncs:name='ce0']/ncs:connect-timeout 60


These are the paths you need to use.


Thanks Jan.

I got the xpath from ncs-cli. But if I call "get_value" method it fails as invalid parameter "th".

Request

=======

{

"jsonrpc" : "2.0",

"id" : 2,

"method" : "get_value",

"params" : {

"th" : 2,

"path" : "/ncs:devices/ncs:device[ncs:name='c1']/ncs:config/ios:interface/ios:Loopback[ios:name='0']"

}

}

Response

========

{

    "jsonrpc": "2.0",

    "error": {

        "type": "rpc.method.invalid_params",

        "code": -32602,

        "message": "Invalid parameters",

        "data": {

            "param": "th"

        },

        "internal": "webui_util547"

    },

    "id": 2

}

I have given integer value for th as per the documentation https://cisco.jiveon.com/docs/DOC-1709569 but it get invalid response.

Thank you

-Vishnu

Well, you need to obtain the th handle from what's returned from a new_trans operation. Just cutting+pasting from sample calls will not work. And before new_trans, you need to call login.

Thanks Jan,

It worked by making call to new_trans.

Hi,

Just FYI.

You can refer some basics of JSON-RPC here.

https://communities.cisco.com/docs/DOC-74494

I hope this helps you.

Regards,

Akira