Add multi ASIC support for syslog rate limit feature

This commit is contained in:
Junchao-Mellanox 2024-03-21 10:51:04 +02:00
parent ec57a44b47
commit cc29dd91ab
2 changed files with 11 additions and 3 deletions

View File

@ -23,6 +23,7 @@ SYSLOG_RATE_LIMIT_BURST = 'rate_limit_burst'
# Container name
container_name = None
service_name = None
def run_command(command):
@ -117,7 +118,7 @@ class SyslogHandler:
data (dict): Data of the entry: {<field_name>: <field_value>}
"""
try:
if key != container_name:
if key != service_name:
return
self.update_syslog_config(data)
except Exception as e:
@ -130,8 +131,8 @@ class SyslogHandler:
init_data (dict): Initial data when first time connecting to CONFIG DB. {<table_name>: {<field_name>: <field_value>}}
"""
if SYSLOG_CONFIG_FEATURE_TABLE in init_data:
if container_name in init_data[SYSLOG_CONFIG_FEATURE_TABLE]:
self.update_syslog_config(init_data[SYSLOG_CONFIG_FEATURE_TABLE][container_name])
if service_name in init_data[SYSLOG_CONFIG_FEATURE_TABLE]:
self.update_syslog_config(init_data[SYSLOG_CONFIG_FEATURE_TABLE][service_name])
def update_syslog_config(self, data):
"""Parse existing syslog conf and apply new syslog conf.
@ -185,7 +186,13 @@ class SyslogHandler:
def main():
global container_name
global service_name
namespace_id = os.environ['NAMESPACE_ID']
container_name = os.environ['CONTAINER_NAME']
if not namespace_id:
service_name = container_name
else:
service_name = container_name.rstrip(namespace_id)
daemon = ContainerConfigDaemon()
daemon.run()

View File

@ -12,6 +12,7 @@ sys.path.insert(0, modules_path)
from containercfgd import containercfgd
containercfgd.container_name = 'swss'
containercfgd.service_name = 'swss'
def test_handle_config():