Skip to content

Commit

Permalink
[acl_loader]: Add status column to session table (sonic-net#177)
Browse files Browse the repository at this point in the history
Signed-off-by: marian-pritsak <[email protected]>
  • Loading branch information
marian-pritsak authored and lguohan committed Dec 19, 2017
1 parent 8677d5f commit 99c3f48
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions acl_loader/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import openconfig_acl
import pyangbind.lib.pybindJSON as pybindJSON
from swsssdk import ConfigDBConnector
from swsssdk import SonicV2Connector


def info(msg):
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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", "")])

Expand Down

0 comments on commit 99c3f48

Please sign in to comment.