3ea3a5c8c1
#### Why I did it According to thermalctld hld, each fan must belong to a fan drawer, if the fan drawer does not physically exist, put fan into a virtual fan drawer. This PR is to clear fan from chassis._fan_list #### How I did it 1. Don't put fan to chassis._fan_list 2. Always query fan from fan_drawer
77 lines
1.6 KiB
Python
77 lines
1.6 KiB
Python
class MockFan:
|
|
speed = 60
|
|
def __init__(self):
|
|
self.presence = True
|
|
self.name = None
|
|
self.status = True
|
|
|
|
def get_presence(self):
|
|
return self.presence
|
|
|
|
def set_speed(self, speed):
|
|
MockFan.speed = speed
|
|
|
|
def get_status(self):
|
|
return self.status
|
|
|
|
def get_target_speed(self):
|
|
return MockFan.speed
|
|
|
|
def get_name(self):
|
|
return self.name
|
|
|
|
|
|
class MockPsu:
|
|
def __init__(self):
|
|
self.presence = True
|
|
self.powergood = True
|
|
|
|
def get_presence(self):
|
|
return self.presence
|
|
|
|
def get_powergood_status(self):
|
|
return self.powergood
|
|
|
|
def get_all_fans(self):
|
|
return []
|
|
|
|
|
|
class MockFanDrawer:
|
|
def __init__(self):
|
|
self.fan_list = []
|
|
|
|
def get_all_fans(self):
|
|
return self.fan_list
|
|
|
|
|
|
class MockChassis:
|
|
def __init__(self):
|
|
self.fan_list = []
|
|
self.psu_list = []
|
|
self.fan_drawer_list = []
|
|
|
|
def get_all_psus(self):
|
|
return self.psu_list
|
|
|
|
def get_all_fans(self):
|
|
return self.fan_list
|
|
|
|
def get_all_fan_drawers(self):
|
|
return self.fan_drawer_list
|
|
|
|
def get_thermal_manager(self):
|
|
from sonic_platform.thermal_manager import ThermalManager
|
|
return ThermalManager
|
|
|
|
def make_fan_absence(self):
|
|
fan = MockFan()
|
|
fan.presence = False
|
|
fan_drawer = MockFanDrawer()
|
|
self.fan_drawer_list.append(fan_drawer)
|
|
fan_drawer.fan_list.append(fan)
|
|
|
|
def make_psu_absence(self):
|
|
psu = MockPsu()
|
|
psu.presence = False
|
|
self.psu_list.append(psu)
|