[platform][barefoot] Lazy initialize fans and thermals list (#7103)

Initialize fans and thermals lists on demand; make them properties in order to reduce Chassis object initialization time

Signed-off-by: Volodymyr Boyko <volodymyrx.boiko@intel.com>
This commit is contained in:
Volodymyr Boiko 2021-03-26 19:18:54 +02:00 committed by GitHub
parent bf43dd375a
commit e1d8d1895b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -28,8 +28,28 @@ class Chassis(ChassisBase):
psu = Psu(i)
self._psu_list.append(psu)
self._fan_drawer_list = fan_drawer_list_get()
self._thermal_list = thermal_list_get()
self.__fan_drawers = None
self.__thermals = None
@property
def _fan_drawer_list(self):
if self.__fan_drawers is None:
self.__fan_drawers = fan_drawer_list_get()
return self.__fan_drawers
@_fan_drawer_list.setter
def _fan_drawer_list(self, value):
pass
@property
def _thermal_list(self):
if self.__thermals is None:
self.__thermals = thermal_list_get()
return self.__thermals
@_thermal_list.setter
def _thermal_list(self, value):
pass
def get_name(self):
"""