08-31-2017 10:34 PM - edited 03-01-2019 03:58 AM
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
Solved! Go to Solution.
09-01-2017 05:51 AM
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.
09-01-2017 02:17 AM
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.
09-01-2017 05:30 AM
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
09-01-2017 05:51 AM
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.
09-03-2017 09:52 PM
Thanks Jan,
It worked by making call to new_trans.
09-05-2017 11:24 PM
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
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide