Skip to content

Commit 54946e9

Browse files
stchengyxieca
authored andcommitted
[acl_loader]: Add monitor port column in show mirror_session output (#662)
This column helps checking the output monitor port for the mirror session. Signed-off-by: Shu0T1an ChenG <[email protected]>
1 parent e71011a commit 54946e9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

acl_loader/main.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,14 @@ def read_sessions_info(self):
134134
self.sessions_db_info = self.configdb.get_table(self.CFG_MIRROR_SESSION_TABLE)
135135
for key in self.sessions_db_info.keys():
136136
state_db_info = self.statedb.get_all(self.statedb.STATE_DB, "{}|{}".format(self.STATE_MIRROR_SESSION_TABLE, key))
137+
monitor_port = ""
137138
if state_db_info:
138139
status = state_db_info.get("status", "inactive")
140+
monitor_port = state_db_info.get("monitor_port", "")
139141
else:
140142
status = "error"
141143
self.sessions_db_info[key]["status"] = status
144+
self.sessions_db_info[key]["monitor_port"] = monitor_port
142145

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

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

551554
data.append([key, val["status"], val["src_ip"], val["dst_ip"],
552555
val.get("gre_type", ""), val.get("dscp", ""),
553-
val.get("ttl", ""), val.get("queue", ""), val.get("policer", "")])
556+
val.get("ttl", ""), val.get("queue", ""), val.get("policer", ""),
557+
val.get("monitor_port", "")])
554558

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

0 commit comments

Comments
 (0)