Commit 7be6abb1 authored by Aleš Mrázek's avatar Aleš Mrázek
Browse files

deckard example

parent 235266c1
......@@ -4,6 +4,7 @@
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXPROJ = Resolvers-YANG
SOURCEDIR = .
BUILDDIR = _build
......
......@@ -40,7 +40,6 @@ release = '0.1'
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.todo',
]
# Add any paths that contain templates here, relative to this directory.
......@@ -64,7 +63,7 @@ language = None
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
# This pattern also affects html_static_path and html_extra_path .
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
# The name of the Pygments (syntax highlighting) style to use.
......@@ -157,27 +156,4 @@ texinfo_documents = [
]
# -- Options for Epub output -------------------------------------------------
# Bibliographic Dublin Core info.
epub_title = project
# The unique identifier of the text. This can be a ISBN number
# or the project homepage.
#
# epub_identifier = ''
# A unique identification for the text.
#
# epub_uid = ''
# A list of files that should not be packed into the epub file.
epub_exclude_files = ['search.html']
# -- Extension configuration -------------------------------------------------
# -- Options for todo extension ----------------------------------------------
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True
\ No newline at end of file
# -- Extension configuration -------------------------------------------------
\ No newline at end of file
.. Resolvers-YANG documentation master file, created by
sphinx-quickstart on Tue Aug 28 15:41:10 2018.
sphinx-quickstart on Tue Sep 4 15:42:13 2018.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
......
@ECHO OFF
pushd %~dp0
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build
if "%1" == "" goto help
%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
goto end
:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
:end
popd
YAM = ../yang-modules
YANGLIB = $(YAM)/yanglib.json
INST = example-data.json
.PHONY: validate
validate:
@yangson -p $(YAM) $(YANGLIB) -v $(INST)
YAM = ../../yang-modules
YANGLIB = $(YAM)/yanglib-deckard.json
INST = deckard-data.json
.PHONY: validate
validate:
@yangson -p $(YAM) $(YANGLIB) -v $(INST)
{
"cznic-deckard:deckard":{
"mock-data": "mock-data/iter_badglue.rpl"
},
"cznic-resolver-common:dns-resolver": {
"server": {
"user-name": "jetconf",
......@@ -73,3 +76,4 @@
}
}
}
import sys
from yangson.datamodel import DataModel
from resolvers_yang.generator import Generator
json_path = sys.argv[1]
# set file names and paths
yangdir = "../../yang-modules"
kresd_path = "kresd.conf"
unb_path = "unbound.rpl"
# load model
model = DataModel.from_file(yangdir + "/yanglib-deckard.json", [yangdir])
# create configuration generator for specific data model
conf_generator = Generator(model)
# load, validate data from json
conf_data = conf_generator.load_from_json(json_path)
# get path where is mock data located
mock_path = conf_data["cznic-deckard:deckard"]["mock-data"].value
# load text file from path as string
mock_data = open(mock_path).read()
# write configurations to files
unb_conf = conf_generator.unbound(conf_data)
kresd_conf = conf_generator.kresd(conf_data)
# write kresd.conf
knot_file = open(kresd_path, "w+")
knot_file.write(kresd_conf)
knot_file.close()
# write unbound.rpl
unb_file = open(unb_path, "w+")
unb_file.write(unb_conf + "\nCONFIG_END\n\n" + mock_data)
unb_file.close()
SCENARIO_BEGIN Test not using cached glue records
;root server
RANGE_BEGIN 0 100
ADDRESS 1.1.1.1
ENTRY_BEGIN
MATCH opcode qname qtype
ADJUST copy_id
REPLY QR RD NOERROR
SECTION QUESTION
. IN NS
SECTION ANSWER
. IN NS k.root-servers.net.
SECTION ADDITIONAL
k.root-servers.net. IN A 1.1.1.1
ENTRY_END
ENTRY_BEGIN
MATCH opcode subdomain
ADJUST copy_id copy_query
REPLY QR RD NOERROR
SECTION QUESTION
com. IN NS
SECTION AUTHORITY
com. IN NS ns.com.
SECTION ADDITIONAL
ns.com. IN A 2.2.2.2
ENTRY_END
ENTRY_BEGIN
MATCH opcode subdomain
ADJUST copy_id copy_query
REPLY QR RD NOERROR
SECTION QUESTION
net. IN NS
SECTION AUTHORITY
net. IN NS ns.net.
SECTION ADDITIONAL
ns.net IN A 3.3.3.3
ENTRY_END
RANGE_END
;ns.com.
RANGE_BEGIN 0 100
ADDRESS 2.2.2.2
ENTRY_BEGIN
MATCH opcode qname qtype
ADJUST copy_id
REPLY QR RD NOERROR
SECTION QUESTION
com. IN NS
SECTION ANSWER
com. IN NS ns.com.
SECTION ADDITIONAL
ns.com. IN A 2.2.2.2
ENTRY_END
ENTRY_BEGIN
MATCH opcode qname qtype
ADJUST copy_id
REPLY QR RD NOERROR
SECTION QUESTION
ns.com. IN A
SECTION ANSWER
ns.com. IN A 2.2.2.2
ENTRY_END
ENTRY_BEGIN
MATCH opcode qname qtype
ADJUST copy_id
REPLY QR RD NOERROR
SECTION QUESTION
ns.com. IN AAAA
SECTION AUTHORITY
com. IN SOA . . 1487352364 1800 900 604800 86400
ENTRY_END
ENTRY_BEGIN
MATCH opcode subdomain
ADJUST copy_id copy_query
REPLY QR RD NOERROR
SECTION QUESTION
a.com. IN NS
SECTION AUTHORITY
a.com. IN NS ns-a.net. ; out-of-bailwick nameservers
a.com. IN NS ns-obsolete.net.
SECTION ADDITIONAL
ns-a.net. IN A 4.4.4.4
ns-obsolete.net. IN A 6.6.6.6 ; dead address in glue records
ENTRY_END
RANGE_END
;ns.net.
RANGE_BEGIN 0 100
ADDRESS 3.3.3.3
ENTRY_BEGIN
MATCH opcode qname qtype
ADJUST copy_id
REPLY QR RD NOERROR
SECTION QUESTION
net. IN NS
SECTION ANSWER
net. IN NS ns.net.
SECTION ADDITIONAL
ns.net. IN A 3.3.3.3
ENTRY_END
ENTRY_BEGIN
MATCH opcode qname qtype
ADJUST copy_id
REPLY QR RD NOERROR
SECTION QUESTION
ns.net. IN A
SECTION ANSWER
ns.net. IN A 3.3.3.3
ENTRY_END
ENTRY_BEGIN
MATCH opcode qname qtype
ADJUST copy_id
REPLY QR RD NOERROR
SECTION QUESTION
ns.net. IN AAAA
SECTION AUTHORITY
net. IN SOA . . 1487352364 1800 900 604800 86400
ENTRY_END
ENTRY_BEGIN
MATCH opcode qname
ADJUST copy_id copy_query
REPLY QR RD NOERROR
SECTION QUESTION
root-servers.net. IN A
SECTION AUTHORITY
net. 900 IN SOA . . 1487352364 1800 900 604800 86400
ENTRY_END
ENTRY_BEGIN
MATCH opcode qtype qname
ADJUST copy_id
REPLY QR RD NOERROR
SECTION QUESTION
k.root-servers.net. IN A
SECTION ANSWER
ns-a.net. IN A 1.1.1.1
ENTRY_END
ENTRY_BEGIN
MATCH opcode qtype qname
ADJUST copy_id
REPLY QR RD NOERROR
SECTION QUESTION
k.root-servers.net. IN AAAA
SECTION AUTHORITY
net. 900 IN SOA . . 1487352364 1800 900 604800 86400
ENTRY_END
ENTRY_BEGIN
MATCH opcode qtype qname
ADJUST copy_id
REPLY QR RD NOERROR
SECTION QUESTION
ns-a.net. IN A
SECTION ANSWER
ns-a.net. IN A 4.4.4.4
ENTRY_END
ENTRY_BEGIN
MATCH opcode qtype qname
ADJUST copy_id
REPLY QR RD NOERROR
SECTION QUESTION
ns-obsolete.net. IN A
SECTION ANSWER
ns-obsolete.net. IN A 9.9.9.9 ; working address
ENTRY_END
; no IPv6
ENTRY_BEGIN
MATCH opcode qtype qname
ADJUST copy_id
REPLY QR RD NOERROR
SECTION QUESTION
ns-a.net. IN AAAA
SECTION AUTHORITY
net. 900 IN SOA . . 1487352364 1800 900 604800 86400
ENTRY_END
ENTRY_BEGIN
MATCH opcode qtype qname
ADJUST copy_id
REPLY QR RD NOERROR
SECTION QUESTION
ns-obsolete.net. IN AAAA
SECTION AUTHORITY
net. 900 IN SOA . . 1487352364 1800 900 604800 86400
ENTRY_END
RANGE_END
;ns-a.net
RANGE_BEGIN 0 100
ADDRESS 4.4.4.4
ADDRESS 9.9.9.9
ENTRY_BEGIN
MATCH opcode qname qtype
ADJUST copy_id
REPLY QR RD NOERROR
SECTION QUESTION
a.com. IN NS
SECTION ANSWER
a.com. IN NS ns-a.net. ; out-of-bailwick nameservers
a.com. IN NS ns-obsolete.net.
SECTION ADDITIONAL
ns-a.net. IN A 4.4.4.4
ns-obsolete.net. IN A 9.9.9.9 ; the new (functional) address
ENTRY_END
ENTRY_BEGIN
MATCH opcode qtype qname
ADJUST copy_id
REPLY QR RD NOERROR
SECTION QUESTION
; phony target used to pollute resolver's cache
www.a.com. IN A
SECTION ANSWER
www.a.com. IN A 5.5.5.5
ENTRY_END
RANGE_END
; ask for phony target to pollute resolver's cache
STEP 1 QUERY
ENTRY_BEGIN
REPLY RD
SECTION QUESTION
www.a.com. IN A
ENTRY_END
; we don't actually care about this answer
STEP 2 CHECK_ANSWER
ENTRY_BEGIN
MATCH all
REPLY QR RD RA NOERROR
SECTION QUESTION
www.a.com. IN A
SECTION ANSWER
www.a.com. IN A 5.5.5.5
ENTRY_END
; check if obsolete data from glue records is returned to the client
STEP 3 QUERY
ENTRY_BEGIN
REPLY RD
SECTION QUESTION
ns-obsolete.net. IN A
ENTRY_END
STEP 4 CHECK_ANSWER
ENTRY_BEGIN
MATCH all
REPLY QR RD RA NOERROR
SECTION QUESTION
ns-obsolete.net. IN A
SECTION ANSWER
ns-obsolete.net. IN A 9.9.9.9 ; 6.6.6.6 should not be here
ENTRY_END
SCENARIO_END
......@@ -2,12 +2,15 @@ import sys
from yangson.datamodel import DataModel
from resolvers_yang.generator import Generator
json_path = sys.argv[1]
yangdir = "../yang-modules"
kresd_path = "kresd.conf"
unb_path = "unbound.conf"
# load data model
model = DataModel.from_file(yangdir + "/yanglib-complete.json", [yangdir])
json_path = sys.argv[1]
# create configuration generator for specific data model
conf_generator = Generator(model)
......
......@@ -4,6 +4,7 @@ from socket import gethostbyname
from yangson import DataModel
from pathlib import Path
ip_address = compile('^((\d{1,3}\.){3}\d{1,3})|(([\dA-Fa-f]{1,4})|(:)|(:[\dA-Fa-f]{1,4})){2,7}[\dA-Fa-f]$')
......@@ -45,8 +46,6 @@ class Generator:
# Function for generate Unbound configuration string
def unbound(self, data: dict):
# Create clear configuration file
unbound_conf = ""
server = "server:\n"
stub = ""
......
{
"ietf-yang-library:modules-state": {
"module-set-id": "e595da11ace92c0d881995fa7e56bbe86f1f48e9",
"module": [
{
"name": "cznic-dns-types",
"revision": "2018-05-14",
"namespace": "https://www.nic.cz/ns/yang/dns-types",
"conformance-type": "implement",
"schema": "https://gitlab.labs.nic.cz/jetconf/jetconf-resolver/blob/master/yang-modules/cznic-dns-types.yang"
},
{
"name": "cznic-resolver-common",
"revision": "2018-07-27",
"feature": [
"set-group"
],
"namespace": "https://www.nic.cz/ns/yang/resolver-common",
"conformance-type": "implement"
},
{
"name": "cznic-resolver-knot",
"revision": "2018-07-27",
"namespace": "https://www.nic.cz/ns/yang/resolver-knot",
"conformance-type": "implement"
},
{
"name": "ietf-inet-types",
"revision": "2013-07-15",
"namespace": "urn:ietf:params:xml:ns:yang:ietf-inet-types",
"conformance-type": "import",
"schema": "https://raw.githubusercontent.com/YangModels/yang/master/standard/ietf/RFC/ietf-inet-types.yang"
},
{
"name": "ietf-yang-library",
"revision": "2016-06-21",
"namespace": "urn:ietf:params:xml:ns:yang:ietf-yang-library",
"conformance-type": "implement"
},
{
"name": "ietf-yang-types",
"revision": "2013-07-15",
"namespace": "urn:ietf:params:xml:ns:yang:ietf-yang-types",
"conformance-type": "import",
"schema": "https://github.com/YangModels/yang/blob/master/standard/ietf/RFC/ietf-yang-types.yang"
}
]
}
}
\ No newline at end of file
{
"ietf-yang-library:modules-state": {
"module-set-id": "9f7fa244bfe2206e5ee8286174eba3715dec84fb",
"module-set-id": "e595da11ace92c0d881995fa7e56bbe86f1f48e9",
"module": [
{
"name": "cznic-dns-types",
"revision": "2018-05-14",
"namespace": "https://www.nic.cz/ns/yang/dns-types",
"conformance-type": "implement",
"schema": "https://gitlab.labs.nic.cz/jetconf/jetconf-resolver/blob/master/yang-modules/cznic-dns-types.yang"
},
{
"name": "cznic-resolver-common",
"revision": "2018-07-27",
......@@ -17,17 +24,25 @@
"namespace": "https://www.nic.cz/ns/yang/deckard",
"conformance-type": "implement"
},
{
"name": "cznic-dns-types",
"revision": "2018-05-14",
"namespace": "https://www.nic.cz/ns/yang/dns-types",
"conformance-type": "implement"
},
{
"name": "ietf-inet-types",
"revision": "2013-07-15",
"namespace": "urn:ietf:params:xml:ns:yang:ietf-inet-types",
"conformance-type": "import",
"schema": "https://raw.githubusercontent.com/YangModels/yang/master/standard/ietf/RFC/ietf-inet-types.yang"
},
{
"name": "ietf-yang-library",
"revision": "2016-06-21",
"namespace": "urn:ietf:params:xml:ns:yang:ietf-yang-library",
"conformance-type": "implement"
},
{
"name": "ietf-yang-types",
"revision": "2013-07-15",
"namespace": "urn:ietf:params:xml:ns:yang:ietf-yang-types",
"conformance-type": "import",
"schema": "https://github.com/YangModels/yang/blob/master/standard/ietf/RFC/ietf-yang-types.yang"
}
]
}
......
{
"ietf-yang-library:modules-state": {
"module-set-id": "9f7fa244bfe2206e5ee8286174eba3715dec84fb",
"module-set-id": "e595da11ace92c0d881995fa7e56bbe86f1f48e9",
"module": [
{
"name": "cznic-dns-types",
"revision": "2018-05-14",
"namespace": "https://www.nic.cz/ns/yang/dns-types",
"conformance-type": "implement",
"schema": "https://gitlab.labs.nic.cz/jetconf/jetconf-resolver/blob/master/yang-modules/cznic-dns-types.yang"
},
{
"name": "cznic-resolver-common",
"revision": "2018-07-27",
......@@ -12,17 +19,31 @@
"conformance-type": "implement"
},
{
"name": "cznic-dns-types",
"revision": "2018-05-14",
"namespace": "https://www.nic.cz/ns/yang/dns-types",
"name": "cznic-resolver-knot",
"revision": "2018-07-27",
"namespace": "https://www.nic.cz/ns/yang/resolver-knot",
"conformance-type": "implement"
},
{
"name": "ietf-inet-types",
"revision": "2013-07-15",
"namespace": "urn:ietf:params:xml:ns:yang:ietf-inet-types",
"conformance-type": "import",
"schema": "https://raw.githubusercontent.com/YangModels/yang/master/standard/ietf/RFC/ietf-inet-types.yang"
},
{
"name": "ietf-yang-library",
"revision": "2016-06-21",
"namespace": "urn:ietf:params:xml:ns:yang:ietf-yang-library",
"conformance-type": "implement"
},
{
"name": "ietf-yang-types",
"revision": "2013-07-15",
"namespace": "urn:ietf:params:xml:ns:yang:ietf-yang-types",
"conformance-type": "import",
"schema": "https://github.com/YangModels/yang/blob/master/standard/ietf/RFC/ietf-yang-types.yang"
}
]
}
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment