diff --git a/confluent_server/aiohmi/ipmi/command.py b/confluent_server/aiohmi/ipmi/command.py index d0151422..51d68f81 100644 --- a/confluent_server/aiohmi/ipmi/command.py +++ b/confluent_server/aiohmi/ipmi/command.py @@ -817,6 +817,25 @@ class Command(object): await self.oem_init() return await self._oem.get_sensor_reading(sensorname) + 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. + """ + fetchcmd = bytearray((channel, param, selector, 0)) + fetched = await self.oldraw_command(0xc, 2, data=fetchcmd) + if fetched['code'] in (0x80, 0xc9): + # parameter not supported, and parameter out of range + return None + if fetched['code']: + raise exc.IpmiException(util.get_ipmi_error(fetched), + fetched['code']) + return bytearray(fetched['data']) + async def _fetch_lancfg_param(self, channel, param, prefixlen=False): """Internal helper for fetching lan cfg parameters @@ -824,20 +843,8 @@ class Command(object): string with ipv4. If 6 bytes, colon delimited hex (mac address). If one byte, return the int value """ - fetchcmd = bytearray((channel, param, 0, 0)) - fetched = await self.oldraw_command(0xc, 2, data=fetchcmd) - # A bmc without the parameter says so in the completion code and sends - # no data at all, so the code has to be read before the payload is. - # oldraw_command reports the code rather than raising on it, which is - # why this cannot be done by catching something. - if fetched['code'] in (0x80, 0xc9): - # parameter not supported, and parameter out of range - return None - if fetched['code']: - raise exc.IpmiException(util.get_ipmi_error(fetched), - fetched['code']) - fetchdata = fetched['data'] - if not fetchdata or bytearray(fetchdata)[0] != 17: + fetchdata = await self._fetch_lancfg_data(channel, param) + if not fetchdata or fetchdata[0] != 17: return None if param == 0x14: vlaninfo = struct.unpack('