summaryrefslogtreecommitdiff
path: root/src/op_mode/dynamic_dns_status.py
diff options
context:
space:
mode:
authorDmytro Aleksandrov <alkersan@gmail.com>2018-08-18 00:43:12 +0300
committerDmytro Aleksandrov <alkersan@gmail.com>2018-08-18 00:43:12 +0300
commit7a27726e0e1e1de47f8abfb64e9c28eadb34c55b (patch)
treef130a3535c11cc73eb669fb79144a3332d556d76 /src/op_mode/dynamic_dns_status.py
parent3acb6381bc2a56e70a58b3a19ae817473f8dd5f4 (diff)
downloadvyos-1x-7a27726e0e1e1de47f8abfb64e9c28eadb34c55b.tar.gz
vyos-1x-7a27726e0e1e1de47f8abfb64e9c28eadb34c55b.zip
T784: Added update dns dynamic operation
Diffstat (limited to 'src/op_mode/dynamic_dns_status.py')
-rwxr-xr-xsrc/op_mode/dynamic_dns_status.py67
1 files changed, 0 insertions, 67 deletions
diff --git a/src/op_mode/dynamic_dns_status.py b/src/op_mode/dynamic_dns_status.py
deleted file mode 100755
index bbff01f49..000000000
--- a/src/op_mode/dynamic_dns_status.py
+++ /dev/null
@@ -1,67 +0,0 @@
-#!/usr/bin/env python3
-
-import jinja2
-import sys
-import time
-
-from vyos.config import Config
-
-cache_file = r'/var/cache/ddclient/ddclient.cache'
-
-OUT_TMPL_SRC = """
-{%- for entry in hosts -%}
-ip address : {{ entry.ip }}
-host-name : {{ entry.host }}
-last update : {{ entry.time }}
-update-status: {{ entry.status }}
-
-{% endfor -%}
-"""
-
-if __name__ == '__main__':
- # Do nothing if service is not configured
- c = Config()
- if not c.exists_effective('service dns dynamic'):
- print("Dynamic DNS not configured")
- sys.exit(0)
-
- data = {
- 'hosts': []
- }
-
- with open(cache_file, 'r') as f:
- for line in f:
- if line.startswith('#'):
- continue
-
- outp = {
- 'host': '',
- 'ip': '',
- 'time': ''
- }
-
- if 'host=' in line:
- host = line.split('host=')[1]
- if host:
- outp['host'] = host.split(',')[0]
-
- if 'ip=' in line:
- ip = line.split('ip=')[1]
- if ip:
- outp['ip'] = ip.split(',')[0]
-
- if 'atime=' in line:
- atime = line.split('atime=')[1]
- if atime:
- tmp = atime.split(',')[0]
- outp['time'] = time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(int(tmp, base=10)))
-
- if 'status=' in line:
- status = line.split('status=')[1]
- if status:
- outp['status'] = status.split(',')[0]
-
- data['hosts'].append(outp)
-
- tmpl = jinja2.Template(OUT_TMPL_SRC)
- print(tmpl.render(data))