Skip to content
38 changes: 38 additions & 0 deletions sonic_platform_base/chassis_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,31 @@ def get_reboot_cause(self):
"""
raise NotImplementedError

def get_supervisor_slot(self):
"""
Retrieves the slot of the supervisor-module of the modular chassis.
On the supervisor or line-card modules, it will return the slot of the
supervisor-module.

Returns:
An integer, the slot identifier of the supervisor module of the
modular-chassis.
"""
return NotImplementedError

def get_my_slot(self):
"""
Retrieves the slot of this module of the modular chassis.
On the supervisor, it will return the slot of the supervisor-module.
On the linecard, it will return the slot of the linecard module where
this instance of SONiC is running.

Returns:
An integer, the slot identifier of this module of the
modular-chassis.
"""
return NotImplementedError

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

return module

def get_module_index(self, module_name):
"""
Retrieves module index from the module name

Args:
name: A string, prefixed by SUPERVISOR, LINE-CARD or FABRIC-CARD
Ex. SUPERVISOR0, LINE-CARD1, FABRIC-CARD5

Returns:
An index of the ModuleBase object in the module_list
"""
raise NotImplementedError

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

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

# Possible card status
#Module state is Empty if no module is inserted in the slot
MODULE_STATUS_EMPTY = "Empty"
#Module state if Offline if powered down. This is also the admin-down state.
MODULE_STATUS_OFFLINE = "Offline"
#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"

# List of ComponentBase-derived objects representing all components
# available on the module
_component_list = None
Expand Down Expand Up @@ -68,6 +86,83 @@ 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:
string: A string providing the name of the card prefixed by one of the
MODULE_TYPE_SUPERVISOR, MODULE_TYPE_LINE, MODULE_TYPE_FABRIC followed by
an 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:
string: A string providing the product description of the module. This
is vendor specific.
"""
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:
string: A string providing the module-type. Supported values are
MODULE_TYPE_SUPERVISOR, MODULE_TYPE_LINE, MODULE_TYPE_FABRIC
"""
raise NotImplementedError

def get_status(self):
"""
Retrieves the status of the card

Returns:
string: A string providing the status of the module. Support values
are MODULE_STATUS_EMPTY, MODULE_STATUS_OFFLINE, MODULE_STATUS_FAULT,
MODULE_STATUS_PRESENT, MODULE_STATUS_ONLINE
"""
raise NotImplementedError

def reboot(self):
"""
Request to reboot the module

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_PRESENT,
MODULE_STATUS_FAULT or MODULE_STAUS_ONLINE states.

Returns:
bool: True if the request has been issued successfully, False if not
"""
raise NotImplementedError

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