[cfggen] Use Redis Pipeline (#5250)
This PR enables cfggen to readr/write from Redis DB using pipelines. Pipelines enables batch read/write from/to Redis DB. signed-off-by: Tamer Ahmed <tamer.ahmed@microsoft.com>
This commit is contained in:
parent
a38105237c
commit
a8016a6987
@ -46,7 +46,7 @@ from sonic_py_common.device_info import get_platform, get_system_mac
|
|||||||
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 config_samples import generate_sample_config
|
from config_samples import generate_sample_config
|
||||||
from config_samples import get_available_config
|
from config_samples import get_available_config
|
||||||
from swsssdk import SonicV2Connector, ConfigDBConnector, SonicDBConfig
|
from swsssdk import SonicV2Connector, ConfigDBConnector, SonicDBConfig, ConfigDBPipeConnector
|
||||||
from redis_bcc import RedisBytecodeCache
|
from redis_bcc import RedisBytecodeCache
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from natsort import natsorted
|
from natsort import natsorted
|
||||||
@ -340,9 +340,9 @@ def main():
|
|||||||
|
|
||||||
if args.from_db:
|
if args.from_db:
|
||||||
if args.namespace is None:
|
if args.namespace is None:
|
||||||
configdb = ConfigDBConnector(use_unix_socket_path=True, **db_kwargs)
|
configdb = ConfigDBPipeConnector(use_unix_socket_path=True, **db_kwargs)
|
||||||
else:
|
else:
|
||||||
configdb = ConfigDBConnector(use_unix_socket_path=True, namespace=args.namespace, **db_kwargs)
|
configdb = ConfigDBPipeConnector(use_unix_socket_path=True, namespace=args.namespace, **db_kwargs)
|
||||||
|
|
||||||
configdb.connect()
|
configdb.connect()
|
||||||
deep_update(data, FormatConverter.db_to_output(configdb.get_config()))
|
deep_update(data, FormatConverter.db_to_output(configdb.get_config()))
|
||||||
@ -401,9 +401,9 @@ def main():
|
|||||||
|
|
||||||
if args.write_to_db:
|
if args.write_to_db:
|
||||||
if args.namespace is None:
|
if args.namespace is None:
|
||||||
configdb = ConfigDBConnector(use_unix_socket_path=True, **db_kwargs)
|
configdb = ConfigDBPipeConnector(use_unix_socket_path=True, **db_kwargs)
|
||||||
else:
|
else:
|
||||||
configdb = ConfigDBConnector(use_unix_socket_path=True, namespace=args.namespace, **db_kwargs)
|
configdb = ConfigDBPipeConnector(use_unix_socket_path=True, namespace=args.namespace, **db_kwargs)
|
||||||
|
|
||||||
configdb.connect(False)
|
configdb.connect(False)
|
||||||
configdb.mod_config(FormatConverter.output_to_db(data))
|
configdb.mod_config(FormatConverter.output_to_db(data))
|
||||||
|
Loading…
Reference in New Issue
Block a user