From 99c3f48247be1c683b9890759191e80e65896017 Mon Sep 17 00:00:00 2001 From: Marian Pritsak Date: Tue, 19 Dec 2017 21:13:36 +0200 Subject: [PATCH] [acl_loader]: Add status column to session table (#177) Signed-off-by: marian-pritsak --- acl_loader/main.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/acl_loader/main.py b/acl_loader/main.py index e1b14f1bba01..7b35f26a8c8c 100644 --- a/acl_loader/main.py +++ b/acl_loader/main.py @@ -12,6 +12,7 @@ import openconfig_acl import pyangbind.lib.pybindJSON as pybindJSON from swsssdk import ConfigDBConnector +from swsssdk import SonicV2Connector def info(msg): @@ -81,6 +82,8 @@ def __init__(self): self.sessions_db_info = {} self.configdb = ConfigDBConnector() self.configdb.connect() + self.appdb = SonicV2Connector() + self.appdb.connect(self.appdb.APPL_DB) self.read_tables_info() self.read_rules_info() @@ -112,6 +115,11 @@ def read_sessions_info(self): :return: """ self.sessions_db_info = self.configdb.get_table(self.MIRROR_SESSION) + for key in self.sessions_db_info.keys(): + app_db_info = self.appdb.get_all(self.appdb.APPL_DB, "{}:{}".format(self.MIRROR_SESSION, key)) + + status = app_db_info.get("status", "inactive") + self.sessions_db_info[key]["status"] = status def get_sessions_db_info(self): """ @@ -400,14 +408,14 @@ def show_session(self, session_name): :param session_name: Optional. Mirror session name. Filter sessions by specified name. :return: """ - header = ("Name", "SRC IP", "DST IP", "GRE", "DSCP", "TTL", "Queue") + header = ("Name", "Status", "SRC IP", "DST IP", "GRE", "DSCP", "TTL", "Queue") data = [] for key, val in self.get_sessions_db_info().iteritems(): if session_name and key != session_name: continue - data.append([key, val["src_ip"], val["dst_ip"], + data.append([key, val["status"], val["src_ip"], val["dst_ip"], val.get("gre_type", ""), val.get("dscp", ""), val.get("ttl", ""), val.get("queue", "")])