Skip to content

Commit b37f156

Browse files
[sonic-platform-base] Introduce APIs for modular chassis support (#124)
sonic-platform-base: Changes to enhance module_base.py and chassis_base.py for modular chassis HLD: sonic-net/SONiC#646 - Enhance ModuleBase with new APIs to repesent pluggable cards in a voq-chassis. - Enhance ChassisBase with new APIs
1 parent 9ba8189 commit b37f156

File tree

2 files changed

+166
-0
lines changed

2 files changed

+166
-0
lines changed

sonic_platform_base/chassis_base.py

+48
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,41 @@ def get_reboot_cause(self):
109109
"""
110110
raise NotImplementedError
111111

112+
def get_supervisor_slot(self):
113+
"""
114+
Retrieves the physical-slot of the supervisor-module in the modular
115+
chassis. On the supervisor or line-card modules, it will return the
116+
physical-slot of the supervisor-module.
117+
118+
On the fixed-platforms, the API can be ignored.
119+
120+
Users of the API can catch the exception and return a default
121+
ModuleBase.MODULE_INVALID_SLOT and bypass code for fixed-platforms.
122+
123+
Returns:
124+
An integer, the vendor specific physical slot identifier of the
125+
supervisor module in the modular-chassis.
126+
"""
127+
return NotImplementedError
128+
129+
def get_my_slot(self):
130+
"""
131+
Retrieves the physical-slot of this module in the modular chassis.
132+
On the supervisor, it will return the physical-slot of the supervisor
133+
module. On the linecard, it will return the physical-slot of the
134+
linecard module where this instance of SONiC is running.
135+
136+
On the fixed-platforms, the API can be ignored.
137+
138+
Users of the API can catch the exception and return a default
139+
ModuleBase.MODULE_INVALID_SLOT and bypass code for fixed-platforms.
140+
141+
Returns:
142+
An integer, the vendor specific physical slot identifier of this
143+
module in the modular-chassis.
144+
"""
145+
return NotImplementedError
146+
112147
##############################################
113148
# Component methods
114149
##############################################
@@ -197,6 +232,19 @@ def get_module(self, index):
197232

198233
return module
199234

235+
def get_module_index(self, module_name):
236+
"""
237+
Retrieves module index from the module name
238+
239+
Args:
240+
module_name: A string, prefixed by SUPERVISOR, LINE-CARD or FABRIC-CARD
241+
Ex. SUPERVISOR0, LINE-CARD1, FABRIC-CARD5
242+
243+
Returns:
244+
An integer, the index of the ModuleBase object in the module_list
245+
"""
246+
raise NotImplementedError
247+
200248
##############################################
201249
# Fan methods
202250
##############################################

sonic_platform_base/module_base.py

+118
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,39 @@ class ModuleBase(device_base.DeviceBase):
1717
# Device type definition. Note, this is a constant.
1818
DEVICE_TYPE = "module"
1919

20+
# Possible card types for modular chassis
21+
MODULE_TYPE_SUPERVISOR = "SUPERVISOR"
22+
MODULE_TYPE_LINE = "LINE-CARD"
23+
MODULE_TYPE_FABRIC = "FABRIC-CARD"
24+
25+
# Possible card status for modular chassis
26+
# Module state is Empty if no module is inserted in the slot
27+
MODULE_STATUS_EMPTY = "Empty"
28+
# Module state if Offline. This is also the admin-down state.
29+
MODULE_STATUS_OFFLINE = "Offline"
30+
# Module state if power down was triggered. Example, this could be a
31+
# policy action from sensors reaching a critical state triggering the
32+
# module to be powered-down.
33+
MODULE_STATUS_POWERED_DOWN = "PoweredDown"
34+
# Module state is Present when it is powered up, but not fully functional.
35+
MODULE_STATUS_PRESENT = "Present"
36+
# Module state is Present when it is powered up, but entered a fault state.
37+
# Module is not able to go Online.
38+
MODULE_STATUS_FAULT = "Fault"
39+
# Module state is Online when fully operational
40+
MODULE_STATUS_ONLINE = "Online"
41+
42+
# Invalid slot for modular chassis
43+
MODULE_INVALID_SLOT = -1
44+
45+
# Possible reboot types for modular chassis
46+
# Module reboot type to reboot entire card
47+
MODULE_REBOOT_DEFAULT = "Default"
48+
# Module reboot type to reboot CPU complex
49+
MODULE_REBOOT_CPU_COMPLEX = "CPU"
50+
# Module reboot type to reboot FPGA complex
51+
MODULE_REBOOT_FPGA_COMPLEX = "FPGA"
52+
2053
# List of ComponentBase-derived objects representing all components
2154
# available on the module
2255
_component_list = None
@@ -68,6 +101,91 @@ def get_system_eeprom_info(self):
68101
"""
69102
raise NotImplementedError
70103

104+
def get_name(self):
105+
"""
106+
Retrieves the name of the module prefixed by SUPERVISOR, LINE-CARD,
107+
FABRIC-CARD
108+
109+
Returns:
110+
A string, the module name prefixed by one of MODULE_TYPE_SUPERVISOR,
111+
MODULE_TYPE_LINE or MODULE_TYPE_FABRIC and followed by a 0-based index
112+
113+
Ex. A Chassis having 1 supervisor, 4 line-cards and 6 fabric-cards
114+
can provide names SUPERVISOR0, LINE-CARD0 to LINE-CARD3,
115+
FABRIC-CARD0 to FABRIC-CARD5
116+
"""
117+
raise NotImplementedError
118+
119+
def get_description(self):
120+
"""
121+
Retrieves the platform vendor's product description of the module
122+
123+
Returns:
124+
A string, providing the vendor's product description of the module.
125+
"""
126+
raise NotImplementedError
127+
128+
def get_slot(self):
129+
"""
130+
Retrieves the platform vendor's slot number of the module
131+
132+
Returns:
133+
An integer, indicating the slot number in the chassis
134+
"""
135+
raise NotImplementedError
136+
137+
def get_type(self):
138+
"""
139+
Retrieves the type of the module.
140+
141+
Returns:
142+
A string, the module-type from one of the predefined types:
143+
MODULE_TYPE_SUPERVISOR, MODULE_TYPE_LINE or MODULE_TYPE_FABRIC
144+
"""
145+
raise NotImplementedError
146+
147+
def get_oper_status(self):
148+
"""
149+
Retrieves the operational status of the module
150+
151+
Returns:
152+
A string, the operational status of the module from one of the
153+
predefined status values: MODULE_STATUS_EMPTY, MODULE_STATUS_OFFLINE,
154+
MODULE_STATUS_FAULT, MODULE_STATUS_PRESENT or MODULE_STATUS_ONLINE
155+
"""
156+
raise NotImplementedError
157+
158+
def reboot(self, reboot_type):
159+
"""
160+
Request to reboot the module
161+
162+
Args:
163+
reboot_type: A string, the type of reboot requested from one of the
164+
predefined reboot types: MODULE_REBOOT_DEFAULT, MODULE_REBOOT_CPU_COMPLEX,
165+
or MODULE_REBOOT_FPGA_COMPLEX
166+
167+
Returns:
168+
bool: True if the request has been issued successfully, False if not
169+
"""
170+
raise NotImplementedError
171+
172+
def set_admin_state(self, up):
173+
"""
174+
Request to keep the card in administratively up/down state.
175+
The down state will power down the module and the status should show
176+
MODULE_STATUS_OFFLINE.
177+
The up state will take the module to MODULE_STATUS_FAULT or
178+
MODULE_STAUS_ONLINE states.
179+
180+
Args:
181+
up: A boolean, True to set the admin-state to UP. False to set the
182+
admin-state to DOWN.
183+
184+
Returns:
185+
bool: True if the request has been issued successfully, False if not
186+
"""
187+
raise NotImplementedError
188+
71189
##############################################
72190
# Component methods
73191
##############################################

0 commit comments

Comments
 (0)