summaryrefslogtreecommitdiff
path: root/python/vyos
diff options
context:
space:
mode:
authorNataliia Solomko <natalirs1985@gmail.com>2024-10-11 13:24:43 +0300
committerNataliia Solomko <natalirs1985@gmail.com>2024-10-11 13:37:45 +0300
commit60cd669d2cee2a17d4e6ab6fce9101069d311e23 (patch)
treeeecb5f26c5367d4b88276a035a1d0f01140ba64e /python/vyos
parent7d4264365e487d37115cff0633b25e4b2012a126 (diff)
downloadvyos-1x-60cd669d2cee2a17d4e6ab6fce9101069d311e23.tar.gz
vyos-1x-60cd669d2cee2a17d4e6ab6fce9101069d311e23.zip
T6695: Machine-readable operational mode support for traceroute
Diffstat (limited to 'python/vyos')
-rw-r--r--python/vyos/configsession.py14
-rw-r--r--python/vyos/opmode.py5
2 files changed, 18 insertions, 1 deletions
diff --git a/python/vyos/configsession.py b/python/vyos/configsession.py
index 7d51b94e4..6bfca5200 100644
--- a/python/vyos/configsession.py
+++ b/python/vyos/configsession.py
@@ -48,6 +48,16 @@ REBOOT = ['/opt/vyatta/bin/vyatta-op-cmd-wrapper', 'reboot']
POWEROFF = ['/opt/vyatta/bin/vyatta-op-cmd-wrapper', 'poweroff']
OP_CMD_ADD = ['/opt/vyatta/bin/vyatta-op-cmd-wrapper', 'add']
OP_CMD_DELETE = ['/opt/vyatta/bin/vyatta-op-cmd-wrapper', 'delete']
+TRACEROUTE = [
+ '/usr/libexec/vyos/op_mode/mtr_execute.py',
+ 'mtr',
+ '--for-api',
+ '--report-mode',
+ '--report-cycles',
+ '1',
+ '--json',
+ '--host',
+]
# Default "commit via" string
APP = "vyos-http-api"
@@ -285,3 +295,7 @@ class ConfigSession(object):
def show_container_image(self):
out = self.__run_command(SHOW + ['container', 'image'])
return out
+
+ def traceroute(self, host):
+ out = self.__run_command(TRACEROUTE + [host])
+ return out
diff --git a/python/vyos/opmode.py b/python/vyos/opmode.py
index 066c8058f..83e25fb50 100644
--- a/python/vyos/opmode.py
+++ b/python/vyos/opmode.py
@@ -89,7 +89,10 @@ class InternalError(Error):
def _is_op_mode_function_name(name):
- if re.match(r"^(show|clear|reset|restart|add|update|delete|generate|set|renew|release|execute)", name):
+ if re.match(
+ r'^(show|clear|reset|restart|add|update|delete|generate|set|renew|release|execute|mtr)',
+ name,
+ ):
return True
else:
return False