summaryrefslogtreecommitdiff
path: root/python/vyos
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-08-04 20:12:23 +0200
committerChristian Breunig <christian@breunig.cc>2023-08-04 20:12:23 +0200
commit292b064d743522d11179bd3cd91a08731380f3a9 (patch)
tree37928a579f4624a447ad46277e43e966f03881ae /python/vyos
parent3aac2941efc473c5d52cf9271d778bd51a72dfc7 (diff)
downloadvyos-1x-292b064d743522d11179bd3cd91a08731380f3a9.tar.gz
vyos-1x-292b064d743522d11179bd3cd91a08731380f3a9.zip
dhcp: T5428: provide common direcotry path via vyos.defaults.directories
Multiple scripts use the same hardcoded path for DHCP client leases in different direcotries - this can't be worse.
Diffstat (limited to 'python/vyos')
-rw-r--r--python/vyos/defaults.py3
-rw-r--r--python/vyos/ifconfig/interface.py3
-rw-r--r--python/vyos/template.py2
3 files changed, 5 insertions, 3 deletions
diff --git a/python/vyos/defaults.py b/python/vyos/defaults.py
index d4ffc249e..cb3e9b654 100644
--- a/python/vyos/defaults.py
+++ b/python/vyos/defaults.py
@@ -32,7 +32,8 @@ directories = {
'api_schema': f'{base_dir}/services/api/graphql/graphql/schema/',
'api_client_op': f'{base_dir}/services/api/graphql/graphql/client_op/',
'api_templates': f'{base_dir}/services/api/graphql/session/templates/',
- 'vyos_udev_dir' : '/run/udev/vyos'
+ 'vyos_udev_dir' : '/run/udev/vyos',
+ 'isc_dhclient_dir' : '/run/dhclient'
}
config_status = '/tmp/vyos-config-status'
diff --git a/python/vyos/ifconfig/interface.py b/python/vyos/ifconfig/interface.py
index 99ddb2021..fe8752d24 100644
--- a/python/vyos/ifconfig/interface.py
+++ b/python/vyos/ifconfig/interface.py
@@ -31,6 +31,7 @@ from vyos import ConfigError
from vyos.configdict import list_diff
from vyos.configdict import dict_merge
from vyos.configdict import get_vlan_ids
+from vyos.defaults import directories
from vyos.template import render
from vyos.utils.network import mac2eui64
from vyos.utils.dict import dict_search
@@ -1240,7 +1241,7 @@ class Interface(Control):
raise ValueError()
ifname = self.ifname
- config_base = r'/var/lib/dhcp/dhclient'
+ config_base = directories['isc_dhclient_dir'] + '/dhclient'
config_file = f'{config_base}_{ifname}.conf'
options_file = f'{config_base}_{ifname}.options'
pid_file = f'{config_base}_{ifname}.pid'
diff --git a/python/vyos/template.py b/python/vyos/template.py
index 7d1c3970f..6469623fd 100644
--- a/python/vyos/template.py
+++ b/python/vyos/template.py
@@ -420,7 +420,7 @@ def get_dhcp_router(interface):
Returns False of no router is found, returns the IP address as string if
a router is found.
"""
- lease_file = f'/var/lib/dhcp/dhclient_{interface}.leases'
+ lease_file = directories['isc_dhclient_dir'] + f'/dhclient_{interface}.leases'
if not os.path.exists(lease_file):
return None