sonic-config-engine uses libswsscommon instead of swsssdk (#6406)
**- Why I did it** swsssdk will be deprecated. Migrate sonic-config-engine to use libswsscommon library instead **- How to verify it** Unit test
This commit is contained in:
parent
77ec2ee14e
commit
28b62bee3f
@ -31,6 +31,11 @@ if [[ -f /usr/share/sonic/virtual_chassis/default_config.json ]]; then
|
|||||||
CHASS_CFG="-j /usr/share/sonic/virtual_chassis/default_config.json"
|
CHASS_CFG="-j /usr/share/sonic/virtual_chassis/default_config.json"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Note: libswsscommon requires a dabase_config file in /var/run/redis/sonic-db/
|
||||||
|
# Prepare this file before any dependent application, such as sonic-cfggen
|
||||||
|
mkdir -p /var/run/redis/sonic-db
|
||||||
|
cp /etc/default/sonic-db/database_config.json /var/run/redis/sonic-db/
|
||||||
|
|
||||||
SYSTEM_MAC_ADDRESS=$(ip link show eth0 | grep ether | awk '{print $2}')
|
SYSTEM_MAC_ADDRESS=$(ip link show eth0 | grep ether | awk '{print $2}')
|
||||||
sonic-cfggen -a '{"DEVICE_METADATA":{"localhost": {"mac": "'$SYSTEM_MAC_ADDRESS'", "buffer_model": "traditional"}}}' $CHASS_CFG --print-data > /etc/sonic/init_cfg.json
|
sonic-cfggen -a '{"DEVICE_METADATA":{"localhost": {"mac": "'$SYSTEM_MAC_ADDRESS'", "buffer_model": "traditional"}}}' $CHASS_CFG --print-data > /etc/sonic/init_cfg.json
|
||||||
|
|
||||||
@ -68,9 +73,6 @@ else
|
|||||||
echo "10.8.1.200 redis_chassis.server" >> /etc/hosts
|
echo "10.8.1.200 redis_chassis.server" >> /etc/hosts
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p /var/run/redis/sonic-db
|
|
||||||
cp /etc/default/sonic-db/database_config.json /var/run/redis/sonic-db/
|
|
||||||
|
|
||||||
supervisorctl start redis-server
|
supervisorctl start redis-server
|
||||||
|
|
||||||
start_chassis_db=`sonic-cfggen -v DEVICE_METADATA.localhost.start_chassis_db -y $chassisdb_cfg_file`
|
start_chassis_db=`sonic-cfggen -v DEVICE_METADATA.localhost.start_chassis_db -y $chassisdb_cfg_file`
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
SONIC_CONFIG_ENGINE_PY2 = sonic_config_engine-1.0-py2-none-any.whl
|
SONIC_CONFIG_ENGINE_PY2 = sonic_config_engine-1.0-py2-none-any.whl
|
||||||
$(SONIC_CONFIG_ENGINE_PY2)_SRC_PATH = $(SRC_PATH)/sonic-config-engine
|
$(SONIC_CONFIG_ENGINE_PY2)_SRC_PATH = $(SRC_PATH)/sonic-config-engine
|
||||||
$(SONIC_CONFIG_ENGINE_PY2)_DEPENDS += $(SWSSSDK_PY2) $(SONIC_PY_COMMON_PY2)
|
$(SONIC_CONFIG_ENGINE_PY2)_DEPENDS += $(SONIC_PY_COMMON_PY2)
|
||||||
|
$(SONIC_CONFIG_ENGINE_PY2)_DEBS_DEPENDS += $(PYTHON_SWSSCOMMON)
|
||||||
$(SONIC_CONFIG_ENGINE_PY2)_PYTHON_VERSION = 2
|
$(SONIC_CONFIG_ENGINE_PY2)_PYTHON_VERSION = 2
|
||||||
SONIC_PYTHON_WHEELS += $(SONIC_CONFIG_ENGINE_PY2)
|
SONIC_PYTHON_WHEELS += $(SONIC_CONFIG_ENGINE_PY2)
|
||||||
|
|
||||||
@ -10,7 +11,8 @@ SONIC_PYTHON_WHEELS += $(SONIC_CONFIG_ENGINE_PY2)
|
|||||||
|
|
||||||
SONIC_CONFIG_ENGINE_PY3 = sonic_config_engine-1.0-py3-none-any.whl
|
SONIC_CONFIG_ENGINE_PY3 = sonic_config_engine-1.0-py3-none-any.whl
|
||||||
$(SONIC_CONFIG_ENGINE_PY3)_SRC_PATH = $(SRC_PATH)/sonic-config-engine
|
$(SONIC_CONFIG_ENGINE_PY3)_SRC_PATH = $(SRC_PATH)/sonic-config-engine
|
||||||
$(SONIC_CONFIG_ENGINE_PY3)_DEPENDS += $(SWSSSDK_PY3) $(SONIC_PY_COMMON_PY3)
|
$(SONIC_CONFIG_ENGINE_PY3)_DEPENDS += $(SONIC_PY_COMMON_PY3)
|
||||||
|
$(SONIC_CONFIG_ENGINE_PY3)_DEBS_DEPENDS += $(PYTHON3_SWSSCOMMON)
|
||||||
# Synthetic dependency to avoid building the Python 2 and 3 packages
|
# Synthetic dependency to avoid building the Python 2 and 3 packages
|
||||||
# simultaneously and any potential conflicts which may arise
|
# simultaneously and any potential conflicts which may arise
|
||||||
$(SONIC_CONFIG_ENGINE_PY3)_DEPENDS += $(SONIC_CONFIG_ENGINE_PY2)
|
$(SONIC_CONFIG_ENGINE_PY3)_DEPENDS += $(SONIC_CONFIG_ENGINE_PY2)
|
||||||
|
@ -5,7 +5,7 @@ try:
|
|||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from swsssdk import ConfigDBConnector
|
from swsscommon.swsscommon import ConfigDBConnector
|
||||||
from sonic_py_common import device_info
|
from sonic_py_common import device_info
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
raise ImportError("%s - required module not found" % str(e))
|
raise ImportError("%s - required module not found" % str(e))
|
||||||
|
@ -19,11 +19,11 @@ class RedisBytecodeCache(jinja2.BytecodeCache):
|
|||||||
return
|
return
|
||||||
code = self._client.get(self._client.LOGLEVEL_DB, self.REDIS_HASH, bucket.key)
|
code = self._client.get(self._client.LOGLEVEL_DB, self.REDIS_HASH, bucket.key)
|
||||||
if code is not None:
|
if code is not None:
|
||||||
bucket.bytecode_from_string(b64decode(code))
|
bucket.bytecode_from_string(b64decode(code.encode()))
|
||||||
|
|
||||||
def dump_bytecode(self, bucket):
|
def dump_bytecode(self, bucket):
|
||||||
if self._client is None:
|
if self._client is None:
|
||||||
return
|
return
|
||||||
self._client.set(self._client.LOGLEVEL_DB, self.REDIS_HASH,
|
self._client.set(self._client.LOGLEVEL_DB, self.REDIS_HASH,
|
||||||
bucket.key, b64encode(bucket.bytecode_to_string()))
|
bucket.key, b64encode(bucket.bytecode_to_string()).decode())
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ from portconfig import get_port_config, get_breakout_mode
|
|||||||
from redis_bcc import RedisBytecodeCache
|
from redis_bcc import RedisBytecodeCache
|
||||||
from sonic_py_common.multi_asic import get_asic_id_from_name, is_multi_asic
|
from sonic_py_common.multi_asic import get_asic_id_from_name, is_multi_asic
|
||||||
from sonic_py_common import device_info
|
from sonic_py_common import device_info
|
||||||
from swsssdk import SonicV2Connector, ConfigDBConnector, SonicDBConfig, ConfigDBPipeConnector
|
from swsscommon.swsscommon import SonicV2Connector, ConfigDBConnector, SonicDBConfig, ConfigDBPipeConnector
|
||||||
|
|
||||||
|
|
||||||
PY3x = sys.version_info >= (3, 0)
|
PY3x = sys.version_info >= (3, 0)
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 2db7bea9963a988a575b8075e1f6c5369d057230
|
Subproject commit 2f79bb49d13820f2c108e4e27a2a12181713662f
|
Reference in New Issue
Block a user