summaryrefslogtreecommitdiff
path: root/src/op_mode
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-12-31 07:28:57 +0100
committerGitHub <noreply@github.com>2023-12-31 07:28:57 +0100
commit2286b8600da6c631b17e1d5b9b341843e50f9abf (patch)
treee2032793be5a755c0e2c1c1317948ff6d244f30a /src/op_mode
parent14dc8a8962f0a52107913423a750f36ed8e45160 (diff)
parent3192095a197ae8d74690ab5c676e6a5fabae7fae (diff)
downloadvyos-1x-2286b8600da6c631b17e1d5b9b341843e50f9abf.tar.gz
vyos-1x-2286b8600da6c631b17e1d5b9b341843e50f9abf.zip
Merge pull request #2696 from indrajitr/kea-lfc-fix
dhcp: T3316: Adjust kea lease files' location and permissions
Diffstat (limited to 'src/op_mode')
-rwxr-xr-xsrc/op_mode/clear_dhcp_lease.py3
-rwxr-xr-xsrc/op_mode/dhcp.py9
2 files changed, 4 insertions, 8 deletions
diff --git a/src/op_mode/clear_dhcp_lease.py b/src/op_mode/clear_dhcp_lease.py
index 2c95a2b08..7d4b47104 100755
--- a/src/op_mode/clear_dhcp_lease.py
+++ b/src/op_mode/clear_dhcp_lease.py
@@ -28,7 +28,7 @@ from vyos.utils.commit import commit_in_progress
config = ConfigTreeQuery()
base = ['service', 'dhcp-server']
-lease_file = '/config/dhcp4.leases'
+lease_file = '/config/dhcp/dhcp4-leases.csv'
def del_lease_ip(address):
@@ -52,7 +52,6 @@ def is_ip_in_leases(address):
Return True if address found in the lease file
"""
leases = kea_parse_leases(lease_file)
- lease_ips = []
for lease in leases:
if address == lease['address']:
return True
diff --git a/src/op_mode/dhcp.py b/src/op_mode/dhcp.py
index a9271ea79..02f4d5bbb 100755
--- a/src/op_mode/dhcp.py
+++ b/src/op_mode/dhcp.py
@@ -31,9 +31,6 @@ from vyos.configquery import ConfigTreeQuery
from vyos.kea import kea_get_active_config
from vyos.kea import kea_get_pool_from_subnet_id
from vyos.kea import kea_parse_leases
-from vyos.utils.dict import dict_search
-from vyos.utils.file import read_file
-from vyos.utils.process import cmd
from vyos.utils.process import is_systemd_service_running
time_string = "%a %b %d %H:%M:%S %Z %Y"
@@ -79,8 +76,8 @@ def _get_raw_server_leases(family='inet', pool=None, sorted=None, state=[], orig
Get DHCP server leases
:return list
"""
- lease_file = '/config/dhcp6.leases' if family == 'inet6' else '/config/dhcp4.leases'
- data = []
+ inet_suffix = '6' if family == 'inet6' else '4'
+ lease_file = f'/config/dhcp/dhcp{inet_suffix}-leases.csv'
leases = kea_parse_leases(lease_file)
if pool is None:
@@ -88,9 +85,9 @@ def _get_raw_server_leases(family='inet', pool=None, sorted=None, state=[], orig
else:
pool = [pool]
- inet_suffix = '6' if family == 'inet6' else '4'
active_config = kea_get_active_config(inet_suffix)
+ data = []
for lease in leases:
data_lease = {}
data_lease['ip'] = lease['address']