73dd38a5ce
Why I did it Part implementation of dhcp_server. HLD: sonic-net/SONiC#1282. Add dhcpservd to dhcp_server container. How I did it Add installing required pkg (psutil) in Dockerfile. Add copying required file to container in Dockerfile (kea-dhcp related and dhcpservd related) Add critical_process and supervisor config. Add support for generating kea config (only in dhcpservd.py) and updating lease table (in dhcpservd.py and lease_update.sh) How to verify it Build image with setting INCLUDE_DHCP_SERVER to y and enabled dhcp_server feature after installed image, container start as expected. Enter container and found that all processes defined in supervisor configuration running as expected. Kill processes defined in critical_processes, container exist.
88 lines
3.0 KiB
Django/Jinja
88 lines
3.0 KiB
Django/Jinja
{%- set default_lease_time = 900 -%}
|
|
{
|
|
"Dhcp4": {
|
|
"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": [
|
|
{
|
|
"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 %}
|
|
}
|
|
}
|