This lab is intended to figure out how to interract with NXOS switched via netconf
The goal is to craft and test RPCs that can be used in the evpn fabric controller (nxos only) that I plan to implement in the future
The tricky part is to dig around YANG models. There are three utilities that helps a lot:
the xml templates are located in the tpl_evpn_xml.py file
I already have mentioned gnmic and yangpath tools above.
They are pretty usefull to dig inside the particular YANG model
The result is a path-like string separated with slashes. I called this format ypath
This is one of the example:
/System/ipv4-items/inst-items/dom-items/Dom-list/name=default/if-items/If-list/id=vlan333
Netconf needs XML though. So I wrote a function and some wrappers to help transforms that ypath into XML
from ypath import ypath2xml, ppxml
xmlns = "http://cisco.com/ns/yang/cisco-nx-os-device"
ypath = '/System/ipv4-items/inst-items/dom-items/Dom-list/name=default/if-items/If-list/id=vlan333'
ppxml(ypath2xml(ypath, xmlns))
<System xmlns="http://cisco.com/ns/yang/cisco-nx-os-device">
<ipv4-items>
<inst-items>
<dom-items>
<Dom-list>
<name>default</name>
<if-items>
<If-list>
<id>vlan333</id>
</If-list>
</if-items>
</Dom-list>
</dom-items>
</inst-items>
</ipv4-items>
</System>
I love scrapli (I've used it in my repo rocket.bot and I like it)
So the scrapli_netconf was the first thing I thought of when I started to play with Netconf
example: play_scraply_netconf.py
Ok lets assume we need to configure not a switch but a service.
This means you have to configure a couple of devices at once. Plus you have to implement a transactional model so if one of the devices fails all the ongoing changes has to be rolled back.
the Nornir library could be pretty usefull. And surprise-surprise there is the scrapli plugin again: nornir_scrapli
the file nr_scraply_funcs contains the function where I tried to implement the transactional model
and it seems to work:
create_evpn.py file is running