Skip to content

Commit b575f00

Browse files
committed
added descrete speed control for supermicro X10 and X11
1 parent ff1a5d7 commit b575f00

File tree

4 files changed

+69
-16
lines changed

4 files changed

+69
-16
lines changed

hush/hardware/factory.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,14 @@ async def driver(
6262
cls.drivers[host][group]["instance"] = ilo.iLO4(host, fans=storage.host(host)["ilo4"].get(group, []))
6363
elif name == "Supermicro X9":
6464
cls.drivers[host][group]["instance"] = supermicro.X9(host)
65-
elif name == "Supermicro X10":
65+
elif name == "Supermicro X10 All":
6666
cls.drivers[host][group]["instance"] = supermicro.X10(host)
67-
elif name == "Supermicro X11":
67+
elif name == "Supermicro X10 Discrete":
68+
cls.drivers[host][group]["instance"] = supermicro.X10(host, speed_zones=storage.host(host)["supermicro"].get(group, []))
69+
elif name == "Supermicro X11 All":
6870
cls.drivers[host][group]["instance"] = supermicro.X11(host)
71+
elif name == "Supermicro X11 Discrete":
72+
cls.drivers[host][group]["instance"] = supermicro.X11(host, speed_zones=storage.host(host)["supermicro"].get(group, []))
6973
elif name == "Cisco M3":
7074
cls.drivers[host][group]["instance"] = cisco.M3(host)
7175
elif name == "Cisco M4":

hush/hardware/supermicro.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ class FanMode(IntEnum):
1515
OPTIMAL = 2
1616
HEAVYIO = 4
1717

18-
def __init__(self, host: str) -> None:
18+
def __init__(self, host: str, speed_zones=["0x10", "0x11"]) -> None:
1919
super().__init__(host)
2020
self.get_oob_credentials()
2121
self._fan_mode: Optional[X9.FanMode] = None
2222
self.fru: Optional[dict] = None
23+
self.speed_zones = speed_zones
2324

2425
async def close(self):
2526
await self.set_fan_mode(self.FanMode.STANDARD)
@@ -59,8 +60,8 @@ async def set_speed(self, speed):
5960
await self.set_fan_mode(self.FanMode.FULL)
6061
if speed != self._speed:
6162
pwm = hex(int(speed / (100 / 255)))
62-
await self.ipmi.execute(f"raw 0x30 0x91 0x5A 0x03 0x10 {pwm}")
63-
await self.ipmi.execute(f"raw 0x30 0x91 0x5A 0x03 0x11 {pwm}")
63+
for zone in self.speed_zones:
64+
await self.ipmi.execute(f"raw 0x30 0x91 0x5A 0x03 {zone} {pwm}")
6465
self._speed = speed
6566

6667
async def board_part_number(self) -> str:
@@ -76,16 +77,24 @@ async def board_part_number(self) -> str:
7677

7778

7879
class X10(X9):
80+
def __init__(self, host, speed_zones=None):
81+
super().__init__(host, speed_zones)
82+
83+
async def get_speed_zones(self):
84+
board_part_number = await self.board_part_number()
85+
if self.speed_zones:
86+
return self.speed_zones
87+
else:
88+
if "X10DRG" in board_part_number:
89+
return ["00", "01", "02", "03"]
90+
else:
91+
return ["00", "01"]
92+
7993
async def set_speed(self, speed):
8094
await self.set_fan_mode(self.FanMode.FULL)
8195
if speed != self._speed:
8296
pwm = hex(int(speed / (100 / 255)))
83-
board_part_number = await self.board_part_number()
84-
if "X10DRG" in board_part_number:
85-
zones = ["00", "01", "02", "03"]
86-
else:
87-
zones = ["00", "01"]
88-
for zone in zones:
97+
for zone in await self.get_speed_zones():
8998
await self.ipmi.execute(f"raw 0x30 0x70 0x66 0x01 0x{zone} {pwm}")
9099
self._speed = speed
91100

hush/storage.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@
2626
if "drive" in hosts[h]:
2727
if hosts[h]["drive"] == "SMART":
2828
hosts[h]["drive"] = "SMART All"
29+
if "speed" in hosts[h]:
30+
if hosts[h]["speed"] == "Supermicro X10":
31+
hosts[h]["speed"] = "Supermicro X10 All"
32+
if "speed" in hosts[h]:
33+
if hosts[h]["speed"] == "Supermicro X11":
34+
hosts[h]["speed"] = "Supermicro X11 All"
2935
if "ilo4" not in hosts[h]:
3036
hosts[h]["ilo4"] = {}
3137
if "smart" not in hosts[h]:
@@ -34,6 +40,8 @@
3440
hosts[h]["chassis"] = "None"
3541
if "shared" not in hosts[h]:
3642
hosts[h]["shared"] = {}
43+
if "supermicro" not in hosts[h]:
44+
hosts[h]["supermicro"] = {}
3745

3846

3947
def host(name: str) -> dict:

hush/tabs/configure.py

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@
3939
"HP iLO 4 All",
4040
"HP iLO 4 Discrete",
4141
"Supermicro X9",
42-
"Supermicro X10",
43-
"Supermicro X11",
42+
"Supermicro X10 All",
43+
"Supermicro X10 Discrete",
44+
"Supermicro X11 All",
45+
"Supermicro X11 Discrete",
4446
"Cisco M3",
4547
"Cisco M4",
4648
"Cisco M5",
@@ -64,6 +66,7 @@ def _build(self):
6466
self._ilo4 = {}
6567
self._smart = {}
6668
self._shared = {}
69+
self._supermicro = {}
6770
self._add_selections()
6871

6972
def _add_selections(self):
@@ -90,6 +93,8 @@ def _add_selections(self):
9093
self._ilo4["speed"].visible = False
9194
self._shared["speed"] = el.WRow()
9295
self._shared["speed"].visible = False
96+
self._supermicro["speed"] = el.WRow()
97+
self._supermicro["speed"].visible = False
9398
with el.WRow():
9499
self._select["cpu"] = ui.select(
95100
cpu_sensor_names,
@@ -168,6 +173,7 @@ async def _store_select(self, group, value):
168173
await self._build_ilo4_ctrl(group)
169174
await self._build_smart_ctrl()
170175
await self._build_shared_ctrl(group)
176+
await self._build_supermicro_ctrl(group)
171177
await Factory.close(self.host, group)
172178
self._control_rebuild()
173179

@@ -243,6 +249,29 @@ async def _build_shared_ctrl(self, group):
243249
if group in self._ilo4:
244250
self._shared[group].visible = False
245251

252+
async def _build_supermicro_ctrl(self, group):
253+
if self._select[group].value == "Supermicro X10 Discrete" or self._select[group].value == "Supermicro X11 Discrete":
254+
self._skeleton[group].visible = True
255+
self._supermicro[group].bind_visibility_from(self._skeleton[group], value=False)
256+
labels = {"speed": "Supermicro Fan Zones"}
257+
self._supermicro[group].clear()
258+
with self._supermicro[group]:
259+
if group == "speed":
260+
options = ["00", "01", "02", "03"]
261+
else:
262+
options = []
263+
ui.select(
264+
options,
265+
label=labels[group],
266+
value=storage.host(self.host)["supermicro"].get(group, []),
267+
on_change=lambda e: self._store_select_supermicro(group, e.value),
268+
multiple=True,
269+
).classes("col")
270+
self._skeleton[group].visible = False
271+
else:
272+
if group in self._supermicro:
273+
self._supermicro[group].visible = False
274+
246275
async def _update_ctrls(self):
247276
groups = ["speed", "cpu", "pci", "drive", "gpu", "chassis"]
248277
for group in groups:
@@ -252,12 +281,11 @@ async def _update_ctrls(self):
252281
await self._build_shared_ctrl(group)
253282
groups = ["speed", "cpu", "pci"]
254283
for group in groups:
255-
if self._select[group].value == "HP iLO 4 Discrete":
284+
if "Discrete" in self._select[group].value:
256285
self._skeleton[group].visible = True
257286
for group in groups:
258287
await self._build_ilo4_ctrl(group)
259-
if self._select["drive"].value == "SMART Discrete":
260-
self._skeleton["drive"].visible = True
288+
await self._build_supermicro_ctrl(group)
261289
await self._build_smart_ctrl()
262290

263291
async def _store_select_ilo4(self, group, value):
@@ -272,6 +300,10 @@ async def _store_select_shared(self, group, value):
272300
storage.host(self.host)["shared"][group] = value
273301
await Factory.close(self.host, group)
274302

303+
async def _store_select_supermicro(self, group, value):
304+
storage.host(self.host)["supermicro"][group] = value
305+
await Factory.close(self.host, group)
306+
275307
async def _test(self, group):
276308
device = None
277309
status = None

0 commit comments

Comments
 (0)