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
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.
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.

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

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

##############################################
# 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
mprabhu-nokia marked this conversation as resolved.
Show resolved Hide resolved
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
mprabhu-nokia marked this conversation as resolved.
Show resolved Hide resolved
MODULE_STATUS_ONLINE = "Online"
mprabhu-nokia marked this conversation as resolved.
Show resolved Hide resolved

# 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):
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):
"""
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.

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

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