|
|
# Examples |
|
|
\ No newline at end of file |
|
|
# Examples
|
|
|
|
|
|
The recommended way is to use a Python virtual environment ([installation instructions](https://gitlab.labs.nic.cz/jetconf/jetconf-resolver/wikis/devinstall))
|
|
|
|
|
|
**JetConf-Resolver** must be installed.
|
|
|
|
|
|
```bash
|
|
|
$ git clone https://gitlab.labs.nic.cz/jetconf/jetconf-resolver
|
|
|
$ cd jetconf-resolver
|
|
|
$ python3 setup.py install
|
|
|
```
|
|
|
|
|
|
|
|
|
## JSON Data Validation
|
|
|
|
|
|
**Data Model**
|
|
|
* 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.
|
|
|
Validate the JSON data against the data model:
|
|
|
```bash
|
|
|
(jetconf-resolver) $ make validate
|
|
|
```
|
|
|
No output means that the JSON data in `example-data.json` is valid.
|
|
|
|
|
|
## Generate configuration from Json file
|
|
|
|
|
|
This will generate `unbound.conf` and `kresd.conf` files in local files.
|
|
|
|
|
|
Go to `examples/` directory
|
|
|
Run `genconf.py` script with path to Json file as parameter
|
|
|
```bash
|
|
|
(jetconf-resolver) $ python genconf.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`genconf.py` script because the configuration designed to [Knot Resolver](https://gitlab.labs.nic.cz/jetconf/jetconf-resolver/raw/master/yang-modules/cznic-resolver-knot@2018-07-27.yang) is ignored for Unbound.
|
|
|
|
|
|
## Convert unbound.conf to json file
|
|
|
This will convert `unbound.conf` to valid `unb-data.json`
|
|
|
|
|
|
Go to `tests/unbound-json` directory.
|
|
|
```bash
|
|
|
(jetconf-resolver) $ cd tests/unbound-json
|
|
|
```
|
|
|
|
|
|
As example configuration file can be used `../complete/unbound.conf` after running `genconf.py`
|
|
|
|
|
|
Run `convert.py` with path to `unbound.conf` as parameter.
|
|
|
```bash
|
|
|
(jetconf-resolver) $ python convert.py ../complete/unbound.conf
|
|
|
```
|
|
|
No output means that the JSON data in `unb-data.json` is valid.
|
|
|
|
|
|
If you generate another `unbound2.conf` from this Json, it should be equal to `unbound.conf` which was used as input parameter to `convert.py` script. |
|
|
\ No newline at end of file |