summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorIndrajit Raychaudhuri <irc@indrajit.com>2026-05-14 06:39:39 -0500
committerGitHub <noreply@github.com>2026-05-14 14:39:39 +0300
commita4cf50f68bdcfd14cfcb51b2ff3f4058c1a0f5c6 (patch)
tree8a7c41c820b0e88d15e417b0df70f7f96ce3dfac /python
parent080557810cf5e4c50852129156b10bcdcfbc7988 (diff)
downloadvyos-1x-a4cf50f68bdcfd14cfcb51b2ff3f4058c1a0f5c6.tar.gz
vyos-1x-a4cf50f68bdcfd14cfcb51b2ff3f4058c1a0f5c6.zip
dhcpv6: T8849: Add time-zone support for Kea DHCPv6 (#5190)
* dhcpv6: T8849: Add time-zone support for Kea DHCPv6 Add DHCPv6 option support for time zone (RFC4833 options 41 and 42). This includes both the POSIX-style TZ string (`new-posix-timezone`) and the IANA time zone name (`new-tzdb-timezone`). * dhcpv6: T8849: Refactor per code-review suggestion * dhcpv6: T8849: Reformat for compliance
Diffstat (limited to 'python')
-rw-r--r--python/vyos/kea.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/python/vyos/kea.py b/python/vyos/kea.py
index 74ffa3fb1..068e2cf7a 100644
--- a/python/vyos/kea.py
+++ b/python/vyos/kea.py
@@ -89,6 +89,14 @@ def _find_list_of_dict_index(lst, key='ip', value=''):
return idx
+def _read_posix_timezone(tz_name):
+ try:
+ with open(f'/usr/share/zoneinfo/{tz_name}', 'rb') as f:
+ return f.read().split(b'\n')[-2].decode('utf-8').replace(',', '\\,')
+ except (FileNotFoundError, IOError, IndexError) as e:
+ raise ConfigError(f'Failed to read timezone data for: {tz_name}') from e
+
+
def kea_test_config(process: str, config_path: str) -> tuple[bool, str]:
result, output = rc_cmd(f'{process} -t {config_path}')
@@ -143,9 +151,7 @@ def kea_parse_options(config):
)
if 'time_zone' in config:
- with open('/usr/share/zoneinfo/' + config['time_zone'], 'rb') as f:
- tz_string = f.read().split(b'\n')[-2].decode('utf-8').replace(',', '\\,')
-
+ tz_string = _read_posix_timezone(config['time_zone'])
options.append({'name': 'pcode', 'data': tz_string})
options.append({'name': 'tcode', 'data': config['time_zone']})
@@ -289,6 +295,11 @@ def kea6_parse_options(config):
if hosts:
options.append({'name': 'sip-server-dns', 'data': ', '.join(hosts)})
+ if 'time_zone' in config:
+ tz_string = _read_posix_timezone(config['time_zone'])
+ options.append({'name': 'new-posix-timezone', 'data': tz_string})
+ options.append({'name': 'new-tzdb-timezone', 'data': config['time_zone']})
+
cisco_tftp = dict_search_args(config, 'vendor_option', 'cisco', 'tftp-server')
if cisco_tftp:
options.append(