summaryrefslogtreecommitdiff
path: root/src/op_mode/mtr.py
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-11-12 10:03:25 +0100
committerChristian Breunig <christian@breunig.cc>2023-11-12 10:03:25 +0100
commit7b27a20c8664460482301cc8d7554048f152485e (patch)
treec7c8d0b934bf1effc34f5f6bc6c61243b456334f /src/op_mode/mtr.py
parent709c578e123bcf258eba1d15842b63eb63413523 (diff)
downloadvyos-1x-7b27a20c8664460482301cc8d7554048f152485e.tar.gz
vyos-1x-7b27a20c8664460482301cc8d7554048f152485e.zip
T5658: add common methods interface_list() and vrf_list() to vyos.utils.network
Reduce amount of duplicated (3 times) code in op-mode scripts for ping, traceroute and mtr.
Diffstat (limited to 'src/op_mode/mtr.py')
-rw-r--r--src/op_mode/mtr.py27
1 files changed, 4 insertions, 23 deletions
diff --git a/src/op_mode/mtr.py b/src/op_mode/mtr.py
index 759f7078c..57aab5389 100644
--- a/src/op_mode/mtr.py
+++ b/src/op_mode/mtr.py
@@ -14,29 +14,13 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-import os
import sys
import socket
import ipaddress
-from vyos.utils.network import get_all_vrfs
-from vyos.ifconfig import Section
-
-
-def interface_list() -> list:
- """
- Get list of interfaces in system
- :rtype: list
- """
- return Section.interfaces()
-
-
-def vrf_list() -> list:
- """
- Get list of VRFs in system
- :rtype: list
- """
- return list(get_all_vrfs().keys())
+from vyos.utils.network import interface_list
+from vyos.utils.network import vrf_list
+from vyos.utils.process import call
options = {
'report': {
@@ -214,7 +198,6 @@ mtr = {
6: '/bin/mtr -6',
}
-
class List(list):
def first(self):
return self.pop(0) if self else ''
@@ -337,6 +320,4 @@ if __name__ == '__main__':
sys.exit(f'mtr: Unknown host: {host}')
command = convert(mtr[version], args)
-
- # print(f'{command} {host}')
- os.system(f'{command} {host}')
+ call(f'{command} --curses --displaymode 0 {host}')