Skip to content

Commit 1dacb7f

Browse files
authored
Replace pyswsssdk with swsscommon (#2251)
#### What I did Replace sonic-py-swsssdk with sonic-swss-common. #### How I did it Update all sonic-py-swsssdk to use sonic-swss-common or sonic-py-common. #### How to verify it Pass all UT and E2E test. #### Previous command output (if the output of a command-line utility has changed) #### New command output (if the output of a command-line utility has changed)
1 parent d6b8869 commit 1dacb7f

11 files changed

+35
-10
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ Currently, this list of dependencies is as follows:
2626
- libyang-cpp_1.0.73_amd64.deb
2727
- python3-yang_1.0.73_amd64.deb
2828
- redis_dump_load-1.1-py3-none-any.whl
29-
- swsssdk-2.0.1-py3-none-any.whl
3029
- sonic_py_common-1.0-py3-none-any.whl
3130
- sonic_config_engine-1.0-py3-none-any.whl
3231
- sonic_yang_mgmt-1.0-py3-none-any.whl
3332
- sonic_yang_models-1.0-py3-none-any.whl
33+
- python-swsscommon_1.0.0_amd64.deb
3434

3535

3636
A convenient alternative is to let the SONiC build system configure a build enviroment for you. This can be done by cloning the [sonic-buildimage](https://github.com/Azure/sonic-buildimage) repo, building the sonic-utilities package inside the Debian Buster slave container, and staying inside the container once the build finishes. During the build process, the SONiC build system will build and install all the necessary dependencies inside the container. After following the instructions to clone and initialize the sonic-buildimage repo, this can be done as follows:

config/config_mgmt.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
import sonic_yang
1717
from jsondiff import diff
18-
from swsssdk import port_util
18+
from sonic_py_common import port_util
1919
from swsscommon.swsscommon import SonicV2Connector, ConfigDBConnector
2020
from utilities_common.general import load_module_from_source
2121

config/main.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6611,7 +6611,7 @@ def rate():
66116611
@click.argument('rates_type', type=click.Choice(['all', 'port', 'rif', 'flowcnt-trap']), default='all')
66126612
def smoothing_interval(interval, rates_type):
66136613
"""Set rates smoothing interval """
6614-
counters_db = swsssdk.SonicV2Connector()
6614+
counters_db = SonicV2Connector()
66156615
counters_db.connect('COUNTERS_DB')
66166616

66176617
alpha = 2.0/(interval + 1)

scripts/fdbshow

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ try: # pragma: no cover
5656
except KeyError: # pragma: no cover
5757
pass
5858

59-
from swsssdk import port_util
59+
from sonic_py_common import port_util
6060
from swsscommon.swsscommon import SonicV2Connector
6161
from tabulate import tabulate
6262

scripts/nbrshow

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import subprocess
3333
import re
3434

3535
from natsort import natsorted
36-
from swsssdk import port_util
36+
from sonic_py_common import port_util
3737
from swsscommon.swsscommon import SonicV2Connector
3838
from tabulate import tabulate
3939

setup.py

-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@
211211
'sonic-platform-common',
212212
'sonic-py-common',
213213
'sonic-yang-mgmt',
214-
'swsssdk>=2.0.1',
215214
'tabulate==0.8.2',
216215
'toposort==1.6',
217216
'www-authenticate==0.9.2',

tests/config_test.py

+28
Original file line numberDiff line numberDiff line change
@@ -1557,3 +1557,31 @@ def teardown_class(cls):
15571557
from .mock_tables import mock_single_asic
15581558
importlib.reload(mock_single_asic)
15591559
dbconnector.load_namespace_config()
1560+
1561+
class TestConfigRate(object):
1562+
@classmethod
1563+
def setup_class(cls):
1564+
os.environ['UTILITIES_UNIT_TESTING'] = "1"
1565+
print("SETUP")
1566+
1567+
import config.main
1568+
importlib.reload(config.main)
1569+
1570+
def test_config_rate(self, get_cmd_module, setup_single_broadcom_asic):
1571+
with mock.patch("utilities_common.cli.run_command", mock.MagicMock(side_effect=mock_run_command_side_effect)) as mock_run_command:
1572+
(config, show) = get_cmd_module
1573+
1574+
runner = CliRunner()
1575+
result = runner.invoke(config.config.commands["rate"], ["smoothing-interval", "500"])
1576+
1577+
print(result.exit_code)
1578+
print(result.output)
1579+
traceback.print_tb(result.exc_info[2])
1580+
1581+
assert result.exit_code == 0
1582+
assert result.output == ""
1583+
1584+
@classmethod
1585+
def teardown_class(cls):
1586+
print("TEARDOWN")
1587+
os.environ['UTILITIES_UNIT_TESTING'] = "0"

tests/db_migrator_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from deepdiff import DeepDiff
66

7-
from swsssdk import SonicV2Connector
7+
from swsscommon.swsscommon import SonicV2Connector
88
from sonic_py_common import device_info
99

1010
from .mock_tables import dbconnector

tests/null_route_helper_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import imp
44

55
from click.testing import CliRunner
6-
from swsssdk import ConfigDBConnector
6+
from swsscommon.swsscommon import ConfigDBConnector
77

88
null_route_helper = imp.load_source('null_route_helper', os.path.join(os.path.dirname(__file__), '..', 'scripts','null_route_helper'))
99
null_route_helper.ConfigDBConnector = ConfigDBConnector

tests/show_snmp_test.py

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import click
44
from click.testing import CliRunner
55
import pytest
6-
import swsssdk
76
import traceback
87

98
test_path = os.path.dirname(os.path.abspath(__file__))

tests/tpid_test.py

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import click
44
from click.testing import CliRunner
55
import pytest
6-
import swsssdk
76
import traceback
87

98
test_path = os.path.dirname(os.path.abspath(__file__))

0 commit comments

Comments
 (0)