forked from alibaba-archive/alibabacloud-tool-bmc-hal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhal_fan.py
222 lines (182 loc) · 6.6 KB
/
hal_fan.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
###############################################################################
#
# Hardware Abstraction Layer APIs -- FAN APIs.
#
# Copyright (C) Alibaba, INC.
#
###############################################################################
"""
class for HAL Fan APIs
API parameters convention:
@param fan_name: Name of the specific fan, format: "FAN%d" % (fan_index),
where fan_index is integer starting from 1
@param rotor_index: Index of the specific fan's rotor, integer starting from 1
"""
class HalFan(object):
def __init__(self):
pass
def get_total_number(self):
"""
Get total fan number count
@return total number of fan in the system, -1 for failure
"""
pass
def get_rotor_number(self, fan_name):
"""
Get fan's rotor count for specific fan_name
@return total rotor count of specific fan, -1 for failure
"""
pass
def get_speed(self, fan_name, rotor_index):
"""
Get current speed for specific fan and rotor
@return speed of the specific fan and rotor, unit is RPM,
-1 for failure
"""
pass
def set_speed(self, fan_name, rotor_index, speed):
"""
Get current speed for specific fan and rotor
@param speed of the specific fan and rotor, unit is RPM
@return 0 for success, -1 for failure
"""
pass
def get_speed_pwm(self, fan_name, rotor_index):
"""
Get current PWM duty cycle for specific fan's specific rotor
@return PWM duty cycle, unit is 1%, -1 for failure
"""
pass
def set_speed_pwm(self, fan_name, rotor_index, pwm):
"""
Set PWM for specific fan's specific rotor
@param pwm duty cycle, unit is 1%, -1 for failure
@return 0 for success, -1 for failure
"""
pass
def get_watchdog_status(self):
"""
Get Fan watchdog status.
@return 'Normal'/'Abnormal'/'N/A' for status good/bad/read-failed.
"""
pass
def enable_watchdog(self, enable=True, timeout_sec=10):
"""
Enable Fan watchdog
@return 0 for success, -1 for failure
"""
pass
def feed_watchdog(self, pwm):
"""
Feed watchdog
@param pwm duty cycle, unit is 1%, -1 for failure
@return 0 for success, -1 for failure
"""
pass
def set_led(self, fan_name, color, blink=False):
"""
Set fan LED
@param color The color of system fan LED, "green"/"yellow"/"off"
@param blink True for blinking, False for steady
@return 0 for success, -1 for failure
"""
pass
def get_presence(self, fan_name):
"""
Get a specific fan's presence status
@return True for present, False for not present or failure
"""
pass
def get_fru_info(self, fan_name):
"""
Get specific fan's information
@return dict for specific fan on success, None for failure
Example return value(all keys are mandatory)
{
# Properties
"Name": "FAN1",
"SN": "serial_number_example", # 'N/A'
"PN": "part_number_exampple", # 'N/A'
"Rotors": 2, # -1
"AirFlow": "F2B", # 'N/A'
"SpeedMin": 2000, # -1
"SpeedMax": 30000 # -1
}
"""
pass
def get_status(self, fan_name):
"""
Get status of specific fan
@return dict for specific fan for success, None for failure
Example return value(all keys are mandatory)
{
"Rotor1": {
"Running": "no", # 'N/A'
"HwAlarm": "yes", # 'N/A'
"speed": 0 # -1
},
"Rotor2": {
"Running": "yes",
"HwAlarm": "no",
"Speed": 6800
}
}
"""
pass
def get_info_all(self):
"""
Get all fans' info
@return dict of all system fans' infor for success, None for failure
Example return value(all keys are mandatory)
{
"Number": 2, # -99999
"WatchdogStatus": "Normal", # "Abnormal"/"N/A"
"FAN1": {
# Properties
"Name": FAN1,
"SN": "serial_number_example", # 'N/A'
"PN": "part_number_exampple", # 'N/A'
"Present": "yes", # 'N/A'
"Rotors": 2, # -99999
"AirFlow": "F2B", # 'N/A'
# Status, dynamic data
"Rotor1": {
"Running": "yes", # 'N/A'
"HwAlarm": "no", # 'N/A'
"Speed": 7000 # -99999
"SpeedMin": 2000, # -99999
"SpeedMax": 30000, # -99999
},
"Rotor2": {
"Running": "yes",
"HwAlarm": "no"
"Speed": 8000
"SpeedMin": 2000,
"SpeedMax": 30000,
}
},
"FAN2": {
# Properties
"Name": FAN2,
"SN": "serial_number_example",
"PN": "part_number_exampple",
"Present": "yes"
"Rotors": 2,
"AirFlow": "F2B",
"SpeedMin": 2000,
"SpeedMax": 30000,
# Status, dynamic data
"Rotor1": {
"Running": "no",
"HwAlarm": "yes",
"Speed": 0
},
"Rotor2": {
"Running": "yes",
"HwAlarm": "no",
"Speed": 6800
}
}
}
"""
pass