From e4071bfaede4971dca093ef459cce8c6caad2372 Mon Sep 17 00:00:00 2001 From: Viacheslav Hletenko Date: Tue, 11 Oct 2022 12:14:29 +0000 Subject: conntrack: T4740: Set correct error msg if enrties not found Set correct error message if conntrack entries not found If we get XML raw data with len 0 it means there are no entries in the conntrack table --- src/op_mode/conntrack.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/op_mode') diff --git a/src/op_mode/conntrack.py b/src/op_mode/conntrack.py index b27aa6060..fff537936 100755 --- a/src/op_mode/conntrack.py +++ b/src/op_mode/conntrack.py @@ -48,6 +48,14 @@ def _get_raw_data(family): Return: dictionary """ xml = _get_xml_data(family) + if len(xml) == 0: + output = {'conntrack': + { + 'error': True, + 'reason': 'entries not found' + } + } + return output return _xml_to_dict(xml) @@ -72,7 +80,8 @@ def get_formatted_output(dict_data): :return: formatted output """ data_entries = [] - #dict_data = _get_raw_data(family) + if 'error' in dict_data['conntrack']: + return 'Entries not found' for entry in dict_data['conntrack']['flow']: orig_src, orig_dst, orig_sport, orig_dport = {}, {}, {}, {} reply_src, reply_dst, reply_sport, reply_dport = {}, {}, {}, {} -- cgit v1.2.3