Skip to content

Commit 27a64c2

Browse files
jvossjestabro
authored andcommitted
http-api: T9223: add VRF option to traceroute REST API endpoint
1 parent ea65e1d commit 27a64c2

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

python/vyos/configsession.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,9 @@ def ping(self, host, count: int = 5, vrf: str | None = None):
494494
out = self.__run_command(cmd)
495495
return out
496496

497-
def traceroute(self, host):
498-
out = self.__run_command(TRACEROUTE + [host])
497+
def traceroute(self, host, vrf: str | None = None):
498+
cmd = TRACEROUTE + [host]
499+
if vrf is not None:
500+
cmd += ['--vrf', vrf]
501+
out = self.__run_command(cmd)
499502
return out

src/services/api/rest/models.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,13 +332,15 @@ class Config:
332332
class TracerouteModel(ApiModel):
333333
op: StrictStr
334334
host: StrictStr
335+
vrf: StrictStr | None = None
335336

336337
class Config:
337338
schema_extra = {
338339
'example': {
339340
'key': 'id_key',
340341
'op': 'traceroute',
341342
'host': 'host',
343+
'vrf': 'vrf',
342344
}
343345
}
344346

src/services/api/rest/routers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -992,10 +992,11 @@ def traceroute_op(data: TracerouteModel):
992992

993993
op = data.op
994994
host = data.host
995+
vrf = data.vrf
995996

996997
try:
997998
if op == 'traceroute':
998-
res = session.traceroute(host)
999+
res = session.traceroute(host, vrf)
9991000
else:
10001001
return error(400, f"'{op}' is not a valid operation")
10011002
except ConfigSessionError as e:

0 commit comments

Comments
 (0)