Skip to content

Commit

Permalink
Fix review comment
Browse files Browse the repository at this point in the history
  • Loading branch information
Junchao-Mellanox committed Nov 10, 2022
1 parent 8018f6b commit d2aead9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
4 changes: 2 additions & 2 deletions config/syslog.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,8 +462,8 @@ def rate_limit_host(db, interval, burst):

@syslog.command("rate-limit-container")
@click.argument("service_name", required=True)
@click.option("-i", "--interval", help="Configures syslog rate limit interval in seconds for containers", type=click.IntRange(0, 2147483647))
@click.option("-b", "--burst", help="Configures syslog rate limit burst in number of messages for containers", type=click.IntRange(0, 2147483647))
@click.option("-i", "--interval", help="Configures syslog rate limit interval in seconds for specified containers", type=click.IntRange(0, 2147483647))
@click.option("-b", "--burst", help="Configures syslog rate limit burst in number of messages for specified containers", type=click.IntRange(0, 2147483647))
@clicommon.pass_db
def rate_limit_container(db, service_name, interval, burst):
""" Configure syslog rate limit for containers """
Expand Down
3 changes: 1 addition & 2 deletions sonic_package_manager/service_creator/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,8 @@ def register_syslog_config(self, new_name, old_name=None):
new_name (str): new table name
old_name (str, optional): old table name. Defaults to None.
"""
def_cfg = DEFAULT_SYSLOG_FEATURE_CONFIG.copy()
for conn in self._sonic_db.get_connectors():
new_cfg = copy.deepcopy(def_cfg)
new_cfg = copy.deepcopy(DEFAULT_SYSLOG_FEATURE_CONFIG.copy())
if old_name:
current_cfg = conn.get_entry(SYSLOG_CONFIG, old_name)
conn.set_entry(SYSLOG_CONFIG, old_name, None)
Expand Down
2 changes: 1 addition & 1 deletion syslog_util/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def service_validator(feature_data, service_name):
"""Validate input service name
Args:
db (obj): db object
feature_data (dict): feature entries of FEATURE table
service_name (str): service name
"""
if service_name not in feature_data:
Expand Down
18 changes: 9 additions & 9 deletions tests/syslog_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@

from click.testing import CliRunner
from utilities_common.db import Db
from syslog_util.common import FEATURE_TABLE, \
SYSLOG_CONFIG_TABLE, \
SYSLOG_CONFIG_GLOBAL_KEY, \
SYSLOG_CONFIG_FEATURE_TABLE, \
SYSLOG_RATE_LIMIT_INTERVAL, \
SYSLOG_RATE_LIMIT_BURST, \
SUPPORT_RATE_LIMIT

from .mock_tables import dbconnector
from .syslog_input import config_mock
Expand All @@ -30,13 +37,6 @@
SUCCESS = 0
ERROR2 = 2

FEATURE_TABLE = 'FEATURE'
SYSLOG_CONFIG_TABLE = 'SYSLOG_CONFIG'
SYSLOG_CONFIG_GLOBAL_KEY = 'GLOBAL'
SYSLOG_CONFIG_FEATURE_TABLE = 'SYSLOG_CONFIG_FEATURE'
SYSLOG_RATE_LIMIT_INTERVAL = 'rate_limit_interval'
SYSLOG_RATE_LIMIT_BURST = 'rate_limit_burst'

test_path = os.path.dirname(os.path.abspath(__file__))
mock_db_path = os.path.join(test_path, "syslog_input")
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -257,7 +257,7 @@ def test_config_syslog_rate_limit_no_option(self, test_data):
{'interval':1, 'burst':0, 'expected_interval': '0', 'expected_burst': '0'}])
def test_config_syslog_rate_limit_container_basic(self, test_data):
db = Db()
db.cfgdb.set_entry(FEATURE_TABLE, 'bgp', {'support_syslog_rate_limit': 'true',
db.cfgdb.set_entry(FEATURE_TABLE, 'bgp', {SUPPORT_RATE_LIMIT: 'true',
'state': 'enabled'})

runner = CliRunner()
Expand Down Expand Up @@ -295,7 +295,7 @@ def test_config_syslog_rate_limit_container_invalid_service(self):

def test_config_syslog_rate_limit_container_service_no_support(self):
db = Db()
db.cfgdb.set_entry(FEATURE_TABLE, 'bgp', {'support_syslog_rate_limit': 'false',
db.cfgdb.set_entry(FEATURE_TABLE, 'bgp', {SUPPORT_RATE_LIMIT: 'false',
'state': 'enabled'})
runner = CliRunner()

Expand Down

0 comments on commit d2aead9

Please sign in to comment.