From fd84d38bbd56a130574df3184965fc7ebdc3875e Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Sat, 15 Aug 2026 05:07:57 +0200 Subject: [PATCH] Read the lan config parameter through raw_command pyghmi asks for this parameter with xraw_command and catches the completion code for a bmc that does not have it, and folding aiohmi in renamed that call to oldraw_command rather than raw_command, so the handler could no longer fire. Answering the code out of the returned dictionary repaired the crash but kept the call on the older contract, which is now the only one left in the tree. Catch it again instead: raw_command puts the completion code on the exception as ipmicode, and nothing here reads the payload of a reply that carries a code, which is the one thing catching gives up. No behaviour change, checked against the previous version over the same fake session for a good reply, an empty one, 0x80 and 0xC9 with and without a stray payload, four other completion codes, a timeout, a lost session and a reply with no data at all: same return value, same exception type, text and ipmicode, same bytes on the wire. --- confluent_server/aiohmi/ipmi/command.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/confluent_server/aiohmi/ipmi/command.py b/confluent_server/aiohmi/ipmi/command.py index 78cdacb3..d7d5ffa2 100644 --- a/confluent_server/aiohmi/ipmi/command.py +++ b/confluent_server/aiohmi/ipmi/command.py @@ -824,20 +824,17 @@ class Command(object): async def _fetch_lancfg_data(self, channel, param, selector=0): """Internal helper for fetching a lan cfg parameter's raw data - Answers None if the bmc does not have the parameter. Such a bmc says - so in the completion code and sends no data at all, so the code has to - be read before the payload is, and oldraw_command reports the code - rather than raising on it, which is why this cannot be done by - catching something. + Answers None if the bmc does not have the parameter, which such a bmc + reports in the completion code, sending no data at all. """ fetchcmd = bytearray((channel, param, selector, 0)) - fetched = await self.oldraw_command(0xc, 2, data=fetchcmd) - if fetched['code'] in (0x80, 0xc9): + try: + fetched = await self.raw_command(0xc, 2, data=fetchcmd) + except exc.IpmiException as ie: # parameter not supported, and parameter out of range - return None - if fetched['code']: - raise exc.IpmiException(util.get_ipmi_error(fetched), - fetched['code']) + if ie.ipmicode in (0x80, 0xc9): + return None + raise return bytearray(fetched['data']) async def _fetch_lancfg_param(self, channel, param, prefixlen=False):