forked from alibaba-archive/alibabacloud-tool-bmc-hal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhal_psu.py
221 lines (198 loc) · 7.37 KB
/
hal_psu.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
###############################################################################
#
# Hardware Abstraction Layer APIs -- FAN APIs.
#
# Copyright (C) Alibaba, INC.
#
###############################################################################
"""
class for HAL PSU APIs
API parameters convention:
@param psu_name Name of a PSU, format: "PSU%d" % psu_index, where psu_index is
integer starting from 1
"""
class HalPsu(object):
def __init__(self):
pass
def get_total_number(self):
"""
Get system's total number of PSU
@return Total number of PSU, -1 for failure
"""
pass
def get_presence(self, psu_name):
"""
Get a specific PSU's presence status
@return True if present, False for NOT present or failure
"""
pass
def get_fru_info(self, psu_name):
"""
Get FRU info of a specific PSU
@return dict of the specific PSU's info, None for failure
Example return value(all keys are mandatory)
{
"Name": "PSU1",
"SN": "serial_number_example", # 'N/A'
"PN": "part_number_example", # 'N/A'
"AirFlow": "B2F" # 'N/A'
}
"""
pass
def get_status(self, psu_name):
"""
Get status of a specific PSU
@return dict of the specific PSU's status, None for failure
Example return value(all keys are mandatory)
{
"Name": "PSU1",
"InputType": "DC", # "AC" or 'N/A'
"InputStatus": True, # H/W status bit
"OutputStatus": True # H/W status bit
"FanSpeed": {
"Value": 4000, # -99999
"Min": 2000, # -99999
"Max": 10000 # -99999
},
"Temperature": {
"Value": 40.0, # -99999.0
"Min": -30.0, # -99999.0
"Max": 50.0 # -99999.0
}
}
"""
pass
def get_power_status(self, psu_name):
"""
Get power status of a specific PSU
@return dict of the specific PSU's power status, None for failure
Example return value
{
"Name": "PSU1",
"Inputs": {
"Status": True, # H/W status bit
"Type": "DC", # or "AC" or "N/A"
"Voltage": {
"Value": 220, # -1
"LowAlarm": 200, # -1
"HighAlarm": 240, # -1
"Unit": "V"
},
"Current": {
"Value": 6.0, # -99999.0
"LowAlarm": 0.2, # -99999.0
"HighAlarm": 7.0, # -99999.0
"Unit": "A"
},
"Power": {
"Value": 1000, # -99999
"LowAlarm": -1, # -99999
"HighAlarm": 1400, # -99999
"Unit": "W"
}
},
"Outputs": {
"Status": True,
"Voltage": {
"Value": 220,
"LowAlarm": 200,
"HighAlarm": 240,
"Unit": "V"
},
"Current": {
"Value": 6.0,
"LowAlarm": 0.2,
"HighAlarm": 7.0,
"Unit": "A"
},
"Power": {
"Value": 1000,
"LowAlarm": -1, # Don't care
"HighAlarm": 1400,
"Unit": "W"
}
}
}
"""
pass
def set_psu_fan_speed_pwm(self, psu_name, pwm):
"""
Set a specific PSU's fan's speed
@param pwm duty cycle, unit is 1%
@return 0 for success, -1 for failure
"""
pass
def get_fan_speed_pwm(self, psu_name):
"""
Get a specific PSU's fan's speed
@return pwm duty cycle, unit is 1%, -1 for failure
"""
pass
def get_info_all(self):
"""
Get all system PSU's info
@return dict of all PSUs or None for failure
{
"Number": 2,
"PSU1": {
"SN": "serial_number_example", # 'N/A'
"PN": "part_number_example", # 'N/A'
"AirFlow": "F2B", # 'N/A'
"Present": "yes" # "no"
"FanSpeed": {
"Value": 4000,
"Min": 2000,
"Max": 30000
},
"Temperature": {
"Value": 35.0,
"Min": -20.0,
"Max": 45.0
},
"Inputs": {
"Status": True, # H/W status bit
"Type": "DC", # or "AC"
"Voltage": {
"Value": 220,
"LowAlarm": 200,
"HighAlarm": 240,
"Unit": "V"
},
"Current": {
"Value": 6.0,
"LowAlarm": 0.2,
"HighAlarm": 7.0,
"Unit": "A"
},
"Power": {
"Value": 1000,
"LowAlarm": -1,
"HighAlarm": 1400,
"Unit": "W"
}
},
"Outputs": {
"Status": True,
"Voltage": {
"Value": 220,
"LowAlarm": 200,
"HighAlarm": 240,
"Unit": "V"
},
"Current": {
"Value": 6.0,
"LowAlarm": 0.2,
"HighAlarm": 7.0,
"Unit": "A"
},
"Power": {
"Value": 1000,
"LowAlarm": -1, # Don't care
"HighAlarm": 1400,
"Unit": "W"
}
}
}
}
"""
pass