summaryrefslogtreecommitdiff
path: root/src/conf_mode/dhcp_server.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-04-12 14:11:29 +0200
committerChristian Poessinger <christian@poessinger.com>2020-04-12 21:34:57 +0200
commitf371946044696737d1649d9119665b96430d2328 (patch)
tree75970b3406c035cee7035d131f9c89d7ebefe4cb /src/conf_mode/dhcp_server.py
parent152a147c3a34eb4444fe1879962c8b53e2e58835 (diff)
downloadvyos-1x-f371946044696737d1649d9119665b96430d2328.tar.gz
vyos-1x-f371946044696737d1649d9119665b96430d2328.zip
dhcp-server: T2185: migrate from SysVinit to systemd
Diffstat (limited to 'src/conf_mode/dhcp_server.py')
-rwxr-xr-xsrc/conf_mode/dhcp_server.py23
1 files changed, 5 insertions, 18 deletions
diff --git a/src/conf_mode/dhcp_server.py b/src/conf_mode/dhcp_server.py
index 13304bf19..59de9913c 100755
--- a/src/conf_mode/dhcp_server.py
+++ b/src/conf_mode/dhcp_server.py
@@ -27,14 +27,9 @@ from vyos import ConfigError
from vyos.util import call
from vyos.template import render
-
-config_file = r'/etc/dhcp/dhcpd.conf'
-lease_file = r'/config/dhcpd.leases'
-pid_file = r'/var/run/dhcpd.pid'
-daemon_config_file = r'/etc/default/isc-dhcpv4-server'
+config_file = r'/run/dhcp-server/dhcpd.conf'
default_config_data = {
- 'lease_file': lease_file,
'disabled': False,
'ddns_enable': False,
'global_parameters': [],
@@ -596,7 +591,7 @@ def verify(dhcp):
return None
def generate(dhcp):
- if dhcp is None:
+ if not dhcp:
return None
if dhcp['disabled'] is True:
@@ -607,24 +602,16 @@ def generate(dhcp):
# we can pass to ISC DHCPd
render(config_file, 'dhcp-server/dhcpd.conf.tmpl', dhcp,
formater=lambda _: _.replace("&quot;", '"'))
- render(daemon_config_file, 'dhcp-server/daemon.tmpl', dhcp)
return None
def apply(dhcp):
- if (dhcp is None) or dhcp['disabled']:
+ if not dhcp or dhcp['disabled']:
# DHCP server is removed in the commit
- call('sudo systemctl stop isc-dhcpv4-server.service')
+ call('sudo systemctl stop isc-dhcp-server.service')
if os.path.exists(config_file):
os.unlink(config_file)
- if os.path.exists(daemon_config_file):
- os.unlink(daemon_config_file)
- else:
- # If our file holding DHCP leases does yet not exist - create it
- if not os.path.exists(lease_file):
- os.mknod(lease_file)
-
- call('sudo systemctl restart isc-dhcpv4-server.service')
+ call('sudo systemctl restart isc-dhcp-server.service')
return None
if __name__ == '__main__':