diff --git a/device/accton/x86_64-accton_as7326_56x-r0/plugins/eeprom.py b/device/accton/x86_64-accton_as7326_56x-r0/plugins/eeprom.py index 28db26eddd31..78da4145c21e 100644 --- a/device/accton/x86_64-accton_as7326_56x-r0/plugins/eeprom.py +++ b/device/accton/x86_64-accton_as7326_56x-r0/plugins/eeprom.py @@ -1,7 +1,6 @@ #!/usr/bin/env python try: - import exceptions import binascii import time import optparse diff --git a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/chassis.py b/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/chassis.py index a1dcf04a1af5..9ca0a1bc2f5b 100644 --- a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/chassis.py +++ b/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/chassis.py @@ -9,6 +9,7 @@ ############################################################################# import os +import sys try: from sonic_platform_base.chassis_base import ChassisBase @@ -26,7 +27,7 @@ NUM_FAN_TRAY = 6 NUM_PSU = 2 NUM_THERMAL = 4 -NUM_PORT = 56 +NUM_PORT = 58 NUM_COMPONENT = 4 HOST_REBOOT_CAUSE_PATH = "/host/reboot-cause/" diff --git a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/component.py b/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/component.py index 2d06b6295f8b..a588e343b56c 100644 --- a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/component.py +++ b/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/component.py @@ -1,16 +1,11 @@ -#!/usr/bin/env python - ############################################################################# -# Edgecore +# Edgecore # # Component contains an implementation of SONiC Platform Base API and # provides the components firmware management function # ############################################################################# -import shlex -import subprocess - try: from sonic_platform_base.component_base import ComponentBase except ImportError as e: diff --git a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/fan.py b/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/fan.py index bf341524580a..91af071784ac 100644 --- a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/fan.py +++ b/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/fan.py @@ -1,6 +1,5 @@ - ############################################################################# -# Edgecor +# Edgecore # # Module contains an implementation of SONiC Platform Base API and # provides the fan status which are available in the platform diff --git a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/fan_drawer.py b/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/fan_drawer.py index 8e4dc8172369..94357d5d82ba 100644 --- a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/fan_drawer.py +++ b/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/fan_drawer.py @@ -1,4 +1,3 @@ - ######################################################################## # # Module contains an implementation of SONiC Platform Base API and @@ -8,7 +7,6 @@ try: from sonic_platform_base.fan_drawer_base import FanDrawerBase - from sonic_platform.fan import Fan except ImportError as e: raise ImportError(str(e) + "- required module not found") @@ -23,8 +21,13 @@ def __init__(self, fantray_index): FanDrawerBase.__init__(self) # FanTray is 0-based in platforms self.fantrayindex = fantray_index + self.__initialize_fan_drawer() + + + def __initialize_fan_drawer(self): + from sonic_platform.fan import Fan for i in range(FANS_PER_FANTRAY): - self._fan_list.append(Fan(fantray_index, i)) + self._fan_list.append(Fan(self.fantrayindex, i)) def get_name(self): """ diff --git a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/platform.py b/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/platform.py index b752b64f11f8..2f2c2a447fcf 100644 --- a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/platform.py +++ b/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/platform.py @@ -1,4 +1,3 @@ - ############################################################################# # Edgecore # diff --git a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/psu.py b/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/psu.py index ddc1b14dd633..8d002d5dc8ee 100644 --- a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/psu.py +++ b/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/psu.py @@ -1,4 +1,3 @@ - ############################################################################# # Edgecore # @@ -11,7 +10,6 @@ try: from sonic_platform_base.psu_base import PsuBase - from sonic_platform.fan import Fan from sonic_platform.thermal import Thermal except ImportError as e: raise ImportError(str(e) + "- required module not found") @@ -59,7 +57,10 @@ def __init__(self, psu_index=0): bus = PSU_CPLD_I2C_MAPPING[self.index]["bus"] addr = PSU_CPLD_I2C_MAPPING[self.index]["addr"] self.cpld_path = I2C_PATH.format(bus, addr) - + self.__initialize_fan() + + def __initialize_fan(self): + from sonic_platform.fan import Fan self._fan_list.append( Fan(NUM_FAN_TRAY + self.index, is_psu_fan=True, diff --git a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/sfp.py b/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/sfp.py index b541fbac5edb..687437425d82 100644 --- a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/sfp.py +++ b/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/sfp.py @@ -131,7 +131,7 @@ class Sfp(SfpBase): # Port number PORT_START = 1 - PORT_END = 56 + PORT_END = 58 # Path to sysfs PLATFORM_ROOT_PATH = "/usr/share/sonic/device" @@ -198,6 +198,8 @@ class Sfp(SfpBase): 54: [30], 55: [31], 56: [32], + 57: [22], + 58: [23] } def __init__(self, sfp_index=0): @@ -343,14 +345,15 @@ def get_transceiver_info(self): ======================================================================== """ # check present status - if self.port_num <= 48: + if self.port_num <= 48 or self.port_num >=57: sfpi_obj = sff8472InterfaceId() #SFP elif self.port_num <= 56: sfpi_obj = sff8436InterfaceId() #QSFP + if not self.get_presence() or not sfpi_obj: return {} - if self.port_num <= 48: + if self.port_num <= 48 or self.port_num >=57: offset = SFP_INFO_OFFSET sfp_interface_bulk_raw = self.__read_eeprom_specific_bytes( (offset + XCVR_INTFACE_BULK_OFFSET), @@ -373,7 +376,7 @@ def get_transceiver_info(self): (offset + XCVR_VENDOR_PN_OFFSET), XCVR_VENDOR_PN_WIDTH) sfp_vendor_pn_data = sfpi_obj.parse_vendor_pn(sfp_vendor_pn_raw, 0) - if self.port_num <= 48: + if self.port_num <= 48 or self.port_num >=57: sfp_vendor_rev_raw = self.__read_eeprom_specific_bytes( (offset + XCVR_HW_REV_OFFSET), XCVR_HW_REV_WIDTH_SFP) else: @@ -431,7 +434,7 @@ def get_transceiver_info(self): transceiver_info_dict['cable_type'] = "Unknown" transceiver_info_dict['cable_length'] = "Unknown" - if self.port_num <= 48: + if self.port_num <= 48 or self.port_num >=57: for key in sfp_cable_length_tup: if key in sfp_interface_bulk_data['data']: transceiver_info_dict['cable_type'] = key @@ -498,7 +501,7 @@ def get_transceiver_bulk_status(self): ======================================================================== """ # check present status - if self.port_num <= 48: #SFP case + if self.port_num <= 48 or self.port_num >=57: #SFP case sfpd_obj = sff8472Dom() if not self.get_presence() or not sfpd_obj: return {} @@ -560,7 +563,7 @@ def get_transceiver_bulk_status(self): (offset_xcvr + XCVR_DOM_CAPABILITY_OFFSET), XCVR_DOM_CAPABILITY_WIDTH) if qsfp_dom_capability_raw is not None: - qspf_dom_capability_data = sfpi_obj.parse_qsfp_dom_capability( + qspf_dom_capability_data = sfpi_obj.parse_dom_capability( qsfp_dom_capability_raw, 0) else: return None @@ -692,7 +695,7 @@ def get_transceiver_threshold_info(self): ======================================================================== """ # check present status - if self.port_num <= 48: + if self.port_num <= 48 or self.port_num >=57: sfpd_obj = sff8472Dom() if not self.get_presence() and not sfpd_obj: @@ -872,7 +875,7 @@ def get_reset_status(self): Returns: A Boolean, True if reset enabled, False if disabled """ - if self.port_num <= 48: + if self.port_num <= 48 or self.port_num >=57: return False # SPF port doesn't support this feature val = self.__read_txt_file( @@ -887,7 +890,7 @@ def get_rx_los(self): Note : RX LOS status is latched until a call to get_rx_los or a reset. """ rx_los = False - if self.port_num <= 48: + if self.port_num <= 48 or self.port_num >=57: cpld_val = self.__read_txt_file( self.cpld_path + "module_rx_los_" + str(self.port_num)) rx_los = (int(cpld_val, 10) == 1) @@ -919,7 +922,7 @@ def get_tx_fault(self): Note : TX fault status is lached until a call to get_tx_fault or a reset. """ tx_fault = False - if self.port_num <= 48: + if self.port_num <= 48 or self.port_num >=57: cpld_val = self.__read_txt_file( self.cpld_path + "module_tx_fault_" + str(self.port_num)) tx_fault = (int(cpld_val, 10) == 1) @@ -950,7 +953,7 @@ def get_tx_disable(self): Returns: A Boolean, True if tx_disable is enabled, False if disabled """ - if self.port_num <= 48: + if self.port_num <= 48 or self.port_num >=57: tx_disable = False status_control_raw = self.__read_eeprom_specific_bytes( @@ -1000,7 +1003,7 @@ def get_tx_disable_channel(self): As an example, a returned value of 0x5 indicates that channel 0 and channel 2 have been disabled. """ - if self.port_num <= 48: + if self.port_num <= 48 or self.port_num >=57: # SFP doesn't support this feature return False else: @@ -1019,7 +1022,7 @@ def get_lpmode(self): Returns: A Boolean, True if lpmode is enabled, False if disabled """ - if self.port_num <= 48: + if self.port_num <= 48 or self.port_num >= 57: # SFP doesn't support this feature return False @@ -1029,7 +1032,7 @@ def get_lpmode(self): def get_power_set(self): - if self.port_num <= 48: + if self.port_num <= 48 or self.port_num >= 57: # SFP doesn't support this feature return False else: @@ -1056,7 +1059,7 @@ def get_power_override(self): Returns: A Boolean, True if power-override is enabled, False if disabled """ - if self.port_num <= 48: + if self.port_num <= 48 or self.port_num >= 57: return False # SFP doesn't support this feature else: power_override = False @@ -1105,7 +1108,7 @@ def get_tx_bias(self): transceiver_dom_info_dict = self.get_transceiver_bulk_status() tx1_bs = transceiver_dom_info_dict.get("tx1bias", "N/A") - if self.port_num <= 48: + if self.port_num <= 48 or self.port_num >=57: return [tx1_bs, "N/A", "N/A", "N/A"] if transceiver_dom_info_dict else [] @@ -1126,7 +1129,7 @@ def get_rx_power(self): transceiver_dom_info_dict = self.get_transceiver_bulk_status() rx1_pw = transceiver_dom_info_dict.get("rx1power", "N/A") - if self.port_num <= 48: + if self.port_num <= 48 or self.port_num >=57: return [rx1_pw, "N/A", "N/A", "N/A"] if transceiver_dom_info_dict else [] rx2_pw = transceiver_dom_info_dict.get("rx2power", "N/A") @@ -1145,7 +1148,7 @@ def get_tx_power(self): """ transceiver_dom_info_dict = self.get_transceiver_bulk_status() tx1_pw = transceiver_dom_info_dict.get("tx1power", "N/A") - if self.port_num <= 48: + if self.port_num <= 48 or self.port_num >=57: return [tx1_pw, "N/A", "N/A", "N/A"] if transceiver_dom_info_dict else [] tx2_pw = transceiver_dom_info_dict.get("tx2power", "N/A") @@ -1160,7 +1163,7 @@ def reset(self): A boolean, True if successful, False if not """ # Check for invalid port_num - if self.port_num <= 48: + if self.port_num <= 48 or self.port_num >=57: return False # SFP doesn't support this feature ret = self.__write_txt_file( @@ -1183,7 +1186,7 @@ def tx_disable(self, tx_disable): Returns: A boolean, True if tx_disable is set successfully, False if not """ - if self.port_num <= 48: + if self.port_num <= 48 or self.port_num >=57: ret = self.__write_txt_file( self.cpld_path + "module_tx_disable_" + str(self.port_num), 1 if tx_disable else 0) @@ -1227,7 +1230,7 @@ def tx_disable_channel(self, channel, disable): A boolean, True if successful, False if not """ - if self.port_num <= 48: + if self.port_num <= 48 or self.port_num >=57: return False # SFP doesn't support this feature else: if not self.get_presence(): @@ -1275,7 +1278,7 @@ def set_lpmode(self, lpmode): Returns: A boolean, True if lpmode is set successfully, False if not """ - if self.port_num <= 48: + if self.port_num <= 48 or self.port_num >=57: return False # SFP doesn't support this feature if lpmode is True: @@ -1300,7 +1303,7 @@ def set_power_override(self, power_override, power_set): A boolean, True if power-override and power_set are set successfully, False if not """ - if self.port_num <= 48: + if self.port_num <= 48 or self.port_num >=57: return False # SFP doesn't support this feature else: if not self.get_presence(): diff --git a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/thermal.py b/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/thermal.py index 673bf95192aa..5dce996f80ad 100644 --- a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/thermal.py +++ b/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/thermal.py @@ -1,4 +1,3 @@ - ############################################################################# # Edgecore # @@ -90,8 +89,6 @@ def __read_txt_file(self, file_path): pass def __get_temp(self, temp_file): - temp = int() - if not self.is_psu: temp_file_path = os.path.join(self.hwmon_path, temp_file) else: @@ -119,8 +116,6 @@ def get_temperature(self): A float number of current temperature in Celsius up to nearest thousandth of one degree Celsius, e.g. 30.125 """ - temp_file = str() - if not self.is_psu: temp_file = "temp{}_input".format(self.ss_index) else: