2021-10-17 11:03:02 -05:00
|
|
|
#
|
|
|
|
# Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES.
|
|
|
|
# Apache-2.0
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
#
|
2020-03-09 12:41:10 -05:00
|
|
|
class MockFan:
|
2020-04-21 10:09:53 -05:00
|
|
|
speed = 60
|
2020-03-09 12:41:10 -05:00
|
|
|
def __init__(self):
|
|
|
|
self.presence = True
|
2020-05-13 12:01:32 -05:00
|
|
|
self.name = None
|
2020-04-21 10:09:53 -05:00
|
|
|
self.status = True
|
2020-03-09 12:41:10 -05:00
|
|
|
|
|
|
|
def get_presence(self):
|
|
|
|
return self.presence
|
|
|
|
|
|
|
|
def set_speed(self, speed):
|
2020-04-21 10:09:53 -05:00
|
|
|
MockFan.speed = speed
|
|
|
|
|
|
|
|
def get_status(self):
|
|
|
|
return self.status
|
|
|
|
|
|
|
|
def get_target_speed(self):
|
|
|
|
return MockFan.speed
|
2020-03-09 12:41:10 -05:00
|
|
|
|
2020-05-13 12:01:32 -05:00
|
|
|
def get_name(self):
|
|
|
|
return self.name
|
|
|
|
|
2020-03-09 12:41:10 -05:00
|
|
|
|
|
|
|
class MockPsu:
|
|
|
|
def __init__(self):
|
|
|
|
self.presence = True
|
2020-03-25 12:54:07 -05:00
|
|
|
self.powergood = True
|
2020-03-09 12:41:10 -05:00
|
|
|
|
|
|
|
def get_presence(self):
|
|
|
|
return self.presence
|
|
|
|
|
2020-03-25 12:54:07 -05:00
|
|
|
def get_powergood_status(self):
|
|
|
|
return self.powergood
|
|
|
|
|
2020-04-21 10:09:53 -05:00
|
|
|
def get_all_fans(self):
|
|
|
|
return []
|
|
|
|
|
2020-03-09 12:41:10 -05:00
|
|
|
|
2021-05-24 13:36:39 -05:00
|
|
|
class MockFanDrawer:
|
|
|
|
def __init__(self):
|
|
|
|
self.fan_list = []
|
|
|
|
|
|
|
|
def get_all_fans(self):
|
|
|
|
return self.fan_list
|
|
|
|
|
|
|
|
|
2020-03-09 12:41:10 -05:00
|
|
|
class MockChassis:
|
|
|
|
def __init__(self):
|
|
|
|
self.fan_list = []
|
|
|
|
self.psu_list = []
|
2021-05-24 13:36:39 -05:00
|
|
|
self.fan_drawer_list = []
|
2020-03-09 12:41:10 -05:00
|
|
|
|
|
|
|
def get_all_psus(self):
|
|
|
|
return self.psu_list
|
|
|
|
|
|
|
|
def get_all_fans(self):
|
|
|
|
return self.fan_list
|
|
|
|
|
2021-05-24 13:36:39 -05:00
|
|
|
def get_all_fan_drawers(self):
|
|
|
|
return self.fan_drawer_list
|
|
|
|
|
2020-03-09 12:41:10 -05:00
|
|
|
def get_thermal_manager(self):
|
|
|
|
from sonic_platform.thermal_manager import ThermalManager
|
|
|
|
return ThermalManager
|
|
|
|
|
|
|
|
def make_fan_absence(self):
|
|
|
|
fan = MockFan()
|
|
|
|
fan.presence = False
|
2021-05-24 13:36:39 -05:00
|
|
|
fan_drawer = MockFanDrawer()
|
|
|
|
self.fan_drawer_list.append(fan_drawer)
|
|
|
|
fan_drawer.fan_list.append(fan)
|
2020-03-09 12:41:10 -05:00
|
|
|
|
|
|
|
def make_psu_absence(self):
|
|
|
|
psu = MockPsu()
|
|
|
|
psu.presence = False
|
|
|
|
self.psu_list.append(psu)
|