Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace pyswsssdk with swsscommon #2251

Merged
merged 6 commits into from
Jul 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ Currently, this list of dependencies is as follows:
- libyang-cpp_1.0.73_amd64.deb
- python3-yang_1.0.73_amd64.deb
- redis_dump_load-1.1-py3-none-any.whl
- swsssdk-2.0.1-py3-none-any.whl
Copy link
Contributor

@qiluo-msft qiluo-msft Jul 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

swsssdk

Add "python-swsscommon_1.0.0_amd64.deb" into the list? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

- sonic_py_common-1.0-py3-none-any.whl
- sonic_config_engine-1.0-py3-none-any.whl
- sonic_yang_mgmt-1.0-py3-none-any.whl
- sonic_yang_models-1.0-py3-none-any.whl
- python-swsscommon_1.0.0_amd64.deb


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:
Expand Down
2 changes: 1 addition & 1 deletion config/config_mgmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import sonic_yang
from jsondiff import diff
from swsssdk import port_util
from sonic_py_common import port_util
from swsscommon.swsscommon import SonicV2Connector, ConfigDBConnector
from utilities_common.general import load_module_from_source

Expand Down
2 changes: 1 addition & 1 deletion config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6539,7 +6539,7 @@ def rate():
@click.argument('rates_type', type=click.Choice(['all', 'port', 'rif', 'flowcnt-trap']), default='all')
def smoothing_interval(interval, rates_type):
"""Set rates smoothing interval """
counters_db = swsssdk.SonicV2Connector()
counters_db = SonicV2Connector()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following API missing in sonic-swss-common:

int64_t SonicV2Connector_Native::set(const std::string& db_name, const std::string& _hash, const std::string& key, const int val, bool blocking=false);

So this PR need wait for swss-common add the missing API first.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create another PR to add the set method:

sonic-net/sonic-swss-common#648

counters_db.connect('COUNTERS_DB')

alpha = 2.0/(interval + 1)
Expand Down
2 changes: 1 addition & 1 deletion scripts/fdbshow
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ try: # pragma: no cover
except KeyError: # pragma: no cover
pass

from swsssdk import port_util
from sonic_py_common import port_util
from swsscommon.swsscommon import SonicV2Connector
from tabulate import tabulate

Expand Down
2 changes: 1 addition & 1 deletion scripts/nbrshow
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import subprocess
import re

from natsort import natsorted
from swsssdk import port_util
from sonic_py_common import port_util
from swsscommon.swsscommon import SonicV2Connector
from tabulate import tabulate

Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@
'sonic-platform-common',
'sonic-py-common',
'sonic-yang-mgmt',
'swsssdk>=2.0.1',
'tabulate==0.8.2',
'toposort==1.6',
'www-authenticate==0.9.2',
Expand Down
28 changes: 28 additions & 0 deletions tests/config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1486,3 +1486,31 @@ def teardown_class(cls):
from .mock_tables import mock_single_asic
importlib.reload(mock_single_asic)
dbconnector.load_namespace_config()

class TestConfigRate(object):
@classmethod
def setup_class(cls):
os.environ['UTILITIES_UNIT_TESTING'] = "1"
print("SETUP")

import config.main
importlib.reload(config.main)

def test_config_rate(self, get_cmd_module, setup_single_broadcom_asic):
with mock.patch("utilities_common.cli.run_command", mock.MagicMock(side_effect=mock_run_command_side_effect)) as mock_run_command:
(config, show) = get_cmd_module

runner = CliRunner()
result = runner.invoke(config.config.commands["rate"], ["smoothing-interval", "500"])

print(result.exit_code)
print(result.output)
traceback.print_tb(result.exc_info[2])

assert result.exit_code == 0
assert result.output == ""

@classmethod
def teardown_class(cls):
print("TEARDOWN")
os.environ['UTILITIES_UNIT_TESTING'] = "0"
2 changes: 1 addition & 1 deletion tests/db_migrator_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from deepdiff import DeepDiff

from swsssdk import SonicV2Connector
from swsscommon.swsscommon import SonicV2Connector
from sonic_py_common import device_info

from .mock_tables import dbconnector
Expand Down
2 changes: 1 addition & 1 deletion tests/null_route_helper_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import imp

from click.testing import CliRunner
from swsssdk import ConfigDBConnector
from swsscommon.swsscommon import ConfigDBConnector

null_route_helper = imp.load_source('null_route_helper', os.path.join(os.path.dirname(__file__), '..', 'scripts','null_route_helper'))
null_route_helper.ConfigDBConnector = ConfigDBConnector
Expand Down
1 change: 0 additions & 1 deletion tests/show_snmp_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import click
from click.testing import CliRunner
import pytest
import swsssdk
import traceback

test_path = os.path.dirname(os.path.abspath(__file__))
Expand Down
1 change: 0 additions & 1 deletion tests/tpid_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import click
from click.testing import CliRunner
import pytest
import swsssdk
import traceback

test_path = os.path.dirname(os.path.abspath(__file__))
Expand Down