summaryrefslogtreecommitdiff
path: root/src/services/vyos-hostsd
diff options
context:
space:
mode:
Diffstat (limited to 'src/services/vyos-hostsd')
-rwxr-xr-xsrc/services/vyos-hostsd14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/services/vyos-hostsd b/src/services/vyos-hostsd
index 6017cea82..bf5d67cfa 100755
--- a/src/services/vyos-hostsd
+++ b/src/services/vyos-hostsd
@@ -28,6 +28,7 @@ import zmq
import collections
import jinja2
+from vyos.util import popen, process_named_running
debug = True
@@ -212,13 +213,17 @@ def handle_message(msg_json):
op = get_option(msg, 'op')
_type = get_option(msg, 'type')
+ changes = 0
+
if op == 'delete':
tag = get_option(msg, 'tag')
if _type == 'name_servers':
delete_name_servers(STATE, tag)
+ changes += 1
elif _type == 'hosts':
delete_hosts(STATE, tag)
+ changes += 1
else:
raise ValueError("Unknown message type {0}".format(_type))
elif op == 'add':
@@ -226,8 +231,10 @@ def handle_message(msg_json):
entries = get_option(msg, 'data')
if _type == 'name_servers':
add_name_servers(STATE, entries, tag)
+ changes += 1
elif _type == 'hosts':
add_hosts(STATE, entries, tag)
+ changes += 1
else:
raise ValueError("Unknown message type {0}".format(_type))
elif op == 'set':
@@ -236,6 +243,7 @@ def handle_message(msg_json):
data = get_option(msg, 'data')
if _type == 'host_name':
set_host_name(STATE, data)
+ changes += 1
else:
raise ValueError("Unknown message type {0}".format(_type))
elif op == 'get':
@@ -255,6 +263,12 @@ def handle_message(msg_json):
with open(STATE_FILE, 'w') as f:
json.dump(STATE, f)
+ if changes > 0:
+ if process_named_running("pdns_recursor"):
+ (ret,return_code) = popen("sudo rec_control --socket-dir=/run/powerdns reload-zones")
+ if return_code > 0:
+ logger.exception("PowerDNS rec_control failed to reload")
+
def exit_handler(sig, frame):
""" Clean up the state when shutdown correctly """
logger.info("Cleaning up state")