Skip to content
Snippets Groups Projects
Commit eaab83e8 authored by Aleš Mrázek's avatar Aleš Mrázek
Browse files

manager: datamodel: local-data template and macros

parent 64925df5
Branches
Tags
1 merge request!1313manager: datamodel improvements
......@@ -24,6 +24,13 @@ views:
answer: allow
local-data:
ttl: 60m
nodata: false
records: |
example.net. TXT "foo bar"
A 192.168.2.3
A 192.168.2.4
local.example.org AAAA ::1
subtrees:
- type: empty
tags: [ t2 ]
......
{% if not cfg.lua.script_only %}
-- FFI library
local C = require('ffi').C
ffi = require('ffi')
local C = ffi.C
-- hostname
hostname('{{ cfg.hostname }}')
......
{% from 'macros/local_data_macros.lua.j2' import local_data_subtree_root %}
{% from 'macros/local_data_macros.lua.j2' import local_data_subtree_root, local_data_records %}
{# TODO: implemented all other options/features from local_data_schema #}
{# records #}
{% if cfg.local_data.records -%}
{{ local_data_records(cfg.local_data.records, false, cfg.local_data.ttl, cfg.local_data.nodata) }}
{%- endif %}
{# subtrees #}
{% if cfg.local_data.subtrees -%}
{% for subtree in cfg.local_data.subtrees %}
......
{% from 'macros/common_macros.lua.j2' import string_table %}
{% from 'macros/common_macros.lua.j2' import string_table, boolean %}
{% from 'macros/policy_macros.lua.j2' import policy_get_tagset, policy_todname %}
{% macro local_data_records(input_str, is_rpz, ttl, nodata) -%}
rrs = ffi.new('struct kr_rule_zonefile_config')
{% if ttl %}
rrs.ttl = {{ ttl.millis() }}
{% endif %}
rrs.nodata = {{ boolean(nodata) }}
rrs.is_rpz = {{ boolean(is_rpz) }}
{% if is_rpz -%}
rrs.filename = '{{ input_str }}'
{% else %}
rrs.input_str = [[
{{ input_str }}]]
{% endif %}
assert(C.kr_rule_zonefile(rrs)==0)
{%- endmacro %}
{% macro local_data_emptyzone(dname, tags) -%}
assert(C.kr_rule_local_data_emptyzone({{ dname }},{{ tags }})==0)
{%- endmacro %}
......
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