summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--Makefile1
-rw-r--r--debian/control1
-rw-r--r--op-mode-definitions/date.xml64
-rw-r--r--op-mode-definitions/show-date.xml30
-rw-r--r--op-mode-definitions/show-ntp.xml22
-rwxr-xr-xsrc/completion/list_ntp_servers.sh4
7 files changed, 95 insertions, 30 deletions
diff --git a/.gitignore b/.gitignore
index 5d0af4bae..af15969c8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,12 +21,15 @@ parts/
sdist/
var/
wheels/
+Pipfile
+Pipfile.lock
*.egg-info/
.installed.cfg
*.egg
.idea/
.idea
.idea/*
+*.iml
# PyInstaller
# Usually these files are written by a python script from a template
diff --git a/Makefile b/Makefile
index 9e7a67fbf..823637e84 100644
--- a/Makefile
+++ b/Makefile
@@ -24,6 +24,7 @@ op_mode_definitions:
find $(CURDIR)/op-mode-definitions/ -type f -name "*.xml" | xargs -I {} $(CURDIR)/scripts/build-command-op-templates {} $(CURDIR)/schema/op-mode-definition.rng $(OP_TMPL_DIR) || exit 1
# 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
diff --git a/debian/control b/debian/control
index ce9d925d3..70bf7a61c 100644
--- a/debian/control
+++ b/debian/control
@@ -32,6 +32,7 @@ Depends: python3,
snmp, snmpd,
openssh-server,
ntp,
+ ntpdate,
iputils-arping,
libvyosconfig0,
beep,
diff --git a/op-mode-definitions/date.xml b/op-mode-definitions/date.xml
new file mode 100644
index 000000000..15a69dbd9
--- /dev/null
+++ b/op-mode-definitions/date.xml
@@ -0,0 +1,64 @@
+<?xml version="1.0"?>
+<interfaceDefinition>
+ <node name="show">
+ <children>
+ <node name="date">
+ <properties>
+ <help>Show system time and date</help>
+ </properties>
+ <command>/bin/date</command>
+ <children>
+ <node name="utc">
+ <properties>
+ <help>Show system date and time as Coordinated Universal Time</help>
+ </properties>
+ <command>/bin/date -u</command>
+ <children>
+ <leafNode name="maya">
+ <properties>
+ <help>Show UTC date in Maya calendar format</help>
+ </properties>
+ <command>${vyos_op_scripts_dir}/maya_date.py $(date +%s)</command>
+ </leafNode>
+ </children>
+ </node>
+ </children>
+ </node>
+ </children>
+ </node>
+ <node name="set">
+ <children>
+ <tagNode name="date">
+ <properties>
+ <help>Set system date and time</help>
+ <completionHelp>
+ <list>&lt;MMDDhhmm&gt; &lt;MMDDhhmmYY&gt; &lt;MMDDhhmmCCYY&gt; &lt;MMDDhhmmCCYY.ss&gt;</list>
+ </completionHelp>
+ </properties>
+ <command>/bin/date "$3"</command>
+ </tagNode>
+ <node name="date">
+ <properties>
+ <help>Set system date and time</help>
+ </properties>
+ <children>
+ <node name="ntp">
+ <properties>
+ <help>Set system date and time from NTP server (default: 0.pool.ntp.org)</help>
+ </properties>
+ <command>/usr/sbin/ntpdate -u 0.pool.ntp.org</command>
+ </node>
+ <tagNode name="ntp">
+ <properties>
+ <help>Set system date and time from NTP server</help>
+ <completionHelp>
+ <script>${vyos_completion_dir}/list_ntp_servers.sh</script>
+ </completionHelp>
+ </properties>
+ <command>/usr/sbin/ntpdate -u "$4"</command>
+ </tagNode>
+ </children>
+ </node>
+ </children>
+ </node>
+</interfaceDefinition>
diff --git a/op-mode-definitions/show-date.xml b/op-mode-definitions/show-date.xml
deleted file mode 100644
index 705172b39..000000000
--- a/op-mode-definitions/show-date.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0"?>
-<interfaceDefinition>
- <node name="show">
- <children>
- <node name="date">
- <properties>
- <help>Show system time and date</help>
- </properties>
- <command>/bin/date</command>
- <children>
- <node name="utc">
- <properties>
- <help>Show system date and time as Coordinated Universal Time</help>
- </properties>
- <command>/bin/date -u</command>
- <children>
- <leafNode name="maya">
- <properties>
- <help>Show UTC date in Maya calendar format</help>
- </properties>
- <command>${vyos_op_scripts_dir}/maya_date.py $(date +%s)</command>
- </leafNode>
- </children>
- </node>
- </children>
- </node>
-
- </children>
- </node>
-</interfaceDefinition>
diff --git a/op-mode-definitions/show-ntp.xml b/op-mode-definitions/show-ntp.xml
new file mode 100644
index 000000000..4f2f2192b
--- /dev/null
+++ b/op-mode-definitions/show-ntp.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<interfaceDefinition>
+ <node name="show">
+ <children>
+ <node name="ntp">
+ <properties>
+ <help>Show peer status of NTP daemon</help>
+ </properties>
+ <command>if ps -C ntpd &amp;>/dev/null; then ntpdc -n -c peers; else echo NTP daemon disabled; fi</command>
+ </node>
+ <tagNode name="ntp">
+ <properties>
+ <help>Show date and time of specified NTP server</help>
+ <completionHelp>
+ <script>${vyos_completion_dir}/list_ntp_servers.sh</script>
+ </completionHelp>
+ </properties>
+ <command>/usr/sbin/ntpdate -q "$3"</command>
+ </tagNode>
+ </children>
+ </node>
+</interfaceDefinition>
diff --git a/src/completion/list_ntp_servers.sh b/src/completion/list_ntp_servers.sh
new file mode 100755
index 000000000..d0977fbd6
--- /dev/null
+++ b/src/completion/list_ntp_servers.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+# Completion script used to select specific NTP server
+/bin/cli-shell-api -- listEffectiveNodes system ntp server | sed "s/'//g"