From 8e0a54676ff2ac90b7c24e4f05b05bcebc584bd3 Mon Sep 17 00:00:00 2001 From: sarthurdev <965089+sarthurdev@users.noreply.github.com> Date: Sun, 17 Dec 2023 01:25:22 +0100 Subject: dhcp: T3316: Kea DHCP and DHCPv6 fixes * Move Kea socket permission change on-demand and speed up conf scripts * Fix issue with DHCP reservations when no `ip-address` value --- python/vyos/kea.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'python/vyos/kea.py') diff --git a/python/vyos/kea.py b/python/vyos/kea.py index cb341e0f2..4a517da5f 100644 --- a/python/vyos/kea.py +++ b/python/vyos/kea.py @@ -23,7 +23,9 @@ from vyos.template import is_ipv6 from vyos.template import isc_static_route 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.file import read_file +from vyos.utils.process import cmd kea4_options = { 'name_server': 'domain-name-servers', @@ -119,10 +121,14 @@ def kea_parse_subnet(subnet, config): if 'disable' in host_config: continue - reservations.append({ - 'hw-address': host_config['mac_address'], - 'ip-address': host_config['ip_address'] - }) + obj = { + 'hw-address': host_config['mac_address'] + } + + if 'ip_address' in host_config: + obj['ip-address'] = host_config['ip_address'] + + reservations.append(obj) out['reservations'] = reservations unifi_controller = dict_search_args(config, 'vendor_option', 'ubiquiti', 'unifi_controller') @@ -275,6 +281,9 @@ def _ctrl_socket_command(path, command, args=None): if not os.path.exists(path): return None + if file_permissions(path) != '0775': + cmd(f'sudo chmod 775 {path}') + with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as sock: sock.connect(path) -- cgit v1.2.3