Skip to content

Commit e1d8d18

Browse files
authored
[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 <[email protected]>
1 parent bf43dd3 commit e1d8d18

File tree

1 file changed

+22
-2
lines changed
  • platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform

1 file changed

+22
-2
lines changed

platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/chassis.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,28 @@ def __init__(self):
2828
psu = Psu(i)
2929
self._psu_list.append(psu)
3030

31-
self._fan_drawer_list = fan_drawer_list_get()
32-
self._thermal_list = thermal_list_get()
31+
self.__fan_drawers = None
32+
self.__thermals = None
33+
34+
@property
35+
def _fan_drawer_list(self):
36+
if self.__fan_drawers is None:
37+
self.__fan_drawers = fan_drawer_list_get()
38+
return self.__fan_drawers
39+
40+
@_fan_drawer_list.setter
41+
def _fan_drawer_list(self, value):
42+
pass
43+
44+
@property
45+
def _thermal_list(self):
46+
if self.__thermals is None:
47+
self.__thermals = thermal_list_get()
48+
return self.__thermals
49+
50+
@_thermal_list.setter
51+
def _thermal_list(self, value):
52+
pass
3353

3454
def get_name(self):
3555
"""

0 commit comments

Comments
 (0)