From cbd21d8ef9f8e9457b0b32266afb7ce8ec356fec Mon Sep 17 00:00:00 2001 From: Santhosh Kumar T <53558409+santhosh-kt@users.noreply.github.com> Date: Thu, 5 Jan 2023 03:28:01 +0530 Subject: [PATCH] [202205][DellEMC] Fixing 'show interface status' break in DellEMC platforms porting changes (#13236) --- .../s5212f/sonic_platform/chassis.py | 5 +---- .../s5212f/sonic_platform/component.py | 4 +++- .../s5224f/sonic_platform/chassis.py | 5 +---- .../s5224f/sonic_platform/component.py | 4 +++- .../s5232f/sonic_platform/chassis.py | 3 +-- .../s5232f/sonic_platform/component.py | 4 +++- .../s5248f/sonic_platform/chassis.py | 3 +-- .../s5248f/sonic_platform/component.py | 4 +++- .../s6000/sonic_platform/chassis.py | 6 ++++++ .../s6100/sonic_platform/chassis.py | 10 ++++++++++ .../s6100/sonic_platform/eeprom.py | 5 +++++ .../z9264f/sonic_platform/chassis.py | 5 +---- .../z9332f/sonic_platform/chassis.py | 3 +-- .../z9332f/sonic_platform/component.py | 4 +++- 14 files changed, 42 insertions(+), 23 deletions(-) diff --git a/platform/broadcom/sonic-platform-modules-dell/s5212f/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-dell/s5212f/sonic_platform/chassis.py index 629f4e73f7..f9ce22719f 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s5212f/sonic_platform/chassis.py +++ b/platform/broadcom/sonic-platform-modules-dell/s5212f/sonic_platform/chassis.py @@ -106,10 +106,7 @@ class Chassis(ChassisBase): for port_num in range(self.PORT_START, (self.PORT_END + 1)): # sfp get uses zero-indexing, but port numbers start from 1 presence = self.get_sfp(port_num).get_presence() - if presence: - self._global_port_pres_dict[port_num] = '1' - else: - self._global_port_pres_dict[port_num] = '0' + self._global_port_pres_dict[port_num] = '0' self._watchdog = Watchdog() diff --git a/platform/broadcom/sonic-platform-modules-dell/s5212f/sonic_platform/component.py b/platform/broadcom/sonic-platform-modules-dell/s5212f/sonic_platform/component.py index a1bba0c9d3..ffa8f1bd6d 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s5212f/sonic_platform/component.py +++ b/platform/broadcom/sonic-platform-modules-dell/s5212f/sonic_platform/component.py @@ -76,7 +76,7 @@ class Component(ComponentBase): self.index = component_index self.name = self.CHASSIS_COMPONENTS[self.index][0] self.description = self.CHASSIS_COMPONENTS[self.index][1] - self.version = self.CHASSIS_COMPONENTS[self.index][2]() + self.version = None def get_name(self): """ @@ -100,6 +100,8 @@ class Component(ComponentBase): Returns: A string containing the firmware version of the component """ + if self.version == None: + self.version = self.CHASSIS_COMPONENTS[self.index][2]() return self.version def install_firmware(self, image_path): diff --git a/platform/broadcom/sonic-platform-modules-dell/s5224f/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-dell/s5224f/sonic_platform/chassis.py index 1f85dd80b2..8d502700c8 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s5224f/sonic_platform/chassis.py +++ b/platform/broadcom/sonic-platform-modules-dell/s5224f/sonic_platform/chassis.py @@ -110,10 +110,7 @@ class Chassis(ChassisBase): for port_num in range(self.PORT_START, (self.PORT_END + 1)): # sfp get uses zero-indexing, but port numbers start from 1 presence = self.get_sfp(port_num-1).get_presence() - if presence: - self._global_port_pres_dict[port_num] = '1' - else: - self._global_port_pres_dict[port_num] = '0' + self._global_port_pres_dict[port_num] = '0' # check for this event change for sfp / do we need to handle timeout/sleep diff --git a/platform/broadcom/sonic-platform-modules-dell/s5224f/sonic_platform/component.py b/platform/broadcom/sonic-platform-modules-dell/s5224f/sonic_platform/component.py index 282a323f25..73e10bd115 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s5224f/sonic_platform/component.py +++ b/platform/broadcom/sonic-platform-modules-dell/s5224f/sonic_platform/component.py @@ -76,7 +76,7 @@ class Component(ComponentBase): self.index = component_index self.name = self.CHASSIS_COMPONENTS[self.index][0] self.description = self.CHASSIS_COMPONENTS[self.index][1] - self.version = self.CHASSIS_COMPONENTS[self.index][2]() + self.version = None def get_name(self): """ @@ -100,6 +100,8 @@ class Component(ComponentBase): Returns: A string containing the firmware version of the component """ + if self.version == None: + self.version = self.CHASSIS_COMPONENTS[self.index][2]() return self.version def install_firmware(self, image_path): diff --git a/platform/broadcom/sonic-platform-modules-dell/s5232f/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-dell/s5232f/sonic_platform/chassis.py index 41f985a173..f0c67d4e92 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s5232f/sonic_platform/chassis.py +++ b/platform/broadcom/sonic-platform-modules-dell/s5232f/sonic_platform/chassis.py @@ -92,8 +92,7 @@ class Chassis(ChassisBase): for port_num in range(self.PORT_START, self.PORTS_IN_BLOCK): # sfp get uses zero-indexing, but port numbers start from 1 - presence = self.get_sfp(port_num).get_presence() - self._global_port_pres_dict[port_num] = '1' if presence else '0' + self._global_port_pres_dict[port_num] = '0' def __del__(self): if self.oir_fd != -1: diff --git a/platform/broadcom/sonic-platform-modules-dell/s5232f/sonic_platform/component.py b/platform/broadcom/sonic-platform-modules-dell/s5232f/sonic_platform/component.py index 52f2bacd70..2a81be140d 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s5232f/sonic_platform/component.py +++ b/platform/broadcom/sonic-platform-modules-dell/s5232f/sonic_platform/component.py @@ -86,7 +86,7 @@ class Component(ComponentBase): self.index = component_index self.name = self.CHASSIS_COMPONENTS[self.index][0] self.description = self.CHASSIS_COMPONENTS[self.index][1] - self.version = self.CHASSIS_COMPONENTS[self.index][2]() + self.version = None def get_name(self): """ @@ -110,6 +110,8 @@ class Component(ComponentBase): Returns: A string containing the firmware version of the component """ + if self.version == None: + self.version = self.CHASSIS_COMPONENTS[self.index][2]() return self.version def install_firmware(self, image_path): diff --git a/platform/broadcom/sonic-platform-modules-dell/s5248f/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-dell/s5248f/sonic_platform/chassis.py index b047ec0c96..fc0768368e 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s5248f/sonic_platform/chassis.py +++ b/platform/broadcom/sonic-platform-modules-dell/s5248f/sonic_platform/chassis.py @@ -151,8 +151,7 @@ class Chassis(ChassisBase): self._component_list = [Component(i) for i in range(MAX_S5248F_COMPONENT)] for port_num in range(self.PORT_START, self.PORTS_IN_BLOCK): # sfp get uses zero-indexing, but port numbers start from 1 - presence = self.get_sfp(port_num-1).get_presence() - self._global_port_pres_dict[port_num] = '1' if presence else '0' + self._global_port_pres_dict[port_num] = '0' #self.LOCATOR_LED_ON = self.STATUS_LED_COLOR_BLUE_BLINK #self.LOCATOR_LED_OFF = self.STATUS_LED_COLOR_OFF diff --git a/platform/broadcom/sonic-platform-modules-dell/s5248f/sonic_platform/component.py b/platform/broadcom/sonic-platform-modules-dell/s5248f/sonic_platform/component.py index fdca4614c2..f55099cdec 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s5248f/sonic_platform/component.py +++ b/platform/broadcom/sonic-platform-modules-dell/s5248f/sonic_platform/component.py @@ -86,7 +86,7 @@ class Component(ComponentBase): self.index = component_index self.name = self.CHASSIS_COMPONENTS[self.index][0] self.description = self.CHASSIS_COMPONENTS[self.index][1] - self.version = self.CHASSIS_COMPONENTS[self.index][2]() + self.version = None def get_name(self): """ @@ -110,6 +110,8 @@ class Component(ComponentBase): Returns: A string containing the firmware version of the component """ + if self.version == None: + self.version = self.CHASSIS_COMPONENTS[self.index][2]() return self.version def install_firmware(self, image_path): diff --git a/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/chassis.py index 6ae79ffadb..77d28391d1 100755 --- a/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/chassis.py +++ b/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/chassis.py @@ -56,6 +56,9 @@ class Chassis(ChassisBase): _is_fan_control_enabled = False _fan_control_initialised = False + _global_port_pres_dict = {} + + def __init__(self): ChassisBase.__init__(self) self.status_led_reg = "system_led" @@ -107,6 +110,9 @@ class Chassis(ChassisBase): component = Component(i) self._component_list.append(component) + for port_num in range(self.PORT_START, (self.PORT_END + 1)): + self._global_port_pres_dict[port_num] = '0' + def _get_cpld_register(self, reg_name): rv = 'ERR' mb_reg_file = self.CPLD_DIR+'/'+reg_name diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/chassis.py index b3d258f32e..6b68d9c98b 100755 --- a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/chassis.py +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/chassis.py @@ -65,6 +65,9 @@ class Chassis(ChassisBase): 'amber': 0x02, 'blinking amber': 0x08 } + _global_port_pres_dict = {} + + def __init__(self): ChassisBase.__init__(self) @@ -103,6 +106,13 @@ class Chassis(ChassisBase): component = Component(i) self._component_list.append(component) + for i in self._sfp_list: + presence = i.get_presence() + if presence: + self._global_port_pres_dict[i.index] = '1' + else: + self._global_port_pres_dict[i.index] = '0' + bios_ver = self.get_component(0).get_firmware_version() bios_minor_ver = bios_ver.split("-")[-1] if bios_minor_ver.isdigit() and (int(bios_minor_ver) >= 9): diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/eeprom.py b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/eeprom.py index ab3bb174e6..cab1998be3 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/eeprom.py +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/eeprom.py @@ -11,6 +11,7 @@ try: from sonic_eeprom import eeprom_tlvinfo + import os except ImportError as e: raise ImportError(str(e) + "- required module not found") @@ -27,6 +28,10 @@ class Eeprom(eeprom_tlvinfo.TlvInfoDecoder): super(Eeprom, self).__init__(self.eeprom_path, 0, '', True) self.eeprom_tlv_dict = dict() + if os.geteuid() != 0: + self.eeprom_data = "N/A" + return + try: if self.is_module: self.write_eeprom(b"\x00\x00") diff --git a/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/chassis.py index 9430f918f9..e6f18f19db 100644 --- a/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/chassis.py +++ b/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/chassis.py @@ -84,10 +84,7 @@ class Chassis(ChassisBase): for port_num in range(self.PORT_START, (self.PORT_END + 1)): presence = self.get_sfp(port_num).get_presence() - if presence: - self._global_port_pres_dict[port_num] = '1' - else: - self._global_port_pres_dict[port_num] = '0' + self._global_port_pres_dict[port_num] = '0' def __del__(self): if self.oir_fd != -1: diff --git a/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/chassis.py index d59deb8b0a..c22466c6c1 100755 --- a/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/chassis.py +++ b/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/chassis.py @@ -147,8 +147,7 @@ class Chassis(ChassisBase): self._component_list = [Component(i) for i in range(MAX_Z9332F_COMPONENT)] for port_num in range(self.PORT_START, self.PORTS_IN_BLOCK): # sfp get uses zero-indexing, but port numbers start from 1 - presence = self.get_sfp(port_num).get_presence() - self._global_port_pres_dict[port_num] = '1' if presence else '0' + self._global_port_pres_dict[port_num] = '0' self._watchdog = Watchdog() def __del__(self): diff --git a/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/component.py b/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/component.py index 24619a481c..eb35610636 100644 --- a/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/component.py +++ b/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/component.py @@ -153,7 +153,7 @@ class Component(ComponentBase): self.index = component_index self.name = self.CHASSIS_COMPONENTS[self.index][0] self.description = self.CHASSIS_COMPONENTS[self.index][1] - self.version = self.CHASSIS_COMPONENTS[self.index][2]() + self.version = None @staticmethod def _get_available_firmware_version(image_path): @@ -242,6 +242,8 @@ class Component(ComponentBase): Returns: A string containing the firmware version of the component """ + if self.version == None: + self.version = self.CHASSIS_COMPONENTS[self.index][2]() return self.version def get_presence(self):