@@ -1560,3 +1560,62 @@ def get_name(self):
15601560 name = sfputil_helper .logical [self .index - 1 ] or "Unknown"
15611561 return name
15621562
1563+ def get_model (self ):
1564+ """
1565+ Retrieves the model number (or part number) of the device
1566+ Returns:
1567+ string: Model/part number of device
1568+ """
1569+ if not self .get_presence ():
1570+ return None
1571+ return self .get_transceiver_info ().get ('model' )
1572+
1573+ def get_serial (self ):
1574+ """
1575+ Retrieves the serial number of the device
1576+ Returns:
1577+ string: Serial number of device
1578+ """
1579+ if not self .get_presence ():
1580+ return None
1581+ return self .get_transceiver_info ().get ('serial' )
1582+
1583+ def get_position_in_parent (self ):
1584+ """
1585+ Retrieves 1-based relative physical position in parent device.
1586+ Returns:
1587+ integer: The 1-based relative physical position in parent
1588+ device or -1 if cannot determine the position
1589+ """
1590+ return self .index
1591+
1592+ def is_replaceable (self ):
1593+ """
1594+ Indicate whether this device is replaceable.
1595+ Returns:
1596+ bool: True if it is replaceable.
1597+ """
1598+ return True
1599+
1600+ def get_error_description (self ):
1601+ """
1602+ Retrives the error descriptions of the SFP module
1603+ Returns:
1604+ String that represents the current error descriptions of vendor specific errors
1605+ In case there are multiple errors, they should be joined by '|',
1606+ like: "Bad EEPROM|Unsupported cable"
1607+ """
1608+ if not self .get_presence ():
1609+ return self .SFP_STATUS_UNPLUGGED
1610+ else :
1611+ eeprom_path = self .port_to_eeprom_mapping [self .port_num ]
1612+ if not os .path .isfile (eeprom_path ):
1613+ return "EEPROM driver is not attached"
1614+ try :
1615+ with open (eeprom_path , mode = "rb" , buffering = 0 ) as eeprom :
1616+ eeprom .seek (QSFP_INFO_OFFSET )
1617+ eeprom .read (1 )
1618+ except OSError as e :
1619+ return "EEPROM read failed ({})" .format (e .strerror )
1620+
1621+ return self .SFP_STATUS_OK
0 commit comments