[DellEMC] Fixing 'show interface status' break in DellEMC platforms (#13021)
When a non-root user tries to run 'show interface status' command, the command got break as 2.0 API throws permission denied error.
This commit is contained in:
parent
7181693242
commit
e83aa15f30
@ -123,11 +123,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'
|
||||
|
||||
self.LOCATOR_LED_ON = self.STATUS_LED_COLOR_BLUE_BLINK
|
||||
self.LOCATOR_LED_OFF = self.STATUS_LED_COLOR_OFF
|
||||
|
@ -78,7 +78,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):
|
||||
"""
|
||||
@ -102,6 +102,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):
|
||||
|
@ -125,11 +125,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'
|
||||
|
||||
self.LOCATOR_LED_ON = self.STATUS_LED_COLOR_BLUE_BLINK
|
||||
self.LOCATOR_LED_OFF = self.STATUS_LED_COLOR_OFF
|
||||
|
@ -77,7 +77,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):
|
||||
"""
|
||||
@ -101,6 +101,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):
|
||||
|
@ -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:
|
||||
|
@ -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):
|
||||
|
@ -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
|
||||
|
@ -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):
|
||||
|
@ -126,6 +126,9 @@ class Chassis(ChassisBase):
|
||||
self._num_fans = MAX_S5296F_FANTRAY * MAX_S5296F_FAN
|
||||
|
||||
self._watchdog = Watchdog()
|
||||
for port_num in range(self.PORT_START, self.PORTS_IN_BLOCK):
|
||||
# sfp get uses zero-indexing, but port numbers start from 1
|
||||
self._global_port_pres_dict[port_num] = '0'
|
||||
|
||||
def __del__(self):
|
||||
if self.oir_fd != -1:
|
||||
|
@ -111,7 +111,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):
|
||||
"""
|
||||
@ -135,6 +135,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):
|
||||
|
@ -56,6 +56,8 @@ 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 +109,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
|
||||
|
@ -65,6 +65,8 @@ class Chassis(ChassisBase):
|
||||
'amber': 0x02, 'blinking amber': 0x08
|
||||
}
|
||||
|
||||
_global_port_pres_dict = {}
|
||||
|
||||
def __init__(self):
|
||||
|
||||
ChassisBase.__init__(self)
|
||||
@ -103,6 +105,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):
|
||||
|
@ -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")
|
||||
|
@ -83,11 +83,8 @@ class Chassis(ChassisBase):
|
||||
self._thermal_list.append(thermal)
|
||||
|
||||
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'
|
||||
#presence = self.get_sfp(port_num).get_presence()
|
||||
self._global_port_pres_dict[port_num] = '0'
|
||||
|
||||
def __del__(self):
|
||||
if self.oir_fd != -1:
|
||||
|
@ -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):
|
||||
|
@ -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):
|
||||
|
@ -130,8 +130,7 @@ class Chassis(ChassisBase):
|
||||
self._thermal_list = [Thermal(i) for i in range(MAX_Z9432F_THERMAL)]
|
||||
self._component_list = [Component(i) for i in range(MAX_Z9432F_COMPONENT)]
|
||||
for port_num in range(PORT_START, PORTS_IN_BLOCK):
|
||||
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()
|
||||
#self.LOCATOR_LED_ON = self.STATUS_LED_COLOR_BLUE_BLINK
|
||||
|
@ -127,7 +127,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):
|
||||
@ -208,6 +208,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):
|
||||
|
Loading…
Reference in New Issue
Block a user