[BFN] Fixed FANs indexing for multi-drawer case (#12491)
Why I did it In case the device contains more then one FAN drawer, the FANs name was incorrect. How I did it Passed max fan value to FAN object. Fixed get_name() FAN API How to verify it show platform fan
This commit is contained in:
parent
f0873f29d8
commit
00178187d0
@ -17,15 +17,15 @@ def _fan_info_get(fan_num, cb, default=None):
|
||||
|
||||
# Fan -> FanBase -> DeviceBase
|
||||
class Fan(FanBase):
|
||||
def __init__(self, index, fantrayindex):
|
||||
def __init__(self, index, max_index, fantrayindex):
|
||||
self.__index = index
|
||||
self.__fantrayindex = fantrayindex
|
||||
self.__glob_index = (fantrayindex - 1) * max_index + self.__index
|
||||
|
||||
# FanBase interface methods:
|
||||
# returns speed in percents
|
||||
def get_speed(self):
|
||||
def cb(info): return info.percent
|
||||
return _fan_info_get(self.__index, cb, 0)
|
||||
return _fan_info_get(self.__glob_index, cb, 0)
|
||||
|
||||
def set_speed(self, percent):
|
||||
# Fan tray speed controlled by BMC
|
||||
@ -33,10 +33,10 @@ class Fan(FanBase):
|
||||
|
||||
# DeviceBase interface methods:
|
||||
def get_name(self):
|
||||
return "counter-rotating-fan-{}".format((self.__fantrayindex - 1) * self.__index + self.__index)
|
||||
return "counter-rotating-fan-{}".format(self.__glob_index)
|
||||
|
||||
def get_presence(self):
|
||||
return _fan_info_get(self.__index, lambda _: True, False)
|
||||
return _fan_info_get(self.__glob_index, lambda _: True, False)
|
||||
|
||||
def get_position_in_parent(self):
|
||||
return self.__index
|
||||
|
@ -10,7 +10,7 @@ class FanDrawer(FanDrawerBase):
|
||||
def __init__(self, fantray_index, max_fan):
|
||||
# For now we return only present fans
|
||||
self.fantrayindex = fantray_index
|
||||
self._fan_list = [Fan(i, self.fantrayindex) for i in range(1, max_fan + 1)]
|
||||
self._fan_list = [Fan(i, max_fan, self.fantrayindex) for i in range(1, max_fan + 1)]
|
||||
|
||||
# DeviceBase interface methods:
|
||||
def get_name(self):
|
||||
|
Reference in New Issue
Block a user