diff options
author | Daniil Baturin <daniil@vyos.io> | 2020-06-22 13:24:30 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-22 13:24:30 +0700 |
commit | 1d09b1a788cc91ff64134d853f063dc0a364ad50 (patch) | |
tree | 1dca2298b55d26ba24347a14dfc5a837d92aefff /python/vyos/hostsd_client.py | |
parent | a8041aa4a9e70c267c17451c14c7dcf9ca887023 (diff) | |
parent | 0ccdf15c0acb0be128fa2346b72cfdd8ce16b694 (diff) | |
download | vyos-1x-1d09b1a788cc91ff64134d853f063dc0a364ad50.tar.gz vyos-1x-1d09b1a788cc91ff64134d853f063dc0a364ad50.zip |
Merge pull request #452 from jjakob/T2486-dns-hostsd-fixes
T2486: DNS, vyos-hostsd fixes
Diffstat (limited to 'python/vyos/hostsd_client.py')
-rw-r--r-- | python/vyos/hostsd_client.py | 100 |
1 files changed, 75 insertions, 25 deletions
diff --git a/python/vyos/hostsd_client.py b/python/vyos/hostsd_client.py index f009aba98..303b6ea47 100644 --- a/python/vyos/hostsd_client.py +++ b/python/vyos/hostsd_client.py @@ -1,15 +1,11 @@ import json - import zmq - -SOCKET_PATH = "ipc:///run/vyos-hostsd.sock" - +SOCKET_PATH = "ipc:///run/vyos-hostsd/vyos-hostsd.sock" class VyOSHostsdError(Exception): pass - class Client(object): def __init__(self): try: @@ -35,35 +31,89 @@ class Client(object): except zmq.error.Again: raise VyOSHostsdError("Could not connect to vyos-hostsd") - def set_host_name(self, host_name, domain_name, search_domains): - msg = { - 'type': 'host_name', - 'op': 'set', - 'data': { - 'host_name': host_name, - 'domain_name': domain_name, - 'search_domains': search_domains - } - } + def add_name_servers(self, data): + msg = {'type': 'name_servers', 'op': 'add', 'data': data} self._communicate(msg) - def add_hosts(self, tag, hosts): - msg = {'type': 'hosts', 'op': 'add', 'tag': tag, 'data': hosts} + def delete_name_servers(self, data): + msg = {'type': 'name_servers', 'op': 'delete', 'data': data} self._communicate(msg) - def delete_hosts(self, tag): - msg = {'type': 'hosts', 'op': 'delete', 'tag': tag} + def get_name_servers(self, tag_regex): + msg = {'type': 'name_servers', 'op': 'get', 'tag_regex': tag_regex} + return self._communicate(msg) + + def add_name_server_tags_recursor(self, data): + msg = {'type': 'name_server_tags_recursor', 'op': 'add', 'data': data} + self._communicate(msg) + + def delete_name_server_tags_recursor(self, data): + msg = {'type': 'name_server_tags_recursor', 'op': 'delete', 'data': data} + self._communicate(msg) + + def get_name_server_tags_recursor(self): + msg = {'type': 'name_server_tags_recursor', 'op': 'get'} + return self._communicate(msg) + + def add_name_server_tags_system(self, data): + msg = {'type': 'name_server_tags_system', 'op': 'add', 'data': data} + self._communicate(msg) + + def delete_name_server_tags_system(self, data): + msg = {'type': 'name_server_tags_system', 'op': 'delete', 'data': data} self._communicate(msg) - def add_name_servers(self, tag, servers): - msg = {'type': 'name_servers', 'op': 'add', 'tag': tag, 'data': servers} + def get_name_server_tags_system(self): + msg = {'type': 'name_server_tags_system', 'op': 'get'} + return self._communicate(msg) + + def add_forward_zones(self, data): + msg = {'type': 'forward_zones', 'op': 'add', 'data': data} self._communicate(msg) - def delete_name_servers(self, tag): - msg = {'type': 'name_servers', 'op': 'delete', 'tag': tag} + def delete_forward_zones(self, data): + msg = {'type': 'forward_zones', 'op': 'delete', 'data': data} self._communicate(msg) - def get_name_servers(self, tag): - msg = {'type': 'name_servers', 'op': 'get', 'tag': tag} + def get_forward_zones(self): + msg = {'type': 'forward_zones', 'op': 'get'} return self._communicate(msg) + def add_search_domains(self, data): + msg = {'type': 'search_domains', 'op': 'add', 'data': data} + self._communicate(msg) + + def delete_search_domains(self, data): + msg = {'type': 'search_domains', 'op': 'delete', 'data': data} + self._communicate(msg) + + def get_search_domains(self, tag_regex): + msg = {'type': 'search_domains', 'op': 'get', 'tag_regex': tag_regex} + return self._communicate(msg) + + def add_hosts(self, data): + msg = {'type': 'hosts', 'op': 'add', 'data': data} + self._communicate(msg) + + def delete_hosts(self, data): + msg = {'type': 'hosts', 'op': 'delete', 'data': data} + self._communicate(msg) + + def get_hosts(self, tag_regex): + msg = {'type': 'hosts', 'op': 'get', 'tag_regex': tag_regex} + return self._communicate(msg) + + def set_host_name(self, host_name, domain_name): + msg = { + 'type': 'host_name', + 'op': 'set', + 'data': { + 'host_name': host_name, + 'domain_name': domain_name, + } + } + self._communicate(msg) + + def apply(self): + msg = {'op': 'apply'} + return self._communicate(msg) |