From 3596d3e5d6d20ebb46a4b9365108280325839ef0 Mon Sep 17 00:00:00 2001 From: Viacheslav Hletenko Date: Sun, 2 Jul 2023 16:28:58 +0000 Subject: T5332: Fix show policy route without attahed interface Interface may not be present in the op-mode dictionary, it cause KeyError: 'interface' for policy route --- src/op_mode/policy_route.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/op_mode') diff --git a/src/op_mode/policy_route.py b/src/op_mode/policy_route.py index 5953786f3..fae47adec 100755 --- a/src/op_mode/policy_route.py +++ b/src/op_mode/policy_route.py @@ -61,8 +61,10 @@ def output_policy_route(name, route_conf, ipv6=False, single_rule_id=None): ip_str = 'IPv6' if ipv6 else 'IPv4' print(f'\n---------------------------------\n{ip_str} Policy Route "{name}"\n') - if route_conf['interface']: + if route_conf.get('interface'): print('Active on: {0}\n'.format(" ".join(route_conf['interface']))) + else: + print('Inactive - Not applied to any interfaces\n') details = get_nftables_details(name, ipv6) rows = [] -- cgit v1.2.3