summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorViacheslav Hletenko <v.gletenko@vyos.io>2022-10-11 12:14:29 +0000
committerViacheslav Hletenko <v.gletenko@vyos.io>2022-10-11 12:14:29 +0000
commite4071bfaede4971dca093ef459cce8c6caad2372 (patch)
treec1f26dba4d32e36b3145f8e6cb44a209efab5555
parente5507b247edc37c466ef0d023417c65ebbad409b (diff)
downloadvyos-1x-e4071bfaede4971dca093ef459cce8c6caad2372.tar.gz
vyos-1x-e4071bfaede4971dca093ef459cce8c6caad2372.zip
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
-rwxr-xr-xsrc/op_mode/conntrack.py11
1 files changed, 10 insertions, 1 deletions
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 = {}, {}, {}, {}