|
6 | 6 | #############################################################################
|
7 | 7 |
|
8 | 8 | try:
|
9 |
| - from sonic_platform_base.fan_drawer_base import FanDrawerBase |
10 |
| - from sonic_platform.fan import Fan |
| 9 | + from sonic_platform_pddf_base.pddf_fan_drawer import PddfFanDrawer |
11 | 10 | except ImportError as e:
|
12 | 11 | raise ImportError(str(e) + "- required module not found")
|
13 | 12 |
|
14 |
| - |
15 |
| -class PddfFanDrawer(FanDrawerBase): |
16 |
| - """PDDF generic Fan Drawer class""" |
17 |
| - |
18 |
| - pddf_obj = {} |
19 |
| - plugin_data = {} |
20 |
| - |
21 |
| - def __init__(self, tray_idx, pddf_data=None, pddf_plugin_data=None): |
22 |
| - FanDrawerBase.__init__(self) |
23 |
| - if not pddf_data or not pddf_plugin_data: |
24 |
| - raise ValueError('PDDF JSON data error') |
25 |
| - |
26 |
| - self.pddf_obj = pddf_data |
27 |
| - self.plugin_data = pddf_plugin_data |
28 |
| - self.platform = self.pddf_obj.get_platform() |
29 |
| - |
30 |
| - if tray_idx < 0 or tray_idx >= self.platform['num_fantrays']: |
31 |
| - print("Invalid fantray index %d\n" % tray_idx) |
32 |
| - return |
33 |
| - |
34 |
| - self.fantray_index = tray_idx+1 |
35 |
| - for j in range(self.platform['num_fans_pertray']): |
36 |
| - # Fan index is 0-based for the init call |
37 |
| - self._fan_list.append(Fan(tray_idx, j, self.pddf_obj, self.plugin_data)) #lgtm [py/call/wrong-number-class-arguments] |
38 |
| - |
39 |
| - def get_name(self): |
40 |
| - """ |
41 |
| - Retrieves the fan drawer name |
42 |
| - Returns: String containing fan-drawer name |
43 |
| - """ |
44 |
| - return "Fantray{0}".format(self.fantray_index) |
45 |
| - |
46 |
| - def get_presence(self): |
47 |
| - status = False |
48 |
| - # Usually if a tray is removed, all the fans inside it are absent |
49 |
| - if self._fan_list: |
50 |
| - status = self._fan_list[0].get_presence() |
51 |
| - |
52 |
| - return status |
53 |
| - |
54 |
| - def get_status(self): |
55 |
| - status = False |
56 |
| - # if all the fans are working fine, then tray status should be okay |
57 |
| - if self._fan_list: |
58 |
| - status = all(fan.get_status() == True for fan in self._fan_list) |
59 |
| - |
60 |
| - return status |
61 |
| - |
62 |
| - def is_replaceable(self): |
63 |
| - """ |
64 |
| - Indicate whether this device is replaceable. |
65 |
| - Returns: |
66 |
| - bool: True if it is replaceable. |
67 |
| - """ |
68 |
| - # Usually Fantrays are replaceable |
69 |
| - return False |
70 |
| - |
71 |
| - def get_position_in_parent(self): |
72 |
| - """ |
73 |
| - Retrieves 1-based relative physical position in parent device. |
74 |
| - Returns: |
75 |
| - integer: The 1-based relative physical position in parent |
76 |
| - device or -1 if cannot determine the position |
77 |
| - """ |
78 |
| - return self.fantray_index |
79 |
| - |
80 |
| - |
81 |
| - |
82 | 13 | class FanDrawer(PddfFanDrawer):
|
83 | 14 | """PDDF Platform-Specific Fan-Drawer class"""
|
84 | 15 |
|
|
0 commit comments