Skip to content

Commit

Permalink
Checkin
Browse files Browse the repository at this point in the history
  • Loading branch information
rsjostrand-hpe committed Aug 30, 2023
1 parent 6fc7089 commit fcbacb0
Show file tree
Hide file tree
Showing 50 changed files with 666 additions and 638 deletions.
2 changes: 1 addition & 1 deletion cmd/smd-loader/smd-loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"net/http"
"os"
"os/signal"
"github.com/Cray-HPE/hms-base"
"github.com/Cray-HPE/hms-base/v2"
hmshttp "github.com/Cray-HPE/hms-go-http-lib"
"syscall"
"time"
Expand Down
27 changes: 14 additions & 13 deletions cmd/smd/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ import (
"fmt"
"strconv"

base "github.com/Cray-HPE/hms-base"
base "github.com/Cray-HPE/hms-base/v2"
"github.com/Cray-HPE/hms-xname/xnametypes"
"github.com/Cray-HPE/hms-smd/v2/internal/hmsds"
rf "github.com/Cray-HPE/hms-smd/v2/pkg/redfish"
)
Expand Down Expand Up @@ -99,16 +100,16 @@ func (s *SmD) DiscoverComponentChassis(chEP *rf.EpChassis) *base.Component {
comp.Class = chEP.DefaultClass

if comp.Class == "" {
if comp.Type == base.Chassis.String() {
if comp.Type == xnametypes.Chassis.String() {
comp.Class = base.ClassMountain.String()
// Just incase our redfish endpoint didn't exist when our child
// components were discovered, update them to be Mountain too.
f := hmsds.ComponentFilter{
Type: []string{
base.NodeBMC.String(),
base.NodeEnclosure.String(),
base.Node.String(),
base.RouterBMC.String(),
xnametypes.NodeBMC.String(),
xnametypes.NodeEnclosure.String(),
xnametypes.Node.String(),
xnametypes.RouterBMC.String(),
},
}
children, err := s.db.GetComponentsQuery(&f, hmsds.FLTR_ID_ONLY, []string{comp.ID})
Expand All @@ -131,12 +132,12 @@ func (s *SmD) DiscoverComponentChassis(chEP *rf.EpChassis) *base.Component {
// Chassis first then go down a level to the chassisBMC
p := comp.ID
for {
p = base.GetHMSCompParent(p)
p = xnametypes.GetHMSCompParent(p)
if p == "" {
s.LogAlways("DiscoverComponentChassis: Could not determine ChassisBMC ID for %s", comp.ID)
break
}
if base.GetHMSType(p) != base.Chassis {
if xnametypes.GetHMSType(p) != xnametypes.Chassis {
continue
}
chassisBmc := p + "b0"
Expand Down Expand Up @@ -194,12 +195,12 @@ func (s *SmD) DiscoverComponentSystem(sysEP *rf.EpSystem) *base.Component {
// Chassis first then go down a level to the chassisBMC
p := comp.ID
for {
p = base.GetHMSCompParent(p)
p = xnametypes.GetHMSCompParent(p)
if p == "" {
s.LogAlways("DiscoverComponentChassis: Could not determine ChassisBMC ID for %s", comp.ID)
break
}
if base.GetHMSType(p) != base.Chassis {
if xnametypes.GetHMSType(p) != xnametypes.Chassis {
continue
}
chassisBmc := p + "b0"
Expand Down Expand Up @@ -246,19 +247,19 @@ func (s *SmD) DiscoverComponentManager(mEP *rf.EpManager) *base.Component {
comp.Class = mEP.DefaultClass

if comp.Class == "" {
if comp.Type == base.ChassisBMC.String() {
if comp.Type == xnametypes.ChassisBMC.String() {
comp.Class = base.ClassMountain.String()
} else {
// Get the ID for the parent Chassis BMC. Need to find the
// Chassis first then go down a level to the chassisBMC
p := comp.ID
for {
p = base.GetHMSCompParent(p)
p = xnametypes.GetHMSCompParent(p)
if p == "" {
s.LogAlways("DiscoverComponentChassis: Could not determine ChassisBMC ID for %s", comp.ID)
break
}
if base.GetHMSType(p) != base.Chassis {
if xnametypes.GetHMSType(p) != xnametypes.Chassis {
continue
}
chassisBmc := p + "b0"
Expand Down
81 changes: 41 additions & 40 deletions cmd/smd/discover.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ import (
"strings"
"sync"

base "github.com/Cray-HPE/hms-base"
base "github.com/Cray-HPE/hms-base/v2"
"github.com/Cray-HPE/hms-xname/xnametypes"
compcreds "github.com/Cray-HPE/hms-compcredentials"
rf "github.com/Cray-HPE/hms-smd/v2/pkg/redfish"
"github.com/Cray-HPE/hms-smd/v2/pkg/sm"
Expand Down Expand Up @@ -56,7 +57,7 @@ func (s *SmD) discoverFromEndpoints(eps []*sm.RedfishEndpoint, id uint, update,
ep.ID)
continue
}
idsFiltered = append(idsFiltered, base.VerifyNormalizeCompID(ep.ID))
idsFiltered = append(idsFiltered, xnametypes.VerifyNormalizeCompID(ep.ID))
}
// This should not fail in practice unless eps have not been inserted yet
// This will "lock" the LastStatus to in-progress so it can't be started
Expand Down Expand Up @@ -316,7 +317,7 @@ func (s *SmD) updateFromRfEndpoint(rfEP *rf.RedfishEP) error {
compMap := make(map[string]*base.Component)
compList := make([]string, 0, 1)
for _, comp := range comps.Components {
if comp.Type == base.Node.String() && comp.State == base.StateOn.String() {
if comp.Type == xnametypes.Node.String() && comp.State == base.StateOn.String() {
compMap[comp.ID] = comp
compList = append(compList, comp.ID)
}
Expand Down Expand Up @@ -640,7 +641,7 @@ func (s *SmD) DiscoverHWInvByLocArray(rfEP *rf.RedfishEP) ([]*sm.HWInvByLoc, err
}
hwlocs = append(hwlocs, hwloc)
for _, powerSupplyEP := range chEP.PowerSupplies.OIDs {
if powerSupplyEP.Type == base.CMMRectifier.String() {
if powerSupplyEP.Type == xnametypes.CMMRectifier.String() {
hwloc, err := s.DiscoverHWInvByLocCMMRectifier(powerSupplyEP)
if err != nil {
if err == base.ErrHMSTypeInvalid || err == base.ErrHMSTypeUnsupported {
Expand All @@ -652,7 +653,7 @@ func (s *SmD) DiscoverHWInvByLocArray(rfEP *rf.RedfishEP) ([]*sm.HWInvByLoc, err
return nil, err
}
hwlocs = append(hwlocs, hwloc)
} else if powerSupplyEP.Type == base.NodeEnclosurePowerSupply.String() {
} else if powerSupplyEP.Type == xnametypes.NodeEnclosurePowerSupply.String() {
hwloc, err := s.DiscoverHWInvByLocNodeEnclosurePowerSupply(powerSupplyEP)
if err != nil {
if err == base.ErrHMSTypeInvalid || err == base.ErrHMSTypeUnsupported {
Expand Down Expand Up @@ -752,7 +753,7 @@ func (s *SmD) DiscoverHWInvByLocArray(rfEP *rf.RedfishEP) ([]*sm.HWInvByLoc, err
hwlocs = append(hwlocs, hwloc)
}
for _, nodeAccelRiserEP := range sysEP.NodeAccelRisers.OIDs {
if nodeAccelRiserEP.Type == base.NodeAccelRiser.String() {
if nodeAccelRiserEP.Type == xnametypes.NodeAccelRiser.String() {
hwloc, err := s.DiscoverHWInvByLocNodeAccelRiser(nodeAccelRiserEP)
if err != nil {
if err == base.ErrHMSTypeInvalid || err == base.ErrHMSTypeUnsupported {
Expand All @@ -767,7 +768,7 @@ func (s *SmD) DiscoverHWInvByLocArray(rfEP *rf.RedfishEP) ([]*sm.HWInvByLoc, err
}
}
for _, networkAdapterEP := range sysEP.NetworkAdapters.OIDs {
if networkAdapterEP.Type == base.NodeHsnNic.String() {
if networkAdapterEP.Type == xnametypes.NodeHsnNic.String() {
hwloc, err := s.DiscoverHWInvByLocNodeHsnNic(networkAdapterEP)
if err != nil {
if err == base.ErrHMSTypeInvalid || err == base.ErrHMSTypeUnsupported {
Expand Down Expand Up @@ -813,7 +814,7 @@ func (s *SmD) DiscoverHWInvByLocArray(rfEP *rf.RedfishEP) ([]*sm.HWInvByLoc, err

// Managers from Redfish "Manager" objects
for _, managerEP := range rfEP.Managers.OIDs {
if managerEP.Type == base.NodeBMC.String() {
if managerEP.Type == xnametypes.NodeBMC.String() {
hwloc, err := s.DiscoverHWInvByLocNodeBMC(managerEP)
if err != nil {
if err == base.ErrHMSTypeInvalid || err == base.ErrHMSTypeUnsupported {
Expand All @@ -826,7 +827,7 @@ func (s *SmD) DiscoverHWInvByLocArray(rfEP *rf.RedfishEP) ([]*sm.HWInvByLoc, err
}
hwlocs = append(hwlocs, hwloc)
}
if managerEP.Type == base.RouterBMC.String() {
if managerEP.Type == xnametypes.RouterBMC.String() {
hwloc, err := s.DiscoverHWInvByLocRouterBMC(managerEP)
if err != nil {
if err == base.ErrHMSTypeInvalid || err == base.ErrHMSTypeUnsupported {
Expand Down Expand Up @@ -926,35 +927,35 @@ func (s *SmD) DiscoverHWInvByLocChassis(chEP *rf.EpChassis) (*sm.HWInvByLoc, err
hwloc.PopulatedFRU = hwfru
}
//rfChassisLocationInfo := &chEP.ChassisRF.ChassisLocationInfoRF
switch base.ToHMSType(hwloc.Type) {
case base.Cabinet:
switch xnametypes.ToHMSType(hwloc.Type) {
case xnametypes.Cabinet:
hwloc.HMSCabinetLocationInfo = &chEP.ChassisRF.ChassisLocationInfoRF
hwloc.HWInventoryByLocationType = sm.HWInvByLocCabinet
case base.Chassis:
case xnametypes.Chassis:
hwloc.HMSChassisLocationInfo = &chEP.ChassisRF.ChassisLocationInfoRF
hwloc.HWInventoryByLocationType = sm.HWInvByLocChassis
case base.ComputeModule:
case xnametypes.ComputeModule:
hwloc.HMSComputeModuleLocationInfo = &chEP.ChassisRF.ChassisLocationInfoRF
hwloc.HWInventoryByLocationType = sm.HWInvByLocComputeModule
case base.RouterModule:
case xnametypes.RouterModule:
hwloc.HMSRouterModuleLocationInfo = &chEP.ChassisRF.ChassisLocationInfoRF
hwloc.HWInventoryByLocationType = sm.HWInvByLocRouterModule
case base.NodeEnclosure:
case xnametypes.NodeEnclosure:
hwloc.HMSNodeEnclosureLocationInfo = &chEP.ChassisRF.ChassisLocationInfoRF
hwloc.HWInventoryByLocationType = sm.HWInvByLocNodeEnclosure
case base.HSNBoard:
case xnametypes.HSNBoard:
hwloc.HMSHSNBoardLocationInfo = &chEP.ChassisRF.ChassisLocationInfoRF
hwloc.HWInventoryByLocationType = sm.HWInvByLocHSNBoard
case base.MgmtSwitch:
case xnametypes.MgmtSwitch:
hwloc.HMSMgmtSwitchLocationInfo = &chEP.ChassisRF.ChassisLocationInfoRF
hwloc.HWInventoryByLocationType = sm.HWInvByLocMgmtSwitch
case base.MgmtHLSwitch:
case xnametypes.MgmtHLSwitch:
hwloc.HMSMgmtHLSwitchLocationInfo = &chEP.ChassisRF.ChassisLocationInfoRF
hwloc.HWInventoryByLocationType = sm.HWInvByLocMgmtHLSwitch
case base.CDUMgmtSwitch:
case xnametypes.CDUMgmtSwitch:
hwloc.HMSCDUMgmtSwitchLocationInfo = &chEP.ChassisRF.ChassisLocationInfoRF
hwloc.HWInventoryByLocationType = sm.HWInvByLocCDUMgmtSwitch
case base.HMSTypeInvalid:
case xnametypes.HMSTypeInvalid:
err := base.ErrHMSTypeInvalid
return nil, err
default:
Expand Down Expand Up @@ -1015,24 +1016,24 @@ func (s *SmD) DiscoverHWInvByLocHpeDevice(hpeDeviceEP *rf.EpHpeDevice) (*sm.HWIn
}
hwloc.PopulatedFRU = hwfru
}
switch base.ToHMSType(hwloc.Type) {
case base.NodeAccel:
switch xnametypes.ToHMSType(hwloc.Type) {
case xnametypes.NodeAccel:
accelInfo := rf.ProcessorLocationInfoRF{
Id: hpeDeviceEP.DeviceRF.Id,
Name: hpeDeviceEP.DeviceRF.Name,
Description: hpeDeviceEP.DeviceRF.Location,
}
hwloc.HMSNodeAccelLocationInfo = &accelInfo
hwloc.HWInventoryByLocationType = sm.HWInvByLocNodeAccel
case base.NodeHsnNic:
case xnametypes.NodeHsnNic:
nicInfo := rf.NALocationInfoRF{
Id: hpeDeviceEP.DeviceRF.Id,
Name: hpeDeviceEP.DeviceRF.Name,
Description: hpeDeviceEP.DeviceRF.Location,
}
hwloc.HMSHSNNICLocationInfo = &nicInfo
hwloc.HWInventoryByLocationType = sm.HWInvByLocHSNNIC
case base.HMSTypeInvalid:
case xnametypes.HMSTypeInvalid:
err := base.ErrHMSTypeInvalid
return nil, err
default:
Expand Down Expand Up @@ -1380,35 +1381,35 @@ func (s *SmD) DiscoverHWInvByFRUChassis(chEP *rf.EpChassis) (*sm.HWInvByFRU, err
hwfru.Subtype = chEP.Subtype

rfChassisFRUInfo := &chEP.ChassisRF.ChassisFRUInfoRF
switch base.ToHMSType(hwfru.Type) {
case base.Cabinet:
switch xnametypes.ToHMSType(hwfru.Type) {
case xnametypes.Cabinet:
hwfru.HMSCabinetFRUInfo = rfChassisFRUInfo
hwfru.HWInventoryByFRUType = sm.HWInvByFRUCabinet
case base.Chassis:
case xnametypes.Chassis:
hwfru.HMSChassisFRUInfo = rfChassisFRUInfo
hwfru.HWInventoryByFRUType = sm.HWInvByFRUChassis
case base.ComputeModule:
case xnametypes.ComputeModule:
hwfru.HMSComputeModuleFRUInfo = rfChassisFRUInfo
hwfru.HWInventoryByFRUType = sm.HWInvByFRUComputeModule
case base.RouterModule:
case xnametypes.RouterModule:
hwfru.HMSRouterModuleFRUInfo = rfChassisFRUInfo
hwfru.HWInventoryByFRUType = sm.HWInvByFRURouterModule
case base.NodeEnclosure:
case xnametypes.NodeEnclosure:
hwfru.HMSNodeEnclosureFRUInfo = rfChassisFRUInfo
hwfru.HWInventoryByFRUType = sm.HWInvByFRUNodeEnclosure
case base.HSNBoard:
case xnametypes.HSNBoard:
hwfru.HMSHSNBoardFRUInfo = rfChassisFRUInfo
hwfru.HWInventoryByFRUType = sm.HWInvByFRUHSNBoard
case base.MgmtSwitch:
case xnametypes.MgmtSwitch:
hwfru.HMSMgmtSwitchFRUInfo = rfChassisFRUInfo
hwfru.HWInventoryByFRUType = sm.HWInvByFRUMgmtSwitch
case base.MgmtHLSwitch:
case xnametypes.MgmtHLSwitch:
hwfru.HMSMgmtHLSwitchFRUInfo = rfChassisFRUInfo
hwfru.HWInventoryByFRUType = sm.HWInvByFRUMgmtHLSwitch
case base.CDUMgmtSwitch:
case xnametypes.CDUMgmtSwitch:
hwfru.HMSCDUMgmtSwitchFRUInfo = rfChassisFRUInfo
hwfru.HWInventoryByFRUType = sm.HWInvByFRUCDUMgmtSwitch
case base.HMSTypeInvalid:
case xnametypes.HMSTypeInvalid:
err := base.ErrHMSTypeInvalid
return nil, err
default:
Expand Down Expand Up @@ -1464,8 +1465,8 @@ func (s *SmD) DiscoverHWInvByFRUHpeDevice(hpeDeviceEP *rf.EpHpeDevice) (*sm.HWIn
hwfru.Type = hpeDeviceEP.Type
hwfru.Subtype = hpeDeviceEP.Subtype

switch base.ToHMSType(hwfru.Type) {
case base.NodeAccel:
switch xnametypes.ToHMSType(hwfru.Type) {
case xnametypes.NodeAccel:
accelInfo := rf.ProcessorFRUInfoRF{
Manufacturer: hpeDeviceEP.DeviceRF.Manufacturer,
Model: hpeDeviceEP.DeviceRF.Model,
Expand All @@ -1475,7 +1476,7 @@ func (s *SmD) DiscoverHWInvByFRUHpeDevice(hpeDeviceEP *rf.EpHpeDevice) (*sm.HWIn
}
hwfru.HMSNodeAccelFRUInfo = &accelInfo
hwfru.HWInventoryByFRUType = sm.HWInvByFRUNodeAccel
case base.NodeHsnNic:
case xnametypes.NodeHsnNic:
nicInfo := rf.NAFRUInfoRF{
Manufacturer: hpeDeviceEP.DeviceRF.Manufacturer,
Model: hpeDeviceEP.DeviceRF.Model,
Expand All @@ -1484,7 +1485,7 @@ func (s *SmD) DiscoverHWInvByFRUHpeDevice(hpeDeviceEP *rf.EpHpeDevice) (*sm.HWIn
}
hwfru.HMSHSNNICFRUInfo = &nicInfo
hwfru.HWInventoryByFRUType = sm.HWInvByFRUHSNNIC
case base.HMSTypeInvalid:
case xnametypes.HMSTypeInvalid:
err := base.ErrHMSTypeInvalid
return nil, err
default:
Expand Down Expand Up @@ -1515,7 +1516,7 @@ func (s *SmD) DiscoverHWInvByFRUProcessor(procEP *rf.EpProcessor) (*sm.HWInvByFR
hwfru.Type = procEP.Type
hwfru.Subtype = procEP.Subtype

if procEP.Type == base.NodeAccel.String() {
if procEP.Type == xnametypes.NodeAccel.String() {
hwfru.HMSNodeAccelFRUInfo = &procEP.ProcessorRF.ProcessorFRUInfoRF
hwfru.HWInventoryByFRUType = sm.HWInvByFRUNodeAccel
} else {
Expand Down
2 changes: 1 addition & 1 deletion cmd/smd/hmsdsmock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ package main
import (
"log"

base "github.com/Cray-HPE/hms-base"
base "github.com/Cray-HPE/hms-base/v2"
"github.com/Cray-HPE/hms-smd/v2/internal/hmsds"
"github.com/Cray-HPE/hms-smd/v2/pkg/sm"
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/smd/job-types.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (
"sync"
"time"

base "github.com/Cray-HPE/hms-base"
base "github.com/Cray-HPE/hms-base/v2"
"github.com/Cray-HPE/hms-smd/v2/pkg/sm"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/smd/msgbus.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
package main

import (
base "github.com/Cray-HPE/hms-base"
base "github.com/Cray-HPE/hms-base/v2"
msgbus "github.com/Cray-HPE/hms-msgbus"
"strconv"
"strings"
Expand Down
2 changes: 1 addition & 1 deletion cmd/smd/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"fmt"
"net/http"

base "github.com/Cray-HPE/hms-base"
base "github.com/Cray-HPE/hms-base/v2"
"github.com/Cray-HPE/hms-smd/v2/pkg/sm"
)

Expand Down
Loading

0 comments on commit fcbacb0

Please sign in to comment.