From 46fa3ec53f9c301b3c58af06ba532838d42a0dc6 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Tue, 28 Aug 2018 09:28:07 +0200 Subject: dhcp_server.py: issue warning and don't generate config if service is disabled --- src/conf_mode/dhcp_server.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/conf_mode/dhcp_server.py') diff --git a/src/conf_mode/dhcp_server.py b/src/conf_mode/dhcp_server.py index e1bc672f8..cc887e28e 100755 --- a/src/conf_mode/dhcp_server.py +++ b/src/conf_mode/dhcp_server.py @@ -601,7 +601,7 @@ def get_config(): return dhcp def verify(dhcp): - if dhcp is None: + if (dhcp is None) or (dhcp['disabled'] is True): return None # If DHCP is enabled we need one share-network @@ -736,7 +736,8 @@ def verify(dhcp): return None def generate(dhcp): - if dhcp is None: + if (dhcp is None) or (dhcp['disabled'] is True): + print('Warning: DHCP server will be deactivated because it is disabled') return None tmpl = jinja2.Template(config_tmpl) @@ -752,13 +753,13 @@ def generate(dhcp): return None def apply(dhcp): - if dhcp is not None: - os.system('sudo systemctl restart isc-dhcp-server.service') - else: + if (dhcp is None) or (dhcp['disabled'] is True): # DHCP server is removed in the commit os.system('sudo systemctl stop isc-dhcp-server.service') os.unlink(config_file) os.unlink(daemon_config_file) + else: + os.system('sudo systemctl restart isc-dhcp-server.service') return None -- cgit v1.2.3