summaryrefslogtreecommitdiff
path: root/src/op_mode/dhcp.py
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-08-05 09:02:16 +0200
committerChristian Breunig <christian@breunig.cc>2023-08-05 09:28:03 +0200
commit6fbce6b6fe495268f896f95fea1a0837367c664a (patch)
treec41960ce21bd40151fcf7eda6b3c6308f48b1f5a /src/op_mode/dhcp.py
parent96132f582ef698b84d08e5ff207e508ed0f9c5f7 (diff)
downloadvyos-1x-6fbce6b6fe495268f896f95fea1a0837367c664a.tar.gz
vyos-1x-6fbce6b6fe495268f896f95fea1a0837367c664a.zip
T3355: provide VRF for DHCP client leases
Diffstat (limited to 'src/op_mode/dhcp.py')
-rwxr-xr-xsrc/op_mode/dhcp.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/op_mode/dhcp.py b/src/op_mode/dhcp.py
index 544156e1c..f558c18b7 100755
--- a/src/op_mode/dhcp.py
+++ b/src/op_mode/dhcp.py
@@ -296,6 +296,7 @@ def _get_raw_client_leases(family='inet', interface=None):
from time import mktime
from datetime import datetime
from vyos.defaults import directories
+ from vyos.utils.network import get_interface_vrf
lease_dir = directories['isc_dhclient_dir']
lease_files = []
@@ -325,6 +326,10 @@ def _get_raw_client_leases(family='inet', interface=None):
k, v = line.split('=')
tmp.update({k : v.replace("'", "")})
+ if 'interface' in tmp:
+ vrf = get_interface_vrf(tmp['interface'])
+ if vrf: tmp.update({'vrf' : vrf})
+
lease_data.append(tmp)
return lease_data
@@ -353,6 +358,8 @@ def _get_formatted_client_leases(lease_data, family):
data_entries.append(["DHCP Server", lease['new_dhcp_server_identifier']])
if 'new_dhcp_lease_time' in lease:
data_entries.append(["DHCP Server", lease['new_dhcp_lease_time']])
+ if 'vrf' in lease:
+ data_entries.append(["VRF", lease['vrf']])
if 'last_update' in lease:
tmp = strftime(time_string, localtime(int(lease['last_update'])))
data_entries.append(["Last Update", tmp])