From ab84f1f3757bb82c3ddf95143c014cdb3d997977 Mon Sep 17 00:00:00 2001 From: Viacheslav Hletenko Date: Mon, 1 Aug 2022 08:40:47 +0000 Subject: vrf: T4562: Check VRF if it has not been configured Check list of VRF's, check key 'ifname' is configured If not configured, return message "VRF is not configured" --- src/op_mode/vrf.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/op_mode/vrf.py b/src/op_mode/vrf.py index f86516786..e3d944d90 100755 --- a/src/op_mode/vrf.py +++ b/src/op_mode/vrf.py @@ -15,6 +15,7 @@ # along with this program. If not, see . import json +import jmespath import sys import typing @@ -76,6 +77,8 @@ def _get_formatted_output(raw_data): def show(raw: bool, name: typing.Optional[str]): vrf_data = _get_raw_data(name=name) + if not jmespath.search('[*].ifname', vrf_data): + return "VRF is not configured" if raw: return vrf_data else: -- cgit v1.2.3