Skip to content

Commit

Permalink
Replace swsssdk with swsscommon (#2368)
Browse files Browse the repository at this point in the history
**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**
  • Loading branch information
liuh-80 authored Jul 11, 2022
1 parent bf91a49 commit 0c3c9c6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
5 changes: 2 additions & 3 deletions fpmsyncd/bgp_eoiu_marker.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"""

import sys
import swsssdk
import time
import syslog
import traceback
Expand Down Expand Up @@ -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)
Expand All @@ -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")
Expand Down
7 changes: 3 additions & 4 deletions neighsyncd/restore_neighbors.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"""

import sys
import swsssdk
import netifaces
import time
from pyroute2 import IPRoute, NetlinkError
Expand Down Expand Up @@ -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 = {}
Expand Down Expand Up @@ -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)
Expand All @@ -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()):
Expand Down

0 comments on commit 0c3c9c6

Please sign in to comment.