diff options
| author | sarthurdev <965089+sarthurdev@users.noreply.github.com> | 2025-10-11 20:59:14 +0200 |
|---|---|---|
| committer | sarthurdev <965089+sarthurdev@users.noreply.github.com> | 2025-10-17 01:03:10 +0200 |
| commit | dd3918ae34a2fb60893874a9141016ee5b5f32c0 (patch) | |
| tree | 6c9f421277365cf742c194cde7ea4b52627cb4e6 /python | |
| parent | 69a9b93f71c818bf134ea06ad73d86a513628f06 (diff) | |
| download | vyos-1x-dd3918ae34a2fb60893874a9141016ee5b5f32c0.tar.gz vyos-1x-dd3918ae34a2fb60893874a9141016ee5b5f32c0.zip | |
kea: T7925: Improve error handling, validate IPv6 PD prefix length
Diffstat (limited to 'python')
| -rw-r--r-- | python/vyos/kea.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/python/vyos/kea.py b/python/vyos/kea.py index 5ce6f47f1..f48cf293d 100644 --- a/python/vyos/kea.py +++ b/python/vyos/kea.py @@ -15,6 +15,7 @@ import json import os +import re import socket from datetime import datetime @@ -25,7 +26,7 @@ from vyos.template import is_ipv6 from vyos.template import netmask_from_cidr from vyos.utils.dict import dict_search_args from vyos.utils.file import file_permissions -from vyos.utils.process import run +from vyos.utils.process import run, rc_cmd kea4_options = { 'name_server': 'domain-name-servers', @@ -86,6 +87,14 @@ def _find_list_of_dict_index(lst, key='ip', value=''): idx = next((index for (index, d) in enumerate(lst) if d[key] == value), None) return idx +def kea_test_config(process: str, config_path: str) -> tuple[bool, str]: + result, output = rc_cmd(f'{process} -t {config_path}') + + if result == 0: + return (True, None) + + find = re.search(r'Error encountered:\s([^\n$]+)', output) + return (False, find[1] if find else None) def kea_parse_options(config): options = [] |
