Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sonic-platform-base] Introduce APIs for modular chassis support #124

Merged
merged 10 commits into from
Nov 10, 2020
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 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.

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 slot identifier of the supervisor module of the
modular-chassis.
mprabhu-nokia marked this conversation as resolved.
Show resolved Hide resolved
"""
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.

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 slot identifier of this module of the
modular-chassis.
mprabhu-nokia marked this conversation as resolved.
Show resolved Hide resolved
"""
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 index of the ModuleBase object in the module_list
mprabhu-nokia marked this conversation as resolved.
Show resolved Hide resolved
"""
raise NotImplementedError

##############################################
# Fan methods
##############################################
Expand Down
115 changes: 115 additions & 0 deletions sonic_platform_base/module_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,35 @@ 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"
mprabhu-nokia marked this conversation as resolved.
Show resolved Hide resolved
# 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"
mprabhu-nokia marked this conversation as resolved.
Show resolved Hide resolved

# 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 +97,92 @@ def get_system_eeprom_info(self):
"""
raise NotImplementedError

def get_name(self):
mprabhu-nokia marked this conversation as resolved.
Show resolved Hide resolved
mprabhu-nokia marked this conversation as resolved.
Show resolved Hide resolved
"""
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.
mprabhu-nokia marked this conversation as resolved.
Show resolved Hide resolved
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):
mprabhu-nokia marked this conversation as resolved.
Show resolved Hide resolved
"""
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):
mprabhu-nokia marked this conversation as resolved.
Show resolved Hide resolved
"""
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
mprabhu-nokia marked this conversation as resolved.
Show resolved Hide resolved
"""
raise NotImplementedError

def get_status(self):
mprabhu-nokia marked this conversation as resolved.
Show resolved Hide resolved
"""
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
mprabhu-nokia marked this conversation as resolved.
Show resolved Hide resolved
"""
raise NotImplementedError

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

Args:
reboot_type: A string, choose from one of pre-defined module
reboot-types. MODULE_REBOOT_DEFAULT, MODULE_REBOOT_CPU_COMPLEX,
MODULE_REBOOT_FPGA_COMPLEX
mprabhu-nokia marked this conversation as resolved.
Show resolved Hide resolved

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.

mprabhu-nokia marked this conversation as resolved.
Show resolved Hide resolved
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