Did anyone see or used JSON-RPC API implementations on Java or C#? If so could you please point to the library, docs or examples. I am looking at NSC User Guide document that contains the whole section on JSON-RPC but it says nothing about working with devices. Simple example of onboarding a device would help.
Solved! Go to Solution.
Please see attached python script that creates a device using JSON RPC.
I don't think you need a NCS-specific library on Java, C# or whatever language to use JSON RPC – it's still/just HTTP with manipulated data/body.
I have no idea of the 2nd question – how to onboard a device using JSON RPC. I even doubt this is what JSON RPC designed to do on NCS
I'm also a newbie, so I might be wrong.
It is best to start with the example.js. The following minimum steps work for me:
cd $NCS_DIR/var/ncs/webui/dist/ncs
ln -s ../../example .
Browse http://127.0.0.1:8080/example/
To create a device, use method “create” path: "/ncs:devices/ncs:device{NAME}”
To delete a device, use method “delete” path.
> I don't think you need a NCS-specific library on Java, C# or whatever
> language to use JSON RPC – it's still/just HTTP with manipulated data/body.
Correct,
> I have no idea of the 2nd question – how to onboard a device > using JSON RPC.
> I even doubt this is what JSON RPC designed to do on NCS I'm also a
> newbie, so I might be wrong.
Ohh it certainly is - it's just a matter of providing the correct payload, i.e adding an entry to /devices/device tree
Nothing differentiates that to any other payload/transaction
Thanks Klacke.
Could you kindly provide a code example of onboarding a device using json-rpc? I wonder why this is not mentioned anywhere in ncs user guide (or I'm too careless) and where is the 'manual' Thanks again.
I haven't personally used the JSON-RPC, and I have no ready-made example on how to onboard a device using JSON-RPC.
However, to use the JSON-RPC you must understand how to produce the equivalent of a NETCONF edit-config for any type of NSO config change. It's a matter of manipulating the DOM tree in general.
Once you do that, you will be able to onboard a device, by invoking the equivalent of
new_trans
create /devices/device[name="x"]
set /devices/device[name="x"]/address a.b.c.d
.....
commit
All that is needed to populate the entire /devices/device entry for the wanted device type.
Create it in CLI first to make sure it works.
Please see attached python script that creates a device using JSON RPC.
Fredrik - you're the man !!
Many thanks to Klacke and Fredrik