From 3104c0ea8284ac5039e1dbab4a3ccd193e748ede Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sun, 16 Aug 2020 12:37:50 +0200 Subject: ping: op-mode: T2762: always run in default VRF unless defined otherwise When connected to VyOS by SSH through any VRF, every command is executed in the VRF context thus e.g. ping will run in VRF context but no VRF was defined on the CLI. ping should always run in the default VRF no matter where it is executed, unless a VRF instance is explicitly defined by CLI. --- src/op_mode/ping.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/op_mode/ping.py b/src/op_mode/ping.py index e56952c38..29b430d53 100755 --- a/src/op_mode/ping.py +++ b/src/op_mode/ping.py @@ -118,7 +118,8 @@ options = { 'vrf': { 'ping': 'sudo ip vrf exec {value} {command}', 'type': '', - 'help': 'Use specified VRF table' + 'help': 'Use specified VRF table', + 'dflt': 'default', }, 'verbose': { 'ping': '{command} -v', @@ -207,6 +208,11 @@ if __name__ == '__main__': sys.stdout.write(options[matched[0]]['type']) sys.exit(0) + for name,option in options.items(): + if 'dflt' in option and name not in args: + args.append(name) + args.append(option['dflt']) + try: ip = socket.gethostbyname(host) except socket.gaierror: -- cgit v1.2.3