Skip to content

Commit f5ce311

Browse files
committed
Update for the Procedures for insertion/hot swap of Switch Fabric Module (SFM)
1. Add chassis_module_config.py and its service. 2. When the cli command "sudo config chassis modules startup/shutdown" runs, calls chassis_module_set_admin_state.py to do the ralated operations.
1 parent 1ee4948 commit f5ce311

2 files changed

Lines changed: 95 additions & 0 deletions

File tree

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#!/usr/bin/env python3
2+
3+
# Name: chassis_module_set_admin_state.py, version: 1.0
4+
# Syntax: chassis_module_set_admin_state.py <module_name> <up/down>
5+
#
6+
import re
7+
import sys
8+
import subprocess
9+
import time
10+
11+
from platform_ndk import nokia_common
12+
from sonic_py_common.logger import Logger
13+
14+
logger=Logger("chassis_module_set_admin_state.py")
15+
16+
sfm_asic_dict = {
17+
0: [0,1],
18+
1: [2,3],
19+
2: [4,5],
20+
3: [6,7],
21+
4: [8,9],
22+
5: [10,11],
23+
6: [12,13],
24+
7: [14,15]
25+
}
26+
27+
sfm_hw_slot_mapping = {
28+
0: 15,
29+
1: 16,
30+
2: 17,
31+
3: 18,
32+
4: 19,
33+
5: 20,
34+
6: 21,
35+
7: 22
36+
}
37+
38+
def main():
39+
argc = len(sys.argv)
40+
41+
if argc != 3:
42+
logger.log_warning("Missing parameters!")
43+
return
44+
45+
module = sys.argv[1]
46+
state = sys.argv[2]
47+
48+
if not module.startswith("FABRIC-CARD"):
49+
logger.log_warning("Failed to set {} state. Admin state can only be set on Fabric module".format(module))
50+
return
51+
52+
num = int(re.search(r"(\d+)$", module).group())
53+
if num not in sfm_hw_slot_mapping:
54+
logger.log_error("Invalid module name {}".format(module))
55+
return
56+
57+
if state == "down":
58+
logger.log_info("Shutting down chassis module {}".format(module))
59+
asic_list = sfm_asic_dict[num]
60+
for asic in asic_list:
61+
logger.log_info("Shut down swss@{} and syncd@{} ...".format(asic, asic))
62+
# Process state
63+
process = subprocess.Popen(['sudo', 'systemctl', 'stop', 'swss@{}.service'.format(asic)],
64+
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
65+
stdout, stderr = process.communicate()
66+
outstr = stdout.decode('ascii')
67+
# wait for service is down
68+
time.sleep(2)
69+
70+
logger.log_info("Power off {} module ...".format(module))
71+
hw_slot = sfm_hw_slot_mapping[num]
72+
nokia_common._power_onoff_SFM(hw_slot,False)
73+
logger.log_info("Shut down chassis module {} complete".format(module))
74+
else:
75+
logger.log_info("Starting up chassis module {}".format(module))
76+
logger.log_info("Power up {} module ...".format(module))
77+
hw_slot = sfm_hw_slot_mapping[num]
78+
nokia_common._power_onoff_SFM(hw_slot,True)
79+
# wait SFM HW init done.
80+
time.sleep(15)
81+
82+
asic_list = sfm_asic_dict[num]
83+
for asic in asic_list:
84+
logger.log_info("Start the swss@{} and syncd@{} ...".format(asic, asic))
85+
# Process state
86+
process = subprocess.Popen(['sudo', 'systemctl', 'start', 'swss@{}.service'.format(asic)],
87+
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
88+
stdout, stderr = process.communicate()
89+
outstr = stdout.decode('ascii')
90+
logger.log_info("Started chassis module {} complete".format(module))
91+
return
92+
93+
if __name__ == "__main__":
94+
main()

debian/sonic-platform-nokia-chassis.install

100644100755
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ chassis/utils/hw-management-generate-dump.sh usr/bin
99
chassis/utils/nokia_install_ndk_service usr/local/bin
1010
chassis/utils/70-persistent-net.rules etc/udev/rules.d
1111
chassis/utils/blacklist.conf etc/modprobe.d
12+
chassis/utils/chassis_module_set_admin_state.py usr/local/bin
1213
common/utils/nokia-asic-thermal.py opt/srlinux/bin
1314
common/service/nokia-asic-thermal.service lib/systemd/system

0 commit comments

Comments
 (0)