diff options
author | Daniil Baturin <daniil@baturin.org> | 2019-08-26 19:58:04 +0200 |
---|---|---|
committer | Daniil Baturin <daniil@baturin.org> | 2019-08-27 08:16:28 +0200 |
commit | 3a6ce1c83b5615bd8eee153a74c5eab9f919ad55 (patch) | |
tree | 49e607c296c721fe081d4392ae282be1c0c29771 /src/services/vyos-hostsd | |
parent | 43b0bbbc9b5b00b3e91dde7e7cffe8dc8497b8ce (diff) | |
download | vyos-1x-3a6ce1c83b5615bd8eee153a74c5eab9f919ad55.tar.gz vyos-1x-3a6ce1c83b5615bd8eee153a74c5eab9f919ad55.zip |
T1598: add a vyos-hostsd operation for retrieving name servers by tag.
Diffstat (limited to 'src/services/vyos-hostsd')
-rwxr-xr-x | src/services/vyos-hostsd | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/services/vyos-hostsd b/src/services/vyos-hostsd index 1bcb2e1f5..8f70eb4e9 100755 --- a/src/services/vyos-hostsd +++ b/src/services/vyos-hostsd @@ -171,6 +171,14 @@ def set_host_name(state, data): if data['search_domains']: state['search_domains'] = data['search_domains'] +def get_name_servers(state, tag): + ns = [] + data = state['name_servers'] + for n in data: + if data[n]['tag'] == tag: + ns.append(n) + return ns + def get_option(msg, key): if key in msg: return msg[key] @@ -209,6 +217,13 @@ def handle_message(msg_json): set_host_name(STATE, data) else: raise ValueError("Unknown message type {0}".format(_type)) + elif op == 'get': + tag = get_option(msg, 'tag') + if _type == 'name_servers': + result = get_name_servers(STATE, tag) + else: + raise ValueError("Unimplemented") + return result else: raise ValueError("Unknown operation {0}".format(op)) @@ -254,7 +269,8 @@ if __name__ == '__main__': resp = {} try: - handle_message(message) + result = handle_message(message) + resp['data'] = result except ValueError as e: resp['error'] = str(e) except: |