Skip to content

Replace py-swsssdk with swsscommon #5926

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

Merged
merged 4 commits into from
Jul 13, 2022

Conversation

liuh-80
Copy link
Contributor

@liuh-80 liuh-80 commented Jul 5, 2022

Description of PR

Replace sonic-py-swsssdk with sonic-swss-common.

Type of change

  • Bug fix
  • Testbed and Framework(new/improvement)
  • Test case(new/improvement)

Back port request

  • 201911
  • 202012

Approach

What is the motivation for this PR?

deprecate sonic-py-swsssdk and switch to sonic-swss-common.

How did you do it?

Replace sonic-py-swsssdk with sonic-swss-common.

How did you verify/test it?

Pass all UT.

Any platform specific information?

Supported testbed topology if it's a new test case?

Documentation

@liuh-80
Copy link
Contributor Author

liuh-80 commented Jul 5, 2022

This PR depends on another PR to merge first:
sonic-net/sonic-buildimage#11215

@liuh-80
Copy link
Contributor Author

liuh-80 commented Jul 8, 2022

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@liuh-80 liuh-80 changed the title [WIP] Replace py-swsssdk with swsscommon Replace py-swsssdk with swsscommon Jul 11, 2022
@liuh-80 liuh-80 requested a review from qiluo-msft July 11, 2022 02:02
@liuh-80 liuh-80 marked this pull request as ready for review July 11, 2022 02:02
@liuh-80 liuh-80 requested a review from a team as a code owner July 11, 2022 02:02
@@ -114,7 +114,7 @@ def get_ifindex(duthost, port):

def get_port_index(duthost, port):
py_version = 'python' if '201911' in duthost.os_version else 'python3'
Copy link
Contributor

Choose a reason for hiding this comment

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

201911

If the code is testing an old image (such as 201911 branch image), will it break?

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.
Add code to check if the sonic_py_common.port_util class exist.

@@ -1,6 +1,6 @@
#!/usr/bin/python

import swsssdk
from swsscommon import swsscommon
Copy link
Contributor

Choose a reason for hiding this comment

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

swsscommon

Is it compatible to old images?

Copy link
Contributor Author

@liuh-80 liuh-80 Jul 12, 2022

Choose a reason for hiding this comment

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

The code change may break on old device, I will test with 2018 image on by devbox.

Copy link
Contributor Author

@liuh-80 liuh-80 Jul 12, 2022

Choose a reason for hiding this comment

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

Fixed.
Manually test on 201911 and latest master branch. this script and related UT does not run on 201811 version.

Copy link
Contributor

Choose a reason for hiding this comment

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

The sonic-mgmt master branch will not be used to test 201811 and older branch images. If this is the truth, then it is good enough, and no need to improve.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The fix is necessary because SonicDBConfig.load_sonic_global_db_config() added on 2021, so on 2019 swsscommon exist but we still need use swsssdk.

qiluo-msft
qiluo-msft previously approved these changes Jul 12, 2022
try:
import swsssdk
except ImportError:
from swsscommon import swsscommon
Copy link
Contributor

Choose a reason for hiding this comment

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

from swsscommon import swsscommon

Could you explore importing the classes? Then the code could be unified.

from swsscommon.swsscommon import SonicDBConfig, 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.

Fixed.

@liuh-80 liuh-80 merged commit 830d17d into sonic-net:master Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants