From 9fda295cd06ee558ee2732b4c81ca447b2da0f4e Mon Sep 17 00:00:00 2001 From: Garrick He <32883830+GarrickHe@users.noreply.github.com> Date: Sat, 7 Nov 2020 20:23:01 -0800 Subject: [PATCH] [sflow] Clean-up sFlow container and port_index_mapper.py script (#5846) * Fix some spelling error and add addition check in port_index_mapper.py script. * Remove unneeded pyroute2 python module from sFlow container Signed-off-by: Garrick He --- dockers/docker-sflow/Dockerfile.j2 | 3 --- dockers/docker-sflow/port_index_mapper.py | 12 +++++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/dockers/docker-sflow/Dockerfile.j2 b/dockers/docker-sflow/Dockerfile.j2 index 94f4d73c968c..e1d7ce72855a 100644 --- a/dockers/docker-sflow/Dockerfile.j2 +++ b/dockers/docker-sflow/Dockerfile.j2 @@ -12,9 +12,6 @@ RUN apt-get update && \ dmidecode \ libmnl0=1.0.4-2 -RUN pip install \ - pyroute2==0.5.3 - {% if docker_sflow_debs.strip() -%} # Copy locally-built Debian package dependencies {{ copy_files("debs/", docker_sflow_debs.split(' '), "/debs/") }} diff --git a/dockers/docker-sflow/port_index_mapper.py b/dockers/docker-sflow/port_index_mapper.py index 3f8a2819a840..c027589e2af0 100755 --- a/dockers/docker-sflow/port_index_mapper.py +++ b/dockers/docker-sflow/port_index_mapper.py @@ -28,12 +28,12 @@ def __init__(self): self.state_db = SonicV2Connector(host='127.0.0.1', decode_responses=True) self.state_db.connect(self.state_db.STATE_DB, False) self.sel = swsscommon.Select() - self.tlbs = [swsscommon.SubscriberStateTable(self.appl_db, t) + self.tbls = [swsscommon.SubscriberStateTable(self.appl_db, t) for t in tbl_lst] self.cur_interfaces = {} - for t in self.tlbs: + for t in self.tbls: self.sel.addSelectable(t) def set_port_index_table_entry(self, key, index, ifindex): @@ -69,11 +69,12 @@ def listen(self): while True: (state, c) = self.sel.select(SELECT_TIMEOUT_MS) if state == swsscommon.Select.OBJECT: - for t in self.tlbs: + for t in self.tbls: (key, op, cfvs) = t.pop() if op == 'DEL' and key in self.cur_interfaces: self.update_db(key, op) elif (op == 'SET' and key != 'PortInitDone' and + key != 'PortConfigDone' and key not in self.cur_interfaces): self.update_db(key, op) elif state == swsscomm.Select.ERROR: @@ -86,9 +87,10 @@ def populate(self): while True: (state, c) = self.sel.select(SELECT_TIMEOUT_MS) if state == swsscommon.Select.OBJECT: - for t in self.tlbs: + for t in self.tbls: (key, op, cfvs) = t.pop() - if key and key != 'PortInitDone': + if (key and key != 'PortInitDone' and + key != 'PortConfigDone'): self.update_db(key, op) else: break