summaryrefslogtreecommitdiff
path: root/src/conf_mode/dhcp_server.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/conf_mode/dhcp_server.py')
-rwxr-xr-xsrc/conf_mode/dhcp_server.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/conf_mode/dhcp_server.py b/src/conf_mode/dhcp_server.py
index cc887e28e..e03a04a4d 100755
--- a/src/conf_mode/dhcp_server.py
+++ b/src/conf_mode/dhcp_server.py
@@ -736,7 +736,10 @@ def verify(dhcp):
return None
def generate(dhcp):
- if (dhcp is None) or (dhcp['disabled'] is True):
+ if dhcp is None:
+ return None
+
+ if dhcp['disabled'] is True:
print('Warning: DHCP server will be deactivated because it is disabled')
return None
@@ -753,11 +756,13 @@ def generate(dhcp):
return None
def apply(dhcp):
- if (dhcp is None) or (dhcp['disabled'] is True):
+ if (dhcp is None) or dhcp['disabled']:
# 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)
+ if os.path.exists(config_file):
+ os.unlink(config_file)
+ if os.path.exists(daemon_config_file):
+ os.unlink(daemon_config_file)
else:
os.system('sudo systemctl restart isc-dhcp-server.service')