summaryrefslogtreecommitdiff
path: root/src/conf_mode
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2018-08-28 09:28:07 +0200
committerChristian Poessinger <christian@poessinger.com>2018-08-28 09:28:07 +0200
commit46fa3ec53f9c301b3c58af06ba532838d42a0dc6 (patch)
tree592b1cc0ded7b7ec863bec8a8fa39f392e1cdbc7 /src/conf_mode
parent0e8bf76a10e5386fbf63ff4eec3c644ad7fe38fc (diff)
downloadvyos-1x-46fa3ec53f9c301b3c58af06ba532838d42a0dc6.tar.gz
vyos-1x-46fa3ec53f9c301b3c58af06ba532838d42a0dc6.zip
dhcp_server.py: issue warning and don't generate config if service is disabled
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-xsrc/conf_mode/dhcp_server.py11
1 files changed, 6 insertions, 5 deletions
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