... | @@ -3,47 +3,42 @@ |
... | @@ -3,47 +3,42 @@ |
|
All examples are located in `examples/` directory.
|
|
All examples are located in `examples/` directory.
|
|
|
|
|
|
**Requirements:**
|
|
**Requirements:**
|
|
- Python 3.5+
|
|
|
|
- [resolvers-yang](https://gitlab.labs.nic.cz/labs/resolvers-yang) library must be installed.
|
|
|
|
- [yangson](https://github.com/CZ-NIC/yangson) library
|
|
|
|
- [Python virtual environment](https://gitlab.labs.nic.cz/jetconf/jetconf-resolver/wikis/devinstall) is recommended.
|
|
|
|
|
|
|
|
## JSON Data Validation
|
|
* Python 3.5+
|
|
|
|
* `resolvers-yang <https://gitlab.labs.nic.cz/labs/resolvers-yang>`_ library must be installed.
|
|
|
|
* `yangson <https://github.com/CZ-NIC/yangson>`_ library
|
|
|
|
|
|
**Data Model**
|
|
Using Python virtual environment is recommended. Look at [devinstall](https://gitlab.labs.nic.cz/jetconf/jetconf-resolver/wikis/devinstall)
|
|
* Current [Schema Tree](https://gitlab.labs.nic.cz/jetconf/resolvers-yang/raw/master/data-model/model.tree)
|
|
|
|
* Current [Yang Modules](https://gitlab.labs.nic.cz/jetconf/resolvers-yang/tree/master/yang-modules)
|
|
|
|
|
|
|
|
Go to the `examples/` directory.
|
|
## example-data.json
|
|
Validate the JSON data against the data model:
|
|
|
|
|
|
`example-data.json` is example of Json-encoded file, which is valid against *resolvers-yang* data model
|
|
|
|
|
|
|
|
You can edit this Json and validate it against data model using
|
|
```bash
|
|
```bash
|
|
(jetconf-resolver) $ make validate
|
|
$ make validate
|
|
```
|
|
```
|
|
No output means that the JSON data in `example-data.json` is valid.
|
|
No output means that `example-data.json` is valid.
|
|
|
|
|
|
## Generate configuration from Json file
|
|
## generate_conf.py
|
|
|
|
|
|
This will generate `unbound.conf` and `kresd.conf` files in local files.
|
|
This script will generate ``unbound.conf`` and ``kresd.conf`` files in local files.
|
|
|
|
|
|
Go to `examples/` directory.
|
|
|
|
|
|
|
|
Run `generate_conf.py` script with path to Json file as parameter
|
|
Run `generate_conf.py` script with path to Json file as parameter
|
|
```bash
|
|
```bash
|
|
(jetconf-resolver) $ python generate_conf.py example-data.json
|
|
$ python generate_conf.py example-data.json
|
|
```
|
|
```
|
|
If generated `unbound.conf` is converted to JSON. The result do not have to be the same as input JSON for`generate_conf.py` script because the configuration designed to [Knot Resolver](https://gitlab.labs.nic.cz/jetconf/resolvers-yang/raw/master/yang-modules/cznic-resolver-knot@2018-07-27.yang) is ignored for Unbound.
|
|
If generated `unbound.conf` is converted to JSON using `unb_to_json.py` script. The result do not have to be the same as input JSON for `generate_conf.py` script because the configuration designed to Knot Resolver is ignored for Unbound.
|
|
|
|
|
|
## Convert unbound.conf to Json file
|
|
|
|
This will convert `unbound.conf` to valid `unb-data.json`
|
|
|
|
|
|
|
|
Go to `examples/` directory.
|
|
## unb_to_json.py
|
|
|
|
|
|
As example configuration file can be used `../complete/unbound.conf` after running `genconf.py`
|
|
This script will convert Unbound configuration text file `unbound.conf` to *resolvers-yang* data model valid Json-encoded file `unb-data.json`.
|
|
|
|
As example configuration file can be used `unbound.conf` created by running `generate_conf.py`
|
|
|
|
|
|
Run `unb_to_conf.py` with path to `unbound.conf` as parameter.
|
|
Run `unb_to_conf.py` with path to `unbound.conf` as parameter
|
|
```bash
|
|
```bash
|
|
(jetconf-resolver) $ python unb_to_json.py unbound.conf
|
|
$ python unb_to_json.py unbound.conf
|
|
```
|
|
```
|
|
No output means that the JSON data in `unb-data.json` is valid.
|
|
No output means that the JSON data in created `unb-data.json` is valid.
|
|
|
|
|
|
If you generate another `unbound.conf` from this Json, it should be equal to `unbound.conf` which was used as input parameter to `unb_to_json.py` script. |
|
If you generate another `unbound.conf` from this Json using `generate_conf.py` script, it should be equal to `unbound.conf`, which was used as input parameter to `unb_to_json.py` script. |
|
\ No newline at end of file |
|
\ No newline at end of file |