From a72b35f27811d2e533e0f5639c06190a6027c241 Mon Sep 17 00:00:00 2001 From: Shuotian Cheng Date: Thu, 26 Sep 2019 11:38:59 -0700 Subject: [PATCH] [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 --- acl_loader/main.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/acl_loader/main.py b/acl_loader/main.py index c633b853ec5d..b80ac0d8408f 100644 --- a/acl_loader/main.py +++ b/acl_loader/main.py @@ -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 @@ -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(): @@ -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=""))