From 8c4bddef7b27b9039b48570212d76c66e0d3b2d0 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 29 Sep 2026 16:48:25 -0400 Subject: [PATCH] Try to identify currently communicating redfish bmc in discovery Some devices have multiple BMCs, but we don't know the 'right' one. In such a scenario, search for BMC NICs for any that match the address we are using. --- .../discovery/handlers/redfishbmc.py | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/confluent_server/confluent/discovery/handlers/redfishbmc.py b/confluent_server/confluent/discovery/handlers/redfishbmc.py index 7a9e63f3..41eadfb6 100644 --- a/confluent_server/confluent/discovery/handlers/redfishbmc.py +++ b/confluent_server/confluent/discovery/handlers/redfishbmc.py @@ -65,12 +65,42 @@ class NodeHandler(generic.NodeHandler): self._srvroot = srvroot return self._srvroot + def is_current_connection(self, nicinfo): + currip = self.ipaddr.replace('[', '').replace(']', '').split('%', 1)[0] + if ':' in currip: + for candidate in nicinfo.get('IPv6Addresses', []): + candip = candidate.get('Address', None) + if candip == currip: + return True + return False + else: + for candidate in nicinfo.get('IPv4Addresses', []): + candip = candidate.get('Address', None) + if candip == currip: + return True + return False + async def get_manager_url(self, wc): mgrs = (await self.srvroot(wc)).get('Managers', {}).get('@odata.id', None) if not mgrs: raise Exception("No Managers resource on BMC") rsp = await wc.grab_json_response(mgrs) if len(rsp.get('Members', [])) != 1: + for member in rsp.get('Members', []): + mgrurl = member.get('@odata.id', None) + if not mgrurl: + continue + mginfo = await wc.grab_json_response(mgrurl) + if 'EthernetInterfaces' not in mginfo: + continue + niclist = await wc.grab_json_response(mginfo['EthernetInterfaces']['@odata.id']) + for nic in niclist.get('Members', []): + nicurl = nic.get('@odata.id', None) + if not nicurl: + continue + nicinfo = await wc.grab_json_response(nicurl) + if self.is_current_connection(nicinfo): + return mgrurl raise Exception("Can not handle multiple Managers") mgrurl = rsp['Members'][0]['@odata.id'] return mgrurl