Skip to content

Commit 05ca42e

Browse files
committed
Fix logging from syslog to logger
1 parent 3c2c615 commit 05ca42e

File tree

5 files changed

+26
-19
lines changed

5 files changed

+26
-19
lines changed

files/scripts/asic_status.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,25 @@
55
"""
66
try:
77
import re
8-
import syslog
98
import sys
109
from sonic_py_common import daemon_base
1110
from swsscommon import swsscommon
1211
from sonic_py_common import multi_asic
12+
from sonic_py_common.logger import Logger
1313
except ImportError as e:
1414
raise ImportError(str(e) + " - required module not found")
1515

1616
#
1717
# Constants ====================================================================
1818
#
19+
SYSLOG_IDENTIFIER = 'asic_status.py'
1920
CHASSIS_ASIC_INFO_TABLE = 'CHASSIS_ASIC_TABLE'
2021
SELECT_TIMEOUT_MSECS = 5000
2122

2223
def main():
24+
logger = Logger(SYSLOG_IDENTIFIER)
25+
logger.set_min_log_priority_info()
26+
2327
if len(sys.argv) != 3:
2428
raise Exception('Pass service and valid asic-id as arguments')
2529

@@ -29,8 +33,7 @@ def main():
2933
# Get num asics
3034
num_asics = multi_asic.get_num_asics()
3135
if num_asics == 0:
32-
syslog.syslog(syslog.LOG_ERR,
33-
'Detected no asics on this platform for service {}'.format(service))
36+
logger.log_error('Detected no asics on this platform for service {}'.format(service))
3437
sys.exit(1)
3538

3639
# Connect to STATE_DB and subscribe to chassis-module table notifications
@@ -55,22 +58,18 @@ def main():
5558
asic_fvs = dict(asic_fvp)
5659
asic_name = asic_fvs.get('name')
5760
if asic_name is None:
58-
syslog.syslog(syslog.LOG_INFO,
59-
'Unable to get asic_name for asic{}'.format(global_asic_id))
61+
logger.log_info('Unable to get asic_name for asic{}'.format(global_asic_id))
6062
continue
6163

6264
if asic_name.startswith('FABRIC-CARD') is False:
63-
syslog.syslog(syslog.LOG_INFO,
64-
'Skipping module with asic_name {} for asic{}'.format(asic_name, global_asic_id))
65+
logger.log_info('Skipping module with asic_name {} for asic{}'.format(asic_name, global_asic_id))
6566
continue
6667

6768
if (global_asic_id == args_asic_id):
68-
syslog.syslog(syslog.LOG_INFO,
69-
'Detected asic{} is online'.format(global_asic_id))
69+
logger.log_info('Detected asic{} is online'.format(global_asic_id))
7070
sys.exit(0)
7171
elif asic_op == 'DEL':
72-
syslog.syslog(syslog.LOG_INFO,
73-
'Detected asic{} is offline'.format(global_asic_id))
72+
logger.log_info('Detected asic{} is offline'.format(global_asic_id))
7473
sys.exit(1)
7574
else:
7675
continue

files/scripts/lldp.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,18 @@ function debug()
1111
start() {
1212
debug "Starting ${SERVICE}$DEV service..."
1313

14-
# start service docker
14+
# On supervisor card, skip starting asic related services here. In wait(),
15+
# wait until the asic is detected by pmon and published via database.
1516
if ! is_chassis_supervisor; then
17+
# start service docker
1618
/usr/bin/${SERVICE}.sh start $DEV
1719
debug "Started ${SERVICE}$DEV service..."
1820
fi
1921
}
2022

2123
wait() {
24+
# On supervisor card, wait for asic to be online before starting the docker.
2225
if is_chassis_supervisor; then
23-
# Check asic status before starting docker
2426
check_asic_status
2527
ASIC_STATUS=$?
2628

files/scripts/swss.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,10 @@ start() {
160160
clean_up_tables STATE_DB "'PORT_TABLE*', 'MGMT_PORT_TABLE*', 'VLAN_TABLE*', 'VLAN_MEMBER_TABLE*', 'LAG_TABLE*', 'LAG_MEMBER_TABLE*', 'INTERFACE_TABLE*', 'MIRROR_SESSION*', 'VRF_TABLE*', 'FDB_TABLE*', 'FG_ROUTE_TABLE*', 'BUFFER_POOL*', 'BUFFER_PROFILE*', 'MUX_CABLE_TABLE*'"
161161
fi
162162

163-
# start service docker
163+
# On supervisor card, skip starting asic related services here. In wait(),
164+
# wait until the asic is detected by pmon and published via database.
164165
if ! is_chassis_supervisor; then
166+
# start service docker
165167
/usr/bin/${SERVICE}.sh start $DEV
166168
debug "Started ${SERVICE}$DEV service..."
167169
fi
@@ -171,8 +173,8 @@ start() {
171173
}
172174

173175
wait() {
176+
# On supervisor card, wait for asic to be online before starting the docker.
174177
if is_chassis_supervisor; then
175-
# Check asic status before starting docker
176178
check_asic_status
177179
ASIC_STATUS=$?
178180

files/scripts/syncd_common.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,10 @@ start() {
106106

107107
startplatform
108108

109-
# start service docker
109+
# On supervisor card, skip starting asic related services here. In wait(),
110+
# wait until the asic is detected by pmon and published via database.
110111
if ! is_chassis_supervisor; then
112+
# start service docker
111113
/usr/bin/${SERVICE}.sh start $DEV
112114
debug "Started ${SERVICE}$DEV service..."
113115
fi
@@ -116,8 +118,8 @@ start() {
116118
}
117119

118120
wait() {
121+
# On supervisor card, wait for asic to be online before starting the docker.
119122
if is_chassis_supervisor; then
120-
# Check asic status before starting docker
121123
check_asic_status
122124
ASIC_STATUS=$?
123125

files/scripts/teamd.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,18 @@ start() {
5050
debug "Warm boot flag: ${SERVICE}$DEV ${WARM_BOOT}."
5151
debug "Fast boot flag: ${SERVICE}$DEV ${Fast_BOOT}."
5252

53-
# start service docker
53+
# On supervisor card, skip starting asic related services here. In wait(),
54+
# wait until the asic is detected by pmon and published via database.
5455
if ! is_chassis_supervisor; then
56+
# start service docker
5557
/usr/bin/${SERVICE}.sh start $DEV
5658
debug "Started ${SERVICE}$DEV service..."
5759
fi
5860
}
5961

6062
wait() {
63+
# On supervisor card, wait for asic to be online before starting the docker.
6164
if is_chassis_supervisor; then
62-
# Check asic status before starting docker
6365
check_asic_status
6466
ASIC_STATUS=$?
6567

0 commit comments

Comments
 (0)