Skip to content


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

pip install pyang
pip install pyangbind
pip3 freeze | grep pyang

Get YANG modules

We need YANG modules so we can use Pyang and Pyangbind.

Create a directory

mkdir yang_modules

Clone the OpenConfig repository

git clone

Run this command to verify

ls public

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

cd yang_modules/

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 openconfig-bgp.yang

The above command generated the python module from the openconfig-bgp.yang file. Run this command to verify:


Use the new python module to generate an OpenConfig configuration file

The file uses the new python module 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 --insecure -u arista -p arista get   \
    --path '/network-instances/network-instance[name=default]/protocols/protocol[name=BGP]/bgp'
show run section bgp

Use gNMIc to configure the swicth

gnmic -a --insecure -u arista -p arista set  \
    --replace-path '/network-instances/network-instance[name=default]/protocols/protocol[name=BGP]/bgp' \
    --replace-file demo.json

Check the device configuration after

gnmic -a --insecure -u arista -p arista get  \
    --path '/network-instances/network-instance[name=default]/protocols/protocol[name=BGP]/bgp'
show run section bgp