Skip to content

Commit

Permalink
[Mellanox] Refactor SFP to use new APIs.
Browse files Browse the repository at this point in the history
  • Loading branch information
oleksandrivantsiv committed Mar 22, 2022
1 parent b2409be commit f687a9e
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1,816 deletions.
20 changes: 10 additions & 10 deletions platform/mellanox/mlnx-platform-api/sonic_platform/chassis.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def __init__(self):

# Initialize DMI data
self.dmi_data = None

# move the initialization of each components to their dedicated initializer
# which will be called from platform
#
Expand Down Expand Up @@ -115,7 +115,7 @@ def __del__(self):

if SFP.shared_sdk_handle:
deinitialize_sdk_handle(SFP.shared_sdk_handle)

##############################################
# PSU methods
##############################################
Expand Down Expand Up @@ -238,7 +238,7 @@ def initialize_single_sfp(self, index):
if index < sfp_count:
if not self._sfp_list:
self._sfp_list = [None] * sfp_count

if not self._sfp_list[index]:
from .sfp import SFP
self._sfp_list[index] = SFP(index)
Expand Down Expand Up @@ -295,7 +295,7 @@ def get_sfp(self, index):
index = index - 1
self.initialize_single_sfp(index)
return super(Chassis, self).get_sfp(index)

def get_change_event(self, timeout=0):
"""
Returns a nested dictionary containing all devices which have
Expand All @@ -310,7 +310,7 @@ def get_change_event(self, timeout=0):
- True if call successful, False if not;
- A nested dictionary where key is a device type,
value is a dictionary with key:value pairs in the format of
{'device_id':'device_event'},
{'device_id':'device_event'},
where device_id is the device ID for this device and
device_event,
status='1' represents device inserted,
Expand Down Expand Up @@ -596,7 +596,7 @@ def get_watchdog(self):
Note:
We overload this method to ensure that watchdog is only initialized
when it is referenced. Currently, only one daemon can open the watchdog.
To initialize watchdog in the constructor causes multiple daemon
To initialize watchdog in the constructor causes multiple daemon
try opening watchdog when loading and constructing a chassis object
and fail. By doing so we can eliminate that risk.
"""
Expand All @@ -609,11 +609,11 @@ def get_watchdog(self):

return self._watchdog


def get_revision(self):
"""
Retrieves the hardware revision of the device
Returns:
string: Revision value of device
"""
Expand Down Expand Up @@ -647,7 +647,7 @@ def _parse_dmi(self, filename):

def _verify_reboot_cause(self, filename):
'''
Open and read the reboot cause file in
Open and read the reboot cause file in
/var/run/hwmanagement/system (which is defined as REBOOT_CAUSE_ROOT)
If a reboot cause file doesn't exists, returns '0'.
'''
Expand Down Expand Up @@ -754,7 +754,7 @@ def initialize_single_module(self, index):
if index < count:
if not self._module_list:
self._module_list = [None] * count

if not self._module_list[index]:
from .module import Module
self._module_list[index] = Module(index + 1)
Expand Down
Loading

0 comments on commit f687a9e

Please sign in to comment.