Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…mage into test2
  • Loading branch information
FengPan-Frank committed Nov 27, 2024
2 parents 4902aae + cf0608a commit 7d1b7d4
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/sonic-bmpcfgd/bmpcfgd/bmpcfgd.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import signal
from shutil import copy2
from datetime import datetime
from sonic_py_common import device_info
from sonic_py_common import logger
from sonic_py_common.general import check_output_pipe
from swsscommon.swsscommon import ConfigDBConnector, DBConnector, Table
from swsscommon import swsscommon
Expand All @@ -22,6 +22,7 @@
REDIS_HOSTIP = "127.0.0.1"
BMP_TABLE = "BMP"
SYSLOG_IDENTIFIER = "bmpcfgd"
logger = logger.Logger(SYSLOG_IDENTIFIER)

def is_true(val):
return str(val).lower() == 'true'
Expand All @@ -40,7 +41,7 @@ def load(self, data={}):
self.bgp_neighbor_table = is_true(common_config.get('bgp_neighbor_table', 'false'))
self.bgp_rib_in_table = is_true(common_config.get('bgp_rib_in_table', 'false'))
self.bgp_rib_out_table = is_true(common_config.get('bgp_rib_out_table', 'false'))
self.log_info(f'BMPCfg: update : {self.bgp_neighbor_table}, {self.bgp_rib_in_table}, {self.bgp_rib_out_table}')
logger.log_notice(f'bmpcfgd: config update : {self.bgp_neighbor_table}, {self.bgp_rib_in_table}, {self.bgp_rib_out_table}')

# reset bmp table state once config is changed.
self.stop_bmp()
Expand All @@ -53,19 +54,19 @@ def cfg_handler(self, data):


def stop_bmp(self):
self.log_info('BMPCfg: stop bmp daemon')
logger.log_notice('bmpcfgd: stop bmp daemon')
subprocess.call(["supervisorctl", "stop", "sonic-bmp:openbmpd"])


def reset_bmp_table(self):
self.log_info('BMPCfg: Reset bmp table from state_db')
logger.log_notice('bmpcfgd: Reset bmp table from state_db')
self.state_db_conn.delete_all_by_pattern(BMP_STATE_DB, 'BGP_NEIGHBOR*')
self.state_db_conn.delete_all_by_pattern(BMP_STATE_DB, 'BGP_RIB_IN_TABLE*')
self.state_db_conn.delete_all_by_pattern(BMP_STATE_DB, 'BGP_RIB_OUT_TABLE*')


def start_bmp(self):
self.log_info('BMPCfg: start bmp daemon')
logger.log_notice('bmpcfgd: start bmp daemon')
subprocess.call(["supervisorctl", "start", "sonic-bmp:openbmpd"])


Expand Down

0 comments on commit 7d1b7d4

Please sign in to comment.