03-20-2019 08:41 AM
Hello all,
I have a simple yang model which represents a netconf device. I created a new netconf NED. Then, I am trying to perform the basic NETCONF operations. I could perfom most of the operations except reading the operational data (config false container).
Any help is appreciated to perform this operation.
Kind Regards,
Solved! Go to Solution.
03-21-2019 10:04 AM
It is enough to add config false to make it operational, and as long as the yang models are in the NED you do build it should work.
Actually, there is an example distributed with nso, if you look at the example examples.ncs/getting-started/developing-with-ncs/0-router-network and run through that you get an nso with 3 netconf devices.
In the ncs_cli for that example you can do:
admin@ncs> show devices device ex0 live-status sys dns
ADDRESS
----------
10.2.3.4
[ok][2019-03-21 18:00:07]
The following is an example python script that works with that example:
import ncs.maapi as maapi
import ncs.maagic as maagic
with maapi.single_read_trans('admin', 'test') as t:
root = maagic.get_root(t)
dev = root.devices.device['ex0']
for server in dev.live_status.sys.dns.server:
print 'DNS server: {}'.format(server.address)
You can just run that from the shell and it'll print all the dns servers in the operational data.
03-21-2019 03:13 AM
Can you give a little bit more information on what commands you are trying, what happens and what you see in the trace files?
03-21-2019 05:34 AM - edited 03-21-2019 05:37 AM
Firstly, thank you very much for your reply. Actually, I am going to connect NSO to a host machine with ubuntu. Host is running a netopeer2-server (i.e., NETCONF server). It has a yang model which describes my device. My yang model has two containers, one for keeping configuration and one for state data.
container host-conf {
leaf test {
type uint32;
}
}
container host-stat {
config false;
leaf stat {
type uint32;
}
}
I created a NED package as a netconf device to introduce my device to NSO. Then, running the ncs. I can use the following python code to read the configuration (i.e., host-conf). Also, I can modify the configuration.
import ncs;
with ncs.maapi.single_read_trans('admin','python') as trans:
root=ncs.maagic.get_root(trans)
device=root.devices.device['host']
device.config['hst:host-conf'].test
But I can not see where is my state data (i.e., host-stat). I mean in the last line (after device.) I am looking for my operational data which is missing. My question is how can I read it?
I hope I could explain my problem.
Thank you in advance,
Kind Regards,
03-21-2019 08:56 AM
The easiest way is probably to test this out in the ncs_cli first. Anyhow, under config you have the configuration, operational data turns up under live-status. So in python that'd be starting from device.live_status.
03-21-2019 09:35 AM - edited 03-21-2019 09:59 AM
Thanks. Could you please provide me an example of live_status. In the cli I used the following:
devices device host live-status-protocol
It turns no entries found. Actually, I have doubts about yang model as well. Does adding config false is enough to say this is operational data in the yang model or I need to add more hints?
Kind Regards,
03-21-2019 10:04 AM
It is enough to add config false to make it operational, and as long as the yang models are in the NED you do build it should work.
Actually, there is an example distributed with nso, if you look at the example examples.ncs/getting-started/developing-with-ncs/0-router-network and run through that you get an nso with 3 netconf devices.
In the ncs_cli for that example you can do:
admin@ncs> show devices device ex0 live-status sys dns
ADDRESS
----------
10.2.3.4
[ok][2019-03-21 18:00:07]
The following is an example python script that works with that example:
import ncs.maapi as maapi
import ncs.maagic as maagic
with maapi.single_read_trans('admin', 'test') as t:
root = maagic.get_root(t)
dev = root.devices.device['ex0']
for server in dev.live_status.sys.dns.server:
print 'DNS server: {}'.format(server.address)
You can just run that from the shell and it'll print all the dns servers in the operational data.
03-22-2019 02:32 AM
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