Pyangbind
PyangBind is a pyang plugin.
About Pyang
Please visit this link if you need help about Pyang.
About PyangBind
It generates Python classes from a YANG module.
It converts YANG module into a Python module. This Python module can be then used to generate data which conforms with the data model defined in YANG.
Install Pyang and Pyangbind
Get YANG modules
We need YANG modules so we can use Pyang and Pyangbind.
Create a directory
Clone the OpenConfig repository
Run this command to verify
Copy all the YANG files from OpenConfig to the yang_modules directory
cp public/release/models/*.yang yang_modules/.
cp -R public/release/models/*/*.yang yang_modules/.
cp public/third_party/ietf/*.yang yang_modules/.
Move to the yang_modules directory
Verify it has all the YANG files published on the OpenConfig repository
Use Pyangbind to generate a Python module from a YANG module
pyang --plugindir $HOME/.local/lib/python3.6/site-packages/pyangbind/plugin/ -f pybind -o oc_bgp.py openconfig-bgp.yang
The above command generated the python module oc_bgp.py
from the openconfig-bgp.yang
file.
Run this command to verify:
Use the new python module to generate an OpenConfig configuration file
The file pyangbind_demo.py uses
the new python module oc_bgp.py
and generates this OpenConfig configuration file demo.json
Use gNMI SET RPC to configure a device
This OpenConfig configuration file demo.json can be loaded on a switch using the gNMI Set RPC
Install gNMIc
Please visit this link if you need help with gNMIc installation
Required device configuration
Please visit this link if you need help to configure EOS for gNMI
Use gNMIc to configure the swicth
Check the device configuration before
gnmic -a 192.0.2.117:6030 --insecure -u arista -p arista get \
--path '/network-instances/network-instance[name=default]/protocols/protocol[name=BGP]/bgp'
Use gNMIc to configure the swicth
gnmic -a 192.0.2.117:6030 --insecure -u arista -p arista set \
--replace-path '/network-instances/network-instance[name=default]/protocols/protocol[name=BGP]/bgp' \
--replace-file demo.json