This is a prototype implementation of RESTCONF for the OpenWrt system that utilizes the UCI configuration files as a datastore.
- Python 3 for the YANG conversion script
- Tool for converting YANG to YIN
To add YANG modules for OpenWrt they have to go through some pre-processing. This is
what the ./yin2json/yin2json.py
script does.
Before YANG modules can be used with this implementation they have to be
annotated with the extensions provided in /yang/openwrt-uci-extension.yang
.
An example of an annotated module is /yang/restconf-example.yang
- Convert the YANG modules to be included to YIN and put them in one folder, i.e.
/yin
. For example withpyang
pyang -f yin ./yang/restconf-example.yang -p ./yang -o ./yin/restconf-example.yin
- Run the
main.py
scriptThis converts the YIN files and generates apython3 ./yin2json/yin2json.py -y ./yin -o ./generated ./yin/restconf-example.yin ...
.h
file in./generated
that has to be included in/src/generated/yang.h
- Clone this repository
Docker pull mgranderath/openwrt-build
docker run -v $(pwd):/restconf mgranderath/openwrt-build
- The generated
.ipk
will be in thebuild
folder
The tests are inside the /test
directory and are based on the Python
Tavern Testing Framework. After
installing the framework the tests can be run using either of the
following commands:
tavern-ci ./test/test_restconf.tavern.yml
# or
py.test ./test/test_restconf.tavern.yml
This will run integration tests that check the actual implementation. The
url where the server is located can be changed in /test/common.yaml
.