Skip to content

Commit

Permalink
Replace swsssdk's SonicV2Connector with swsscommon's implementation (s…
Browse files Browse the repository at this point in the history
…onic-net#35)

swsssdk is going to be deprecated. swsscommon provides similar implementation by SWIG wrapping C++ common library.

Tested in unit test and DUT.
  • Loading branch information
qiluo-msft authored Feb 19, 2021
1 parent 5cc29a1 commit 3c9f488
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/lldp_syncd/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from collections import defaultdict

from enum import unique, Enum
from swsssdk import SonicV2Connector
from swsscommon.swsscommon import SonicV2Connector

from sonic_syncd import SonicSyncDaemon
from . import logger
Expand Down
14 changes: 9 additions & 5 deletions tests/mock_tables/dbconnector.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
import sys

import mockredis
import swsssdk.interface
from swsssdk.interface import redis
import redis
from swsssdk import SonicV2Connector
from swsssdk import SonicDBConfig
from swsssdk.interface import DBInterface
from swsscommon import swsscommon


if sys.version_info >= (3, 0):
long = int
Expand Down Expand Up @@ -79,8 +82,8 @@ def _encode(self, value):
value = super(SwssSyncClient, self)._encode(value)

if self.decode_responses:
return value.decode('utf-8')
return value.decode('utf-8')

# Patch mockredis/mockredis/client.py
# The official implementation will filter out keys with a slash '/'
# ref: https://github.com/locationlabs/mockredis/blob/master/mockredis/client.py
Expand All @@ -105,7 +108,8 @@ def keys(self, pattern='*'):
return [key for key in self.redis.keys() if regex.match(key)]


swsssdk.interface.DBInterface._subscribe_keyspace_notification = _subscribe_keyspace_notification
DBInterface._subscribe_keyspace_notification = _subscribe_keyspace_notification
mockredis.MockRedis.config_set = config_set
redis.StrictRedis = SwssSyncClient
SonicV2Connector.connect = connect_SonicV2Connector
swsscommon.SonicV2Connector = SonicV2Connector
2 changes: 1 addition & 1 deletion tests/test_lldpSyncDaemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import lldp_syncd
import lldp_syncd.conventions
import lldp_syncd.daemon
from swsssdk import SonicV2Connector, ConfigDBConnector
from swsssdk import SonicV2Connector

INPUT_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'subproc_outputs')

Expand Down

0 comments on commit 3c9f488

Please sign in to comment.