[202012] Replace swsssdk with swsscommon in sonic-host-services and update submodule sonic-swss-common (#8513)

#### Why I did it
Backport https://github.com/Azure/sonic-buildimage/pull/8034 to 202012 branch

sonic-swss-common submodule updating includes below commits
```
a6b98da 2021-04-29 | Add support for config_db subscribe and unsubscribe python apis (#481) [arlakshm]
2506ca0 2021-08-22 | [ci] Fix azure pipeline DownloadPipelineArtifact source branch (#514) [Qi Luo]
```
This commit is contained in:
Qi Luo 2021-09-14 18:16:18 -07:00 committed by GitHub
parent 9c5917d8dd
commit ad8a332b78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 15 additions and 17 deletions

View File

@ -20,7 +20,6 @@ try:
from sonic_py_common import daemon_base, device_info from sonic_py_common import daemon_base, device_info
from swsscommon import swsscommon from swsscommon import swsscommon
from swsssdk import SonicDBConfig, ConfigDBConnector
except ImportError as err: except ImportError as err:
raise ImportError("%s - required module not found" % str(err)) raise ImportError("%s - required module not found" % str(err))
@ -103,10 +102,10 @@ class ControlPlaneAclManager(daemon_base.DaemonBase):
self.lock[DEFAULT_NAMESPACE] = threading.Lock() self.lock[DEFAULT_NAMESPACE] = threading.Lock()
self.num_changes[DEFAULT_NAMESPACE] = 0 self.num_changes[DEFAULT_NAMESPACE] = 0
SonicDBConfig.load_sonic_global_db_config() swsscommon.SonicDBConfig.load_sonic_global_db_config()
self.config_db_map = {} self.config_db_map = {}
self.iptables_cmd_ns_prefix = {} self.iptables_cmd_ns_prefix = {}
self.config_db_map[DEFAULT_NAMESPACE] = ConfigDBConnector(use_unix_socket_path=True, namespace=DEFAULT_NAMESPACE) self.config_db_map[DEFAULT_NAMESPACE] = swsscommon.ConfigDBConnector(use_unix_socket_path=True, namespace=DEFAULT_NAMESPACE)
self.config_db_map[DEFAULT_NAMESPACE].connect() self.config_db_map[DEFAULT_NAMESPACE].connect()
self.iptables_cmd_ns_prefix[DEFAULT_NAMESPACE] = "" self.iptables_cmd_ns_prefix[DEFAULT_NAMESPACE] = ""
self.namespace_mgmt_ip = self.get_namespace_mgmt_ip(self.iptables_cmd_ns_prefix[DEFAULT_NAMESPACE], DEFAULT_NAMESPACE) self.namespace_mgmt_ip = self.get_namespace_mgmt_ip(self.iptables_cmd_ns_prefix[DEFAULT_NAMESPACE], DEFAULT_NAMESPACE)
@ -124,7 +123,7 @@ class ControlPlaneAclManager(daemon_base.DaemonBase):
self.lock[front_asic_namespace] = threading.Lock() self.lock[front_asic_namespace] = threading.Lock()
self.num_changes[front_asic_namespace] = 0 self.num_changes[front_asic_namespace] = 0
self.config_db_map[front_asic_namespace] = ConfigDBConnector(use_unix_socket_path=True, namespace=front_asic_namespace) self.config_db_map[front_asic_namespace] = swsscommon.ConfigDBConnector(use_unix_socket_path=True, namespace=front_asic_namespace)
self.config_db_map[front_asic_namespace].connect() self.config_db_map[front_asic_namespace].connect()
self.iptables_cmd_ns_prefix[front_asic_namespace] = "ip netns exec " + front_asic_namespace + " " self.iptables_cmd_ns_prefix[front_asic_namespace] = "ip netns exec " + front_asic_namespace + " "
self.namespace_docker_mgmt_ip[front_asic_namespace] = self.get_namespace_mgmt_ip(self.iptables_cmd_ns_prefix[front_asic_namespace], self.namespace_docker_mgmt_ip[front_asic_namespace] = self.get_namespace_mgmt_ip(self.iptables_cmd_ns_prefix[front_asic_namespace],

View File

@ -9,7 +9,7 @@ import syslog
import jinja2 import jinja2
from sonic_py_common import device_info from sonic_py_common import device_info
from swsssdk import ConfigDBConnector from swsscommon.swsscommon import ConfigDBConnector
# FILE # FILE
PAM_AUTH_CONF = "/etc/pam.d/common-auth-sonic" PAM_AUTH_CONF = "/etc/pam.d/common-auth-sonic"

View File

@ -12,7 +12,7 @@ import time
from datetime import datetime from datetime import datetime
from sonic_py_common import daemon_base from sonic_py_common import daemon_base
import swsssdk from swsscommon import swsscommon
VERSION = '1.0' VERSION = '1.0'
@ -25,7 +25,7 @@ class ProcDockerStats(daemon_base.DaemonBase):
def __init__(self, log_identifier): def __init__(self, log_identifier):
super(ProcDockerStats, self).__init__(log_identifier) super(ProcDockerStats, self).__init__(log_identifier)
self.state_db = swsssdk.SonicV2Connector(host=REDIS_HOSTIP) self.state_db = swsscommon.SonicV2Connector(host=REDIS_HOSTIP)
self.state_db.connect("STATE_DB") self.state_db.connect("STATE_DB")
def run_command(self, cmd): def run_command(self, cmd):

View File

@ -12,7 +12,7 @@ try:
import pwd import pwd
import sys import sys
import swsssdk from swsscommon import swsscommon
from sonic_py_common import logger from sonic_py_common import logger
except ImportError as err: except ImportError as err:
raise ImportError("%s - required module not found" % str(err)) raise ImportError("%s - required module not found" % str(err))
@ -39,7 +39,7 @@ sonic_logger = logger.Logger(SYSLOG_IDENTIFIER)
# ============================= Functions ============================= # ============================= Functions =============================
def read_reboot_cause_files_and_save_state_db(): def read_reboot_cause_files_and_save_state_db():
# Connect State DB # Connect State DB
state_db = swsssdk.SonicV2Connector(host=REDIS_HOSTIP) state_db = swsscommon.SonicV2Connector(host=REDIS_HOSTIP)
state_db.connect(state_db.STATE_DB) state_db.connect(state_db.STATE_DB)
# Sort the previous reboot cause files by creation time # Sort the previous reboot cause files by creation time

View File

@ -20,7 +20,6 @@ setup(
install_requires = [ install_requires = [
'Jinja2>=2.10', 'Jinja2>=2.10',
'sonic-py-common', 'sonic-py-common',
'swsssdk>=2.0.1',
], ],
setup_requires = [ setup_requires = [
'pytest-runner', 'pytest-runner',

View File

@ -2,7 +2,7 @@ import sys
import os import os
import pytest import pytest
import swsssdk from swsscommon import swsscommon
from sonic_py_common.general import load_module_from_source from sonic_py_common.general import load_module_from_source
# TODO: Remove this if/else block once we no longer support Python 2 # TODO: Remove this if/else block once we no longer support Python 2
@ -21,7 +21,7 @@ else:
from .mock_connector import MockConnector from .mock_connector import MockConnector
swsssdk.SonicV2Connector = MockConnector swsscommon.SonicV2Connector = MockConnector
test_path = os.path.dirname(os.path.abspath(__file__)) test_path = os.path.dirname(os.path.abspath(__file__))
modules_path = os.path.dirname(test_path) modules_path = os.path.dirname(test_path)

View File

@ -1,6 +1,6 @@
import os import os
import sys import sys
import swsssdk import swsscommon
from parameterized import parameterized from parameterized import parameterized
from sonic_py_common.general import load_module_from_source from sonic_py_common.general import load_module_from_source
@ -10,7 +10,7 @@ from .test_vectors import HOSTCFGD_TEST_VECTOR
from .mock_configdb import MockConfigDb from .mock_configdb import MockConfigDb
swsssdk.ConfigDBConnector = MockConfigDb swsscommon.swsscommon.ConfigDBConnector = MockConfigDb
test_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) test_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
modules_path = os.path.dirname(test_path) modules_path = os.path.dirname(test_path)
scripts_path = os.path.join(modules_path, "scripts") scripts_path = os.path.join(modules_path, "scripts")

View File

@ -2,12 +2,12 @@ import sys
import os import os
import pytest import pytest
import swsssdk from swsscommon import swsscommon
from sonic_py_common.general import load_module_from_source from sonic_py_common.general import load_module_from_source
from .mock_connector import MockConnector from .mock_connector import MockConnector
swsssdk.SonicV2Connector = MockConnector swsscommon.SonicV2Connector = MockConnector
test_path = os.path.dirname(os.path.abspath(__file__)) test_path = os.path.dirname(os.path.abspath(__file__))
modules_path = os.path.dirname(test_path) modules_path = os.path.dirname(test_path)

@ -1 +1 @@
Subproject commit 83d3351bc54fabb3b87789af31d664c5a0c00d00 Subproject commit a6b98daebdb5a77457747333f3832b27b669a037