Skip to content

Commit

Permalink
smdclient: look up EthernetInterfaces, not ComponentEndpoint
Browse files Browse the repository at this point in the history
This still provides the MAC address that we need, and includes an IP
address that we'll use shortly.
  • Loading branch information
LRitzdorf committed Jul 19, 2024
1 parent b67933e commit 19d0ce6
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions internal/smdclient/SMDclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,24 @@ func (s *SMDClient) getSMD(ep string, smd interface{}) error {
return nil
}

// Helper array type
// TODO: This probably belongs in OpenCHAMI/smd, pkg/sm/endpoints.go
type CompEthInterfaceV2Array struct {
Array []*sm.CompEthInterfaceV2
}

// IDfromMAC returns the ID of the xname that has the MAC address
func (s *SMDClient) IDfromMAC(mac string) (string, error) {
endpointData := new(sm.ComponentEndpointArray)
ep := "/hsm/v2/Inventory/ComponentEndpoints/"
endpointData := new(CompEthInterfaceV2Array)
ep := "/hsm/v2/Inventory/EthernetInterfaces/"
s.getSMD(ep, endpointData)

for _, ep := range endpointData.ComponentEndpoints {
id := ep.ID
nics := ep.RedfishSystemInfo.EthNICInfo
for _, v := range nics {
if strings.EqualFold(mac, v.MACAddress) {
return id, nil
}
for _, ep := range endpointData.Array {
if strings.EqualFold(mac, ep.MACAddr) {
return ep.CompID, nil
}
}
return "", errors.New("MAC " + mac + " not found for an xname in ComponentEndpoints")
return "", errors.New("MAC " + mac + " not found for an xname in EthernetInterfaces")
}

// GroupMembership returns the group labels for the xname with the given ID
Expand Down

0 comments on commit 19d0ce6

Please sign in to comment.