Skip to content

Commit c217bd6

Browse files
abdullahenesoncuStaphylo
authored andcommitted
api: implementation of ChassisBase.get_port_or_cage_type
This new API method was introduced by sonic-net/sonic-platform-common#288 Change-Id: Ic04496089c0d6767210ae86320ee4fee38fe17c0
1 parent f3af999 commit c217bd6

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

arista/utils/sonic_platform/chassis.py

+29
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
try:
1010
from sonic_platform_base.chassis_base import ChassisBase
11+
from sonic_platform_base.sfp_base import SfpBase
1112
from arista.core import thermal_control
1213
from arista.core.card import Card
1314
from arista.core.cause import getReloadCauseManager
@@ -214,6 +215,34 @@ def get_thermal_manager(self):
214215
def getThermalControl(self):
215216
return thermal_control
216217

218+
def get_port_or_cage_type(self, index):
219+
portLayout = self._platform.PORTS
220+
221+
if not hasattr( SfpBase, 'SFP_PORT_TYPE_BIT_RJ45' ):
222+
raise NotImplementedError
223+
224+
if index in portLayout.ethernetRange:
225+
return SfpBase.SFP_PORT_TYPE_BIT_RJ45
226+
227+
if index in portLayout.sfpRange:
228+
return ( SfpBase.SFP_PORT_TYPE_BIT_SFP |
229+
SfpBase.SFP_PORT_TYPE_BIT_SFP_PLUS |
230+
SfpBase.SFP_PORT_TYPE_BIT_SFP28 |
231+
SfpBase.SFP_PORT_TYPE_BIT_SFP_DD )
232+
233+
if index in portLayout.qsfpRange:
234+
return ( SfpBase.SFP_PORT_TYPE_BIT_QSFP |
235+
SfpBase.SFP_PORT_TYPE_BIT_QSFP_PLUS |
236+
SfpBase.SFP_PORT_TYPE_BIT_QSFP28 |
237+
SfpBase.SFP_PORT_TYPE_BIT_QSFP56 |
238+
SfpBase.SFP_PORT_TYPE_BIT_QSFPDD )
239+
240+
if index in portLayout.osfpRange:
241+
return ( SfpBase.SFP_PORT_TYPE_BIT_OSFP |
242+
SfpBase.SFP_PORT_TYPE_BIT_QSFPDD )
243+
244+
return 0x00000000
245+
217246
def get_position_in_parent(self):
218247
return -1
219248

0 commit comments

Comments
 (0)