Skip to content

Commit

Permalink
[sonic-platform-base] Introduce APIs for modular chassis support (#124)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mprabhu-nokia authored Nov 10, 2020
1 parent 9ba8189 commit b37f156
Show file tree
Hide file tree
Showing 2 changed files with 166 additions and 0 deletions.
48 changes: 48 additions & 0 deletions sonic_platform_base/chassis_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,41 @@ def get_reboot_cause(self):
"""
raise NotImplementedError

def get_supervisor_slot(self):
"""
Retrieves the physical-slot of the supervisor-module in the modular
chassis. On the supervisor or line-card modules, it will return the
physical-slot of the supervisor-module.
On the fixed-platforms, the API can be ignored.
Users of the API can catch the exception and return a default
ModuleBase.MODULE_INVALID_SLOT and bypass code for fixed-platforms.
Returns:
An integer, the vendor specific physical slot identifier of the
supervisor module in the modular-chassis.
"""
return NotImplementedError

def get_my_slot(self):
"""
Retrieves the physical-slot of this module in the modular chassis.
On the supervisor, it will return the physical-slot of the supervisor
module. On the linecard, it will return the physical-slot of the
linecard module where this instance of SONiC is running.
On the fixed-platforms, the API can be ignored.
Users of the API can catch the exception and return a default
ModuleBase.MODULE_INVALID_SLOT and bypass code for fixed-platforms.
Returns:
An integer, the vendor specific physical slot identifier of this
module in the modular-chassis.
"""
return NotImplementedError

##############################################
# Component methods
##############################################
Expand Down Expand Up @@ -197,6 +232,19 @@ def get_module(self, index):

return module

def get_module_index(self, module_name):
"""
Retrieves module index from the module name
Args:
module_name: A string, prefixed by SUPERVISOR, LINE-CARD or FABRIC-CARD
Ex. SUPERVISOR0, LINE-CARD1, FABRIC-CARD5
Returns:
An integer, the index of the ModuleBase object in the module_list
"""
raise NotImplementedError

##############################################
# Fan methods
##############################################
Expand Down
118 changes: 118 additions & 0 deletions sonic_platform_base/module_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,39 @@ class ModuleBase(device_base.DeviceBase):
# Device type definition. Note, this is a constant.
DEVICE_TYPE = "module"

# Possible card types for modular chassis
MODULE_TYPE_SUPERVISOR = "SUPERVISOR"
MODULE_TYPE_LINE = "LINE-CARD"
MODULE_TYPE_FABRIC = "FABRIC-CARD"

# Possible card status for modular chassis
# Module state is Empty if no module is inserted in the slot
MODULE_STATUS_EMPTY = "Empty"
# Module state if Offline. This is also the admin-down state.
MODULE_STATUS_OFFLINE = "Offline"
# Module state if power down was triggered. Example, this could be a
# policy action from sensors reaching a critical state triggering the
# module to be powered-down.
MODULE_STATUS_POWERED_DOWN = "PoweredDown"
# Module state is Present when it is powered up, but not fully functional.
MODULE_STATUS_PRESENT = "Present"
# Module state is Present when it is powered up, but entered a fault state.
# Module is not able to go Online.
MODULE_STATUS_FAULT = "Fault"
# Module state is Online when fully operational
MODULE_STATUS_ONLINE = "Online"

# Invalid slot for modular chassis
MODULE_INVALID_SLOT = -1

# Possible reboot types for modular chassis
# Module reboot type to reboot entire card
MODULE_REBOOT_DEFAULT = "Default"
# Module reboot type to reboot CPU complex
MODULE_REBOOT_CPU_COMPLEX = "CPU"
# Module reboot type to reboot FPGA complex
MODULE_REBOOT_FPGA_COMPLEX = "FPGA"

# List of ComponentBase-derived objects representing all components
# available on the module
_component_list = None
Expand Down Expand Up @@ -68,6 +101,91 @@ def get_system_eeprom_info(self):
"""
raise NotImplementedError

def get_name(self):
"""
Retrieves the name of the module prefixed by SUPERVISOR, LINE-CARD,
FABRIC-CARD
Returns:
A string, the module name prefixed by one of MODULE_TYPE_SUPERVISOR,
MODULE_TYPE_LINE or MODULE_TYPE_FABRIC and followed by a 0-based index
Ex. A Chassis having 1 supervisor, 4 line-cards and 6 fabric-cards
can provide names SUPERVISOR0, LINE-CARD0 to LINE-CARD3,
FABRIC-CARD0 to FABRIC-CARD5
"""
raise NotImplementedError

def get_description(self):
"""
Retrieves the platform vendor's product description of the module
Returns:
A string, providing the vendor's product description of the module.
"""
raise NotImplementedError

def get_slot(self):
"""
Retrieves the platform vendor's slot number of the module
Returns:
An integer, indicating the slot number in the chassis
"""
raise NotImplementedError

def get_type(self):
"""
Retrieves the type of the module.
Returns:
A string, the module-type from one of the predefined types:
MODULE_TYPE_SUPERVISOR, MODULE_TYPE_LINE or MODULE_TYPE_FABRIC
"""
raise NotImplementedError

def get_oper_status(self):
"""
Retrieves the operational status of the module
Returns:
A string, the operational status of the module from one of the
predefined status values: MODULE_STATUS_EMPTY, MODULE_STATUS_OFFLINE,
MODULE_STATUS_FAULT, MODULE_STATUS_PRESENT or MODULE_STATUS_ONLINE
"""
raise NotImplementedError

def reboot(self, reboot_type):
"""
Request to reboot the module
Args:
reboot_type: A string, the type of reboot requested from one of the
predefined reboot types: MODULE_REBOOT_DEFAULT, MODULE_REBOOT_CPU_COMPLEX,
or MODULE_REBOOT_FPGA_COMPLEX
Returns:
bool: True if the request has been issued successfully, False if not
"""
raise NotImplementedError

def set_admin_state(self, up):
"""
Request to keep the card in administratively up/down state.
The down state will power down the module and the status should show
MODULE_STATUS_OFFLINE.
The up state will take the module to MODULE_STATUS_FAULT or
MODULE_STAUS_ONLINE states.
Args:
up: A boolean, True to set the admin-state to UP. False to set the
admin-state to DOWN.
Returns:
bool: True if the request has been issued successfully, False if not
"""
raise NotImplementedError

##############################################
# Component methods
##############################################
Expand Down

0 comments on commit b37f156

Please sign in to comment.