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 swsssdk.SonicV2Connector with swsscommon.SonicV2Connector (SWIG wrapper of C++ implementation) in production code #1217

Merged
merged 3 commits into from
Nov 6, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 2 additions & 1 deletion acl_loader/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
import pyangbind.lib.pybindJSON as pybindJSON
from natsort import natsorted
from sonic_py_common import device_info
from swsssdk import ConfigDBConnector, SonicV2Connector, SonicDBConfig
from swsssdk import ConfigDBConnector, SonicDBConfig
from swsscommon.swsscommon import SonicV2Connector


def info(msg):
Expand Down
3 changes: 2 additions & 1 deletion config/config_mgmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

# SONiC specific imports
import sonic_yang
from swsssdk import ConfigDBConnector, SonicV2Connector, port_util
from swsssdk import ConfigDBConnector, port_util
from swsscommon.swsscommon import SonicV2Connector

# Using load_source to 'import /usr/local/bin/sonic-cfggen as sonic_cfggen'
# since /usr/local/bin/sonic-cfggen does not have .py extension.
Expand Down
3 changes: 2 additions & 1 deletion config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
from portconfig import get_child_ports
from sonic_py_common import device_info, multi_asic
from sonic_py_common.interface import get_interface_table_name, get_port_table_name
from swsssdk import ConfigDBConnector, SonicV2Connector, SonicDBConfig
from swsssdk import ConfigDBConnector, SonicDBConfig
from swsscommon.swsscommon import SonicV2Connector
from utilities_common.db import Db
from utilities_common.intf_filter import parse_interface_in_filter
import utilities_common.cli as clicommon
Expand Down
2 changes: 1 addition & 1 deletion config/nat.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import click
import ipaddress
from swsssdk import ConfigDBConnector
from swsssdk import SonicV2Connector
from swsscommon.swsscommon import SonicV2Connector

def is_valid_ipv4_address(address):
"""Check if the given ipv4 address is valid"""
Expand Down
3 changes: 2 additions & 1 deletion scripts/db_migrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import traceback

from sonic_py_common import device_info, logger
from swsssdk import ConfigDBConnector, SonicDBConfig, SonicV2Connector
from swsssdk import ConfigDBConnector, SonicDBConfig
from swsscommon.swsscommon import SonicV2Connector


SYSLOG_IDENTIFIER = 'db_migrator'
Expand Down
2 changes: 1 addition & 1 deletion scripts/fanshow
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ from __future__ import print_function
import os
import sys
from tabulate import tabulate
from swsssdk import SonicV2Connector
from natsort import natsorted

# mock the redis for unit test purposes #
Expand All @@ -21,6 +20,7 @@ try:
except KeyError:
pass

from swsscommon.swsscommon import SonicV2Connector

header = ['Drawer', 'LED', 'FAN', 'Speed', 'Direction', 'Presence', 'Status', 'Timestamp']

Expand Down
3 changes: 2 additions & 1 deletion scripts/fdbclear
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import argparse
import json
import sys

from swsssdk import SonicV2Connector

class FdbClear(object):

Expand All @@ -32,6 +31,8 @@ class FdbClear(object):
self.db.publish('APPL_DB','FLUSHFDBREQUEST', msg)
return

from swsscommon.swsscommon import SonicV2Connector

def main():

parser = argparse.ArgumentParser(description='Clear FDB entries', formatter_class=argparse.RawTextHelpFormatter)
Expand Down
3 changes: 2 additions & 1 deletion scripts/fdbshow
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ import json
import sys

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

class FdbShow(object):
Expand Down
2 changes: 1 addition & 1 deletion scripts/natclear
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import argparse
import json
import sys

from swsssdk import SonicV2Connector
from swsscommon.swsscommon import SonicV2Connector

class NatClear(object):

Expand Down
2 changes: 1 addition & 1 deletion scripts/natshow
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ import json
import sys
import re

from swsssdk import SonicV2Connector
from swsscommon.swsscommon import SonicV2Connector
from tabulate import tabulate

class NatShow(object):
Expand Down
3 changes: 2 additions & 1 deletion scripts/nbrshow
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ import subprocess
import re

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

"""
Expand Down
3 changes: 2 additions & 1 deletion scripts/neighbor_advertiser
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import traceback
import warnings

from sonic_py_common import logger
from swsssdk import ConfigDBConnector, SonicV2Connector
from swsssdk import ConfigDBConnector
from swsscommon.swsscommon import SonicV2Connector
from netaddr import IPAddress, IPNetwork


Expand Down
3 changes: 2 additions & 1 deletion scripts/psushow
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import argparse
import sys
import os
from swsssdk import SonicV2Connector
from tabulate import tabulate

# mock the redis for unit test purposes #
Expand All @@ -17,6 +16,8 @@ try:
except KeyError:
pass

from swsscommon.swsscommon import SonicV2Connector

def psu_status_show(index):
db = SonicV2Connector(host="127.0.0.1")
db.connect(db.STATE_DB)
Expand Down
2 changes: 1 addition & 1 deletion scripts/tempershow
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from __future__ import print_function

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


Expand Down
2 changes: 1 addition & 1 deletion show/fgnhg.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import click
import utilities_common.cli as clicommon
from swsssdk import ConfigDBConnector
from swsssdk import SonicV2Connector
from swsscommon.swsscommon import SonicV2Connector
from tabulate import tabulate


Expand Down
3 changes: 2 additions & 1 deletion show/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
import fgnhg

from sonic_py_common import device_info, multi_asic
from swsssdk import ConfigDBConnector, SonicV2Connector
from swsssdk import ConfigDBConnector
from swsscommon.swsscommon import SonicV2Connector
from tabulate import tabulate
from utilities_common.db import Db
import utilities_common.multi_asic as multi_asic_util
Expand Down
2 changes: 1 addition & 1 deletion sonic_installer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import click
from sonic_py_common import logger
from swsssdk import SonicV2Connector
from swsscommon.swsscommon import SonicV2Connector

from .bootloader import get_bootloader
from .common import run_command, run_command_or_raise
Expand Down
6 changes: 4 additions & 2 deletions tests/mock_tables/dbconnector.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

import mock
import mockredis
import swsssdk.interface
import redis
import swsssdk
from sonic_py_common import multi_asic
from swsssdk import SonicDBConfig, SonicV2Connector
from swsssdk.interface import redis
from swsscommon import swsscommon

topo = None

Expand Down Expand Up @@ -137,3 +138,4 @@ def keys(self, pattern='*'):
mockredis.MockRedis.config_set = config_set
redis.StrictRedis = SwssSyncClient
SonicV2Connector.connect = connect_SonicV2Connector
swsscommon.SonicV2Connector = SonicV2Connector