summaryrefslogtreecommitdiff
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
parent3acb6381bc2a56e70a58b3a19ae817473f8dd5f4 (diff)
downloadvyos-1x-7a27726e0e1e1de47f8abfb64e9c28eadb34c55b.tar.gz
vyos-1x-7a27726e0e1e1de47f8abfb64e9c28eadb34c55b.zip
T784: Added update dns dynamic operation
-rw-r--r--Makefile1
-rw-r--r--op-mode-definitions/dns-forwarding.xml3
-rw-r--r--op-mode-definitions/dynamic-dns.xml25
-rwxr-xr-xsrc/op_mode/dynamic_dns.py (renamed from src/op_mode/dynamic_dns_status.py)29
4 files changed, 54 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 823637e84..70101181d 100644
--- a/Makefile
+++ b/Makefile
@@ -26,7 +26,6 @@ op_mode_definitions:
# XXX: delete top level op mode node.def's that now live in other packages
rm -f $(OP_TMPL_DIR)/set/node.def
rm -f $(OP_TMPL_DIR)/show/node.def
- rm -f $(OP_TMPL_DIR)/show/dns/node.def
rm -f $(OP_TMPL_DIR)/reset/node.def
rm -f $(OP_TMPL_DIR)/restart/node.def
rm -f $(OP_TMPL_DIR)/monitor/node.def
diff --git a/op-mode-definitions/dns-forwarding.xml b/op-mode-definitions/dns-forwarding.xml
index e789f4aee..be71302cd 100644
--- a/op-mode-definitions/dns-forwarding.xml
+++ b/op-mode-definitions/dns-forwarding.xml
@@ -4,6 +4,9 @@
<node name="show">
<children>
<node name="dns">
+ <properties>
+ <help>Show DNS information</help>
+ </properties>
<children>
<node name="forwarding">
<properties>
diff --git a/op-mode-definitions/dynamic-dns.xml b/op-mode-definitions/dynamic-dns.xml
index c67769a83..76c473fd7 100644
--- a/op-mode-definitions/dynamic-dns.xml
+++ b/op-mode-definitions/dynamic-dns.xml
@@ -4,6 +4,9 @@
<node name="show">
<children>
<node name="dns">
+ <properties>
+ <help>Show DNS information</help>
+ </properties>
<children>
<node name="dynamic">
<properties>
@@ -14,7 +17,7 @@
<properties>
<help>Show Dynamic DNS status</help>
</properties>
- <command>sudo ${vyos_op_scripts_dir}/dynamic_dns_status.py</command>
+ <command>sudo ${vyos_op_scripts_dir}/dynamic_dns.py --status</command>
</leafNode>
</children>
</node>
@@ -22,4 +25,24 @@
</node>
</children>
</node>
+ <node name="update">
+ <properties>
+ <help>Update data for a service</help>
+ </properties>
+ <children>
+ <node name="dns">
+ <properties>
+ <help>Update DNS information</help>
+ </properties>
+ <children>
+ <node name="dynamic">
+ <properties>
+ <help>Update Dynamic DNS information</help>
+ </properties>
+ <command>sudo ${vyos_op_scripts_dir}/dynamic_dns.py --update</command>
+ </node>
+ </children>
+ </node>
+ </children>
+ </node>
</interfaceDefinition>
diff --git a/src/op_mode/dynamic_dns_status.py b/src/op_mode/dynamic_dns.py
index bbff01f49..7ac3dfe9f 100755
--- a/src/op_mode/dynamic_dns_status.py
+++ b/src/op_mode/dynamic_dns.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
-
+import os
+import argparse
import jinja2
import sys
import time
@@ -18,7 +19,8 @@ update-status: {{ entry.status }}
{% endfor -%}
"""
-if __name__ == '__main__':
+
+def show_status():
# Do nothing if service is not configured
c = Config()
if not c.exists_effective('service dns dynamic'):
@@ -65,3 +67,26 @@ if __name__ == '__main__':
tmpl = jinja2.Template(OUT_TMPL_SRC)
print(tmpl.render(data))
+
+
+def update_ddns():
+ os.system('systemctl stop ddclient')
+ os.remove(cache_file)
+ os.system('systemctl start ddclient')
+
+
+def main():
+ parser = argparse.ArgumentParser()
+ group = parser.add_mutually_exclusive_group()
+ group.add_argument("--status", help="Show DDNS status", action="store_true")
+ group.add_argument("--update", help="Update DDNS on a given interface", action="store_true")
+ args = parser.parse_args()
+
+ if args.status:
+ show_status()
+ elif args.update:
+ update_ddns()
+
+
+if __name__ == '__main__':
+ main()