From 0c3c9c671f6e53d6c1940f907be47983d3c1b0f4 Mon Sep 17 00:00:00 2001 From: Hua Liu <58683130+liuh-80@users.noreply.github.com> Date: Mon, 11 Jul 2022 09:59:24 +0800 Subject: [PATCH] Replace swsssdk with swsscommon (#2368) **What I did** Replace py-swsssdk with sonic-swss-common **Why I did it** To deprecate py-swsssdk, need replace it from code. **How I verified it** Pass all UT. **Details if related** --- fpmsyncd/bgp_eoiu_marker.py | 5 ++--- neighsyncd/restore_neighbors.py | 7 +++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/fpmsyncd/bgp_eoiu_marker.py b/fpmsyncd/bgp_eoiu_marker.py index 83051d7878a7..d7f144e4bfbd 100644 --- a/fpmsyncd/bgp_eoiu_marker.py +++ b/fpmsyncd/bgp_eoiu_marker.py @@ -17,7 +17,6 @@ """ import sys -import swsssdk import time import syslog import traceback @@ -80,7 +79,7 @@ def init_peers_eor_status(self): # Only two families: 'ipv4' and 'ipv6' # state is "unknown" / "reached" / "consumed" def set_bgp_eoiu_marker(self, family, state): - db = swsssdk.SonicV2Connector(host='127.0.0.1') + db = swsscommon.SonicV2Connector(host='127.0.0.1') db.connect(db.STATE_DB, False) key = "BGP_STATE_TABLE|%s|eoiu" % family db.set(db.STATE_DB, key, 'state', state) @@ -90,7 +89,7 @@ def set_bgp_eoiu_marker(self, family, state): return def clean_bgp_eoiu_marker(self): - db = swsssdk.SonicV2Connector(host='127.0.0.1') + db = swsscommon.SonicV2Connector(host='127.0.0.1') db.connect(db.STATE_DB, False) db.delete(db.STATE_DB, "BGP_STATE_TABLE|IPv4|eoiu") db.delete(db.STATE_DB, "BGP_STATE_TABLE|IPv6|eoiu") diff --git a/neighsyncd/restore_neighbors.py b/neighsyncd/restore_neighbors.py index fac7b1f2df49..a02e5434fcdd 100755 --- a/neighsyncd/restore_neighbors.py +++ b/neighsyncd/restore_neighbors.py @@ -13,7 +13,6 @@ """ import sys -import swsssdk import netifaces import time from pyroute2 import IPRoute, NetlinkError @@ -117,7 +116,7 @@ def is_intf_up(intf, db): # 2, need check interface state twice due to the split map def read_neigh_table_to_maps(): - db = swsssdk.SonicV2Connector(host='127.0.0.1') + db = swsscommon.SonicV2Connector(host='127.0.0.1') db.connect(db.APPL_DB, False) intf_neigh_map = {} @@ -207,7 +206,7 @@ def build_arp_ns_pkt(family, smac, src_ip, dst_ip): # Set the statedb "NEIGH_RESTORE_TABLE|Flags", so neighsyncd can start reconciliation def set_statedb_neigh_restore_done(): - db = swsssdk.SonicV2Connector(host='127.0.0.1') + db = swsscommon.SonicV2Connector(host='127.0.0.1') db.connect(db.STATE_DB, False) db.set(db.STATE_DB, 'NEIGH_RESTORE_TABLE|Flags', 'restored', 'true') db.close(db.STATE_DB) @@ -228,7 +227,7 @@ def restore_update_kernel_neighbors(intf_neigh_map, timeout=DEF_TIME_OUT): ipclass = IPRoute() start_time = time.monotonic() is_intf_up.counter = 0 - db = swsssdk.SonicV2Connector(host='127.0.0.1') + db = swsscommon.SonicV2Connector(host='127.0.0.1') db.connect(db.STATE_DB, False) while (time.monotonic() - start_time) < timeout: for intf, family_neigh_map in list(intf_neigh_map.items()):