Skip to content

Commit

Permalink
Add get_sfp to chassis
Browse files Browse the repository at this point in the history
  • Loading branch information
Jostar Yang committed Jun 25, 2021
1 parent d7dd271 commit ab15d45
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#############################################################################

try:
import sys
import time
from sonic_platform_pddf_base.pddf_chassis import PddfChassis
except ImportError as e:
Expand Down Expand Up @@ -58,3 +59,27 @@ def get_change_event(self, timeout=2000):
return True, change_dict
else:
return True, change_dict


def get_sfp(self, index):
"""
Retrieves sfp represented by (1-based) index <index>
Args:
index: An integer, the index (1-based) of the sfp to retrieve.
The index should be the sequence of a physical port in a chassis,
starting from 1.
For example, 1 for Ethernet0, 2 for Ethernet4 and so on.
Returns:
An object derived from SfpBase representing the specified sfp
"""
sfp = None

try:
# The index will start from 1
sfp = self._sfp_list[index-1]
except IndexError:
sys.stderr.write("SFP index {} out of range (1-{})\n".format(
index, len(self._sfp_list)))
return sfp

0 comments on commit ab15d45

Please sign in to comment.