DellEMC: Fix API2.0 initialization issue (#15687)

Why I did it
To fix sonic-net/sonic-mgmt#8786

How I did it
Modified Fan API to check whether the data retrieved is valid or not and return accordingly

How to verify it
Verify whether API 2.0 is loaded properly or not.
Execute CLI's like "show version", "show interface status", "show platform psustatus" etc..
This commit is contained in:
Aravind Mani 2023-07-20 22:20:22 +05:30 committed by GitHub
parent 05314f9e5b
commit 2de5abdaf4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 31 additions and 20 deletions

View File

@ -71,8 +71,7 @@ class Fan(FanBase):
self.fru = IpmiFru(self.PSU_FRU_MAPPING[self.fanindex])
self.max_speed_offset = PSU_FAN_MAX_SPEED_OFFSET
self.fan_direction_offset = PSU_FAN_DIRECTION_OFFSET
self.max_speed = self.fru.get_fru_data(self.max_speed_offset,2)[1]
self.max_speed = self.max_speed[1] << 8 | self.max_speed[0]
self.max_speed = 0
def get_name(self):
"""
@ -163,11 +162,14 @@ class Fan(FanBase):
int: percentage of the max fan speed
"""
if self.max_speed == 0:
self.max_speed = self.fru.get_fru_data(self.max_speed_offset,2)[1]
self.max_speed = self.max_speed[1] << 8 | self.max_speed[0]
is_valid, max_speed = self.fru.get_fru_data(self.max_speed_offset,2)
if not is_valid:
return 0
self.max_speed = max_speed[1]
self.max_speed = max_speed[1] << 8 | max_speed[0]
is_valid, fan_speed = self.speed_sensor.get_reading()
if not is_valid or self.max_speed == 0:
return None
speed = 0
else:
speed = (100 * fan_speed)//self.max_speed
return speed

View File

@ -69,8 +69,7 @@ class Fan(FanBase):
self.fru = IpmiFru(self.PSU_FRU_MAPPING[self.fanindex])
self.max_speed_offset = PSU_FAN_MAX_SPEED_OFFSET
self.fan_direction_offset = PSU_FAN_DIRECTION_OFFSET
self.max_speed = self.fru.get_fru_data(self.max_speed_offset,2)[1]
self.max_speed = self.max_speed[1] << 8 | self.max_speed[0]
self.max_speed = 0
def get_name(self):
"""
@ -163,8 +162,11 @@ class Fan(FanBase):
int: percentage of the max fan speed
"""
if self.max_speed == 0:
self.max_speed = self.fru.get_fru_data(self.max_speed_offset,2)[1]
self.max_speed = self.max_speed[1] << 8 | self.max_speed[0]
is_valid, max_speed = self.fru.get_fru_data(self.max_speed_offset,2)
if not is_valid:
return 0
self.max_speed = max_speed[1]
self.max_speed = max_speed[1] << 8 | max_speed[0]
is_valid, fan_speed = self.speed_sensor.get_reading()
if not is_valid or self.max_speed == 0:
speed = 0

View File

@ -71,8 +71,7 @@ class Fan(FanBase):
self.fru = IpmiFru(self.PSU_FRU_MAPPING[self.fanindex])
self.max_speed_offset = PSU_FAN_MAX_SPEED_OFFSET
self.fan_direction_offset = PSU_FAN_DIRECTION_OFFSET
self.max_speed = self.fru.get_fru_data(self.max_speed_offset,2)[1]
self.max_speed = self.max_speed[1] << 8 | self.max_speed[0]
self.max_speed = 0
def get_name(self):
"""
@ -165,11 +164,14 @@ class Fan(FanBase):
int: percentage of the max fan speed
"""
if self.max_speed == 0:
self.max_speed = self.fru.get_fru_data(self.max_speed_offset,2)[1]
self.max_speed = self.max_speed[1] << 8 | self.max_speed[0]
is_valid, max_speed = self.fru.get_fru_data(self.max_speed_offset,2)
if not is_valid:
return 0
self.max_speed = max_speed[1]
self.max_speed = max_speed[1] << 8 | max_speed[0]
is_valid, fan_speed = self.speed_sensor.get_reading()
if not is_valid or self.max_speed == 0:
return None
speed = 0
else:
speed = (100 * fan_speed)//self.max_speed
return speed

View File

@ -71,8 +71,7 @@ class Fan(FanBase):
self.fru = IpmiFru(self.PSU_FRU_MAPPING[self.fanindex])
self.max_speed_offset = PSU_FAN_MAX_SPEED_OFFSET
self.fan_direction_offset = PSU_FAN_DIRECTION_OFFSET
self.max_speed = self.fru.get_fru_data(self.max_speed_offset,2)[1]
self.max_speed = self.max_speed[1] << 8 | self.max_speed[0]
self.max_speed = 0
def get_name(self):
"""
@ -165,8 +164,11 @@ class Fan(FanBase):
int: percentage of the max fan speed
"""
if self.max_speed == 0:
self.max_speed = self.fru.get_fru_data(self.max_speed_offset,2)[1]
self.max_speed = self.max_speed[1] << 8 | self.max_speed[0]
is_valid, max_speed = self.fru.get_fru_data(self.max_speed_offset,2)
if not is_valid:
return 0
self.max_speed = max_speed[1]
self.max_speed = max_speed[1] << 8 | max_speed[0]
is_valid, fan_speed = self.speed_sensor.get_reading()
if not is_valid or self.max_speed == 0:
speed = 0

View File

@ -165,8 +165,11 @@ class Fan(FanBase):
int: percentage of the max fan speed
"""
if self.max_speed == 0:
self.max_speed = self.fru.get_fru_data(self.max_speed_offset, 2)[1]
self.max_speed = self.max_speed[1] << 8 | self.max_speed[0]
is_valid, max_speed = self.fru.get_fru_data(self.max_speed_offset, 2)
if not is_valid:
return 0
self.max_speed = max_speed[1]
self.max_speed = max_speed[1] << 8 | max_speed[0]
is_valid, fan_speed = self.speed_sensor.get_reading()
if not is_valid or self.max_speed == 0:
return None