Skip to content

Commit

Permalink
[acl_loader]: Add monitor port column in show mirror_session output (s…
Browse files Browse the repository at this point in the history
…onic-net#662)

This column helps checking the output monitor port for the mirror
session.

Signed-off-by: Shu0T1an ChenG <shuche@microsoft.com>
  • Loading branch information
stcheng authored Sep 26, 2019
1 parent cbf19f6 commit a72b35f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions acl_loader/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,14 @@ def read_sessions_info(self):
self.sessions_db_info = self.configdb.get_table(self.CFG_MIRROR_SESSION_TABLE)
for key in self.sessions_db_info.keys():
state_db_info = self.statedb.get_all(self.statedb.STATE_DB, "{}|{}".format(self.STATE_MIRROR_SESSION_TABLE, key))
monitor_port = ""
if state_db_info:
status = state_db_info.get("status", "inactive")
monitor_port = state_db_info.get("monitor_port", "")
else:
status = "error"
self.sessions_db_info[key]["status"] = status
self.sessions_db_info[key]["monitor_port"] = monitor_port

def get_sessions_db_info(self):
return self.sessions_db_info
Expand Down Expand Up @@ -541,7 +544,7 @@ def show_session(self, session_name):
:param session_name: Optional. Mirror session name. Filter sessions by specified name.
:return:
"""
header = ("Name", "Status", "SRC IP", "DST IP", "GRE", "DSCP", "TTL", "Queue", "Policer")
header = ("Name", "Status", "SRC IP", "DST IP", "GRE", "DSCP", "TTL", "Queue", "Policer", "Monitor Port")

data = []
for key, val in self.get_sessions_db_info().iteritems():
Expand All @@ -550,7 +553,8 @@ def show_session(self, session_name):

data.append([key, val["status"], val["src_ip"], val["dst_ip"],
val.get("gre_type", ""), val.get("dscp", ""),
val.get("ttl", ""), val.get("queue", ""), val.get("policer", "")])
val.get("ttl", ""), val.get("queue", ""), val.get("policer", ""),
val.get("monitor_port", "")])

print(tabulate.tabulate(data, headers=header, tablefmt="simple", missingval=""))

Expand Down

0 comments on commit a72b35f

Please sign in to comment.