sonic-buildimage/dockers/docker-dhcp-server/kea-dhcp4.conf.j2
Yaqiang Zhu 3223ca0156
[dhcp_server] Add config_db monitor and customize options for dhcpservd (#17051)
Why I did it
Add config_db monitor and customize options for dhcpservd. HLD: sonic-net/SONiC#1282

Work item tracking
Microsoft ADO (number only): 25600859
How I did it
Add support to customize unassigned DHCP options. Current support type: binary, boolean, ipv4-address, string, uint8, uint16, uint32
Add db config change monitor for dhcpservd
How to verify it
Unit tests in sonic-dhcp-server all passed
2023-11-16 08:56:50 -08:00

106 lines
3.6 KiB
Django/Jinja

{%- set default_lease_time = 900 -%}
{
"Dhcp4": {
{%- if customized_options %}
"option-def": [
{%- for option_name, config in customized_options.items() %}
{
"name": "{{ option_name }}",
"code": {{ config["id"] }},
"type": "{{ config["type"] }}"
}{% if not loop.last %},{% endif %}
{%- endfor %}
],
{%- endif %}
"hooks-libraries": [
{
"library": "/usr/local/lib/kea/hooks/libdhcp_run_script.so",
"parameters": {
"name": "{{ lease_update_script_path }}",
"sync": false
}
}
],
"interfaces-config": {
"interfaces": [
"eth0"
]
},
"control-socket": {
"socket-type": "unix",
"socket-name": "/run/kea/kea4-ctrl-socket"
},
"lease-database": {
"type": "memfile",
"persist": true,
"name": "{{ lease_path }}",
"lfc-interval": 3600
},
"subnet4": [
{%- set add_subnet_preceding_comma = { 'flag': False } %}
{%- for subnet_info in subnets %}
{%- if add_subnet_preceding_comma.flag -%},{%- endif -%}
{%- set _dummy = add_subnet_preceding_comma.update({'flag': True}) %}
{
"subnet": "{{ subnet_info["subnet"] }}",
"pools": [
{%- set add_pool_preceding_comma = { 'flag': False } %}
{%- for pool in subnet_info["pools"] %}
{%- if add_pool_preceding_comma.flag -%},{%- endif -%}
{%- set _dummy = add_pool_preceding_comma.update({'flag': True}) %}
{
"pool": "{{ pool["range"] }}",
"client-class": "{{ pool["client_class"] }}"
}
{%- endfor%}
],
"option-data": [
{%- for option_name, config in subnet_info["customized_options"].items() %}
{
"name": "{{ option_name }}",
"data": "{{ config["value"] }}",
"always-send": {{ config["always_send"] }}
},
{%- endfor %}
{
"name": "routers",
"data": "{{ subnet_info["gateway"] if "gateway" in subnet_info else subnet_info["server_id"] }}"
},
{
"name": "dhcp-server-identifier",
"data": "{{ subnet_info["server_id"] }}"
}
],
"valid-lifetime": {{ subnet_info["lease_time"] if "lease_time" in subnet_info else default_lease_time }},
"reservations": []
}
{%- endfor %}
],
"loggers": [
{
"name": "kea-dhcp4",
"output_options": [
{
"output": "/var/log/kea-dhcp.log",
"pattern": "%-5p %m\n"
}
],
"severity": "INFO",
"debuglevel": 0
}
]{%- if client_classes -%},
"client-classes": [
{%- set add_preceding_comma = { 'flag': False } %}
{%- for class in client_classes %}
{%- if add_preceding_comma.flag -%},{%- endif -%}
{%- set _dummy = add_preceding_comma.update({'flag': True}) %}
{
"name": "{{ class["name"] }}",
"test": "{{ class["condition"] }}"
}
{%- endfor %}
]
{%- endif %}
}
}