From 65622a733df80ecee2192f3cd5758a27e4324b3b Mon Sep 17 00:00:00 2001 From: Nataliia Solomko Date: Tue, 10 Sep 2024 16:00:13 +0300 Subject: op-mode: T6694: Move some op-mode commands in the "execute" family MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 'force netns' — move to 'execute shell netns'. 'force vrf'— move to 'execute shell vrf'. 'force owping' — move to 'execute owping'. 'force twping' — move to 'execute twping'. 'monitor bandwidth-test' — move to 'execute bandwidth-test`. 'telnet' — move to 'execute telnet' --- op-mode-definitions/execute-bandwidth-test.xml.in | 59 +++++++++++++++++++++++ op-mode-definitions/execute-shell.xml.in | 32 ++++++++++++ op-mode-definitions/execute-wamp.xml.in | 25 ++++++++++ op-mode-definitions/force-netns.xml.in | 16 ------ op-mode-definitions/force-vrf.xml.in | 16 ------ op-mode-definitions/force-wamp.xml.in | 25 ---------- op-mode-definitions/monitor-bandwidth-test.xml.in | 59 ----------------------- op-mode-definitions/telnet.xml.in | 35 ++++++++------ op-mode-definitions/wake-on-lan.xml.in | 2 +- src/op_mode/execute_bandwidth_test.sh | 33 +++++++++++++ src/op_mode/monitor_bandwidth_test.sh | 33 ------------- 11 files changed, 170 insertions(+), 165 deletions(-) create mode 100644 op-mode-definitions/execute-bandwidth-test.xml.in create mode 100644 op-mode-definitions/execute-shell.xml.in create mode 100644 op-mode-definitions/execute-wamp.xml.in delete mode 100644 op-mode-definitions/force-netns.xml.in delete mode 100644 op-mode-definitions/force-vrf.xml.in delete mode 100644 op-mode-definitions/force-wamp.xml.in delete mode 100644 op-mode-definitions/monitor-bandwidth-test.xml.in create mode 100755 src/op_mode/execute_bandwidth_test.sh delete mode 100755 src/op_mode/monitor_bandwidth_test.sh diff --git a/op-mode-definitions/execute-bandwidth-test.xml.in b/op-mode-definitions/execute-bandwidth-test.xml.in new file mode 100644 index 000000000..1581d5c25 --- /dev/null +++ b/op-mode-definitions/execute-bandwidth-test.xml.in @@ -0,0 +1,59 @@ + + + + + + + Initiate or wait for bandwidth test + + + + + Wait for bandwidth test connections (port TCP/5001) + + /usr/bin/iperf -V -s + + + + Wait for bandwidth test connections (port TCP/5001) + + /usr/bin/iperf -V -s + + + + Wait for bandwidth test connections (port UDP/5001) + + /usr/bin/iperf -V -s -u + + + + + + Initiate a bandwidth test to specified host + + + + + Initiate a bandwidth test to specified host (port TCP/5001) + + <hostname> <x.x.x.x> <h:h:h:h:h:h:h:h> + + + ${vyos_op_scripts_dir}/execute_bandwidth_test.sh "$5" + + + + Initiate a bandwidth test to specified host (port UDP/5001) + + <hostname> <x.x.x.x> <h:h:h:h:h:h:h:h> + + + ${vyos_op_scripts_dir}/execute_bandwidth_test.sh "$5" "-u" + + + + + + + + diff --git a/op-mode-definitions/execute-shell.xml.in b/op-mode-definitions/execute-shell.xml.in new file mode 100644 index 000000000..dfdc1e371 --- /dev/null +++ b/op-mode-definitions/execute-shell.xml.in @@ -0,0 +1,32 @@ + + + + + + + Execute shell + + + + + Execute shell in given Network Namespace + + netns name + + + sudo ip netns exec $4 su - $(whoami) + + + + Execute shell in given VRF instance + + vrf name + + + sudo ip vrf exec $4 su - $(whoami) + + + + + + diff --git a/op-mode-definitions/execute-wamp.xml.in b/op-mode-definitions/execute-wamp.xml.in new file mode 100644 index 000000000..bcceedc53 --- /dev/null +++ b/op-mode-definitions/execute-wamp.xml.in @@ -0,0 +1,25 @@ + + + + + + + IP address of the remote OWAMP server + + <x.x.x.x> <h:h:h:h:h:h:h:h> + + + owping $3 + + + + IP address of the remote TWAMP server + + <x.x.x.x> <h:h:h:h:h:h:h:h> + + + twping $3 + + + + diff --git a/op-mode-definitions/force-netns.xml.in b/op-mode-definitions/force-netns.xml.in deleted file mode 100644 index b9dc2c1e8..000000000 --- a/op-mode-definitions/force-netns.xml.in +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - Execute shell in given Network Namespace - - netns name - - - sudo ip netns exec $3 su - $(whoami) - - - - diff --git a/op-mode-definitions/force-vrf.xml.in b/op-mode-definitions/force-vrf.xml.in deleted file mode 100644 index 71f50b0d2..000000000 --- a/op-mode-definitions/force-vrf.xml.in +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - Execute shell in given VRF instance - - vrf name - - - sudo ip vrf exec $3 su - $(whoami) - - - - diff --git a/op-mode-definitions/force-wamp.xml.in b/op-mode-definitions/force-wamp.xml.in deleted file mode 100644 index dbb205c6b..000000000 --- a/op-mode-definitions/force-wamp.xml.in +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - IP address of the remote OWAMP server - - <x.x.x.x> <h:h:h:h:h:h:h:h> - - - owping $3 - - - - IP address of the remote TWAMP server - - <x.x.x.x> <h:h:h:h:h:h:h:h> - - - twping $3 - - - - diff --git a/op-mode-definitions/monitor-bandwidth-test.xml.in b/op-mode-definitions/monitor-bandwidth-test.xml.in deleted file mode 100644 index 965591280..000000000 --- a/op-mode-definitions/monitor-bandwidth-test.xml.in +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - Initiate or wait for bandwidth test - - - - - Wait for bandwidth test connections (port TCP/5001) - - /usr/bin/iperf -V -s - - - - Wait for bandwidth test connections (port TCP/5001) - - /usr/bin/iperf -V -s - - - - Wait for bandwidth test connections (port UDP/5001) - - /usr/bin/iperf -V -s -u - - - - - - Initiate a bandwidth test to specified host - - - - - Initiate a bandwidth test to specified host (port TCP/5001) - - <hostname> <x.x.x.x> <h:h:h:h:h:h:h:h> - - - ${vyos_op_scripts_dir}/monitor_bandwidth_test.sh "$5" - - - - Initiate a bandwidth test to specified host (port UDP/5001) - - <hostname> <x.x.x.x> <h:h:h:h:h:h:h:h> - - - ${vyos_op_scripts_dir}/monitor_bandwidth_test.sh "$5" "-u" - - - - - - - - diff --git a/op-mode-definitions/telnet.xml.in b/op-mode-definitions/telnet.xml.in index c5bb6d283..2cacc6a26 100644 --- a/op-mode-definitions/telnet.xml.in +++ b/op-mode-definitions/telnet.xml.in @@ -1,30 +1,35 @@ - - - Telnet to a node - + - + - Telnet to a host - - <hostname> <x.x.x.x> <h:h:h:h:h:h:h:h> - + Telnet to a node - /usr/bin/telnet $3 - + - Telnet to a host:port + Telnet to a host - <0-65535> + <hostname> <x.x.x.x> <h:h:h:h:h:h:h:h> - /usr/bin/telnet $3 $5 + /usr/bin/telnet $4 + + + + Telnet to a host:port + + <0-65535> + + + /usr/bin/telnet $4 $6 + + - + + diff --git a/op-mode-definitions/wake-on-lan.xml.in b/op-mode-definitions/wake-on-lan.xml.in index 625cf4056..d4589c868 100644 --- a/op-mode-definitions/wake-on-lan.xml.in +++ b/op-mode-definitions/wake-on-lan.xml.in @@ -19,7 +19,7 @@ Station (MAC) address to wake up - sudo /usr/sbin/etherwake -i "$3" "$5" + sudo /usr/sbin/etherwake -i "$4" "$6" diff --git a/src/op_mode/execute_bandwidth_test.sh b/src/op_mode/execute_bandwidth_test.sh new file mode 100755 index 000000000..a6ad0b42c --- /dev/null +++ b/src/op_mode/execute_bandwidth_test.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# +# Copyright (C) 2020 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +if ipaddrcheck --is-ipv6 $1; then + # Set address family to IPv6 when an IPv6 address was specified + OPT="-V" +elif [[ $(dig $1 AAAA +short | grep -v '\.$' | wc -l) -gt 0 ]]; then + # CNAME is also part of the dig answer thus we must remove any + # CNAME response and only shot the AAAA response(s), this is done + # by grep -v '\.$' + + # Set address family to IPv6 when FQDN has at least one AAAA record + OPT="-V" +else + # It's not IPv6, no option needed + OPT="" +fi + +/usr/bin/iperf $OPT -c $1 $2 + diff --git a/src/op_mode/monitor_bandwidth_test.sh b/src/op_mode/monitor_bandwidth_test.sh deleted file mode 100755 index a6ad0b42c..000000000 --- a/src/op_mode/monitor_bandwidth_test.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -# -# Copyright (C) 2020 VyOS maintainers and contributors -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 or later as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -if ipaddrcheck --is-ipv6 $1; then - # Set address family to IPv6 when an IPv6 address was specified - OPT="-V" -elif [[ $(dig $1 AAAA +short | grep -v '\.$' | wc -l) -gt 0 ]]; then - # CNAME is also part of the dig answer thus we must remove any - # CNAME response and only shot the AAAA response(s), this is done - # by grep -v '\.$' - - # Set address family to IPv6 when FQDN has at least one AAAA record - OPT="-V" -else - # It's not IPv6, no option needed - OPT="" -fi - -/usr/bin/iperf $OPT -c $1 $2 - -- cgit v1.2.3