Skip to content

Commit

Permalink
Merge pull request #112 from Cray-HPE/CASMHMS-5951
Browse files Browse the repository at this point in the history
Add RTS management switch discovery
  • Loading branch information
alvarez3-hpe authored May 8, 2023
2 parents 407ffef + f50716b commit 4af8fe0
Show file tree
Hide file tree
Showing 10 changed files with 329 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7.0
2.8.0
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.8.0] - 2023-05-03

### Added

- Added RTS management switch discovery

### Changed

- Reduced verbosity of V2 readiness/liveness requests in HSM logs.

## [2.7.0] - 2023-04-12

### Fixed
Expand Down
117 changes: 117 additions & 0 deletions api/swagger_v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1419,6 +1419,9 @@ paths:
- NodeEnclosure
- NodeEnclosurePowerSupply
- HSNBoard
- MgmtSwitch
- MgmtHLSwitch
- CDUMgmtSwitch
- Node
- Processor
- Drive
Expand Down Expand Up @@ -7015,6 +7018,30 @@ definitions:
$ref: '#/definitions/HWInvByLocHSNBoard'
readOnly: true
type: array
MgmtSwitches:
description: >-
All appropriate components with HMS type 'MgmtSwitch' given
Target component/partition and query type.
items:
$ref: '#/definitions/HWInvByLocMgmtSwitch'
readOnly: true
type: array
MgmtHLSwitches:
description: >-
All appropriate components with HMS type 'MgmtHLSwitch' given
Target component/partition and query type.
items:
$ref: '#/definitions/HWInvByLocMgmtHLSwitch'
readOnly: true
type: array
CDUMgmtSwitches:
description: >-
All appropriate components with HMS type 'CDUMgmtSwitch' given
Target component/partition and query type.
items:
$ref: '#/definitions/HWInvByLocCDUMgmtSwitch'
readOnly: true
type: array
Nodes:
description: >-
All appropriate components with HMS type 'Node' given Target
Expand Down Expand Up @@ -7168,6 +7195,9 @@ definitions:
- HWInvByLocRouterModule
- HWInvByLocNodeEnclosure
- HWInvByLocHSNBoard
- HWInvByLocMgmtSwitch
- HWInvByLocMgmtHLSwitch
- HWInvByLocCDUMgmtSwitch
- HWInvByLocNode
- HWInvByLocProcessor
- HWInvByLocNodeAccel
Expand Down Expand Up @@ -7363,6 +7393,45 @@ definitions:
HSNBoardLocationInfo:
$ref: '#/definitions/HWInventory.1.0.0_RedfishChassisLocationInfo'
type: object
HWInvByLocMgmtSwitch:
description: >-
This is a subtype of HWInventoryByLocation for HMSType MgmtSwitch.
It represents a management switch. It is selected via the
'discriminator: HWInventoryByLocationType' of HWInventoryByLocation
when HWInventoryByLocationType is 'HWInvByLocMgmtSwitch'.
allOf:
- $ref: '#/definitions/HWInventory.1.0.0_HWInventoryByLocation'
- type: object
properties:
MgmtSwitchLocationInfo:
$ref: '#/definitions/HWInventory.1.0.0_RedfishChassisLocationInfo'
type: object
HWInvByLocMgmtHLSwitch:
description: >-
This is a subtype of HWInventoryByLocation for HMSType MgmtHLSwitch.
It represents a high level management switch. It is selected via the
'discriminator: HWInventoryByLocationType' of HWInventoryByLocation
when HWInventoryByLocationType is 'HWInvByLocMgmtHLSwitch'.
allOf:
- $ref: '#/definitions/HWInventory.1.0.0_HWInventoryByLocation'
- type: object
properties:
MgmtHLSwitchLocationInfo:
$ref: '#/definitions/HWInventory.1.0.0_RedfishChassisLocationInfo'
type: object
HWInvByLocCDUMgmtSwitch:
description: >-
This is a subtype of HWInventoryByLocation for HMSType CDUMgmtSwitch.
It represents a CDU management switch. It is selected via the
'discriminator: HWInventoryByLocationType' of HWInventoryByLocation
when HWInventoryByLocationType is 'HWInvByLocCDUMgmtSwitch'.
allOf:
- $ref: '#/definitions/HWInventory.1.0.0_HWInventoryByLocation'
- type: object
properties:
CDUMgmtSwitchLocationInfo:
$ref: '#/definitions/HWInventory.1.0.0_RedfishChassisLocationInfo'
type: object
HWInvByLocNode:
description: >-
This is a subtype of HWInventoryByLocation for HMSType Node.
Expand Down Expand Up @@ -8403,6 +8472,9 @@ definitions:
- HWInvByFRURouterModule
- HWInvByFRUNodeEnclosure
- HWInvByFRUHSNBoard
- HWInvByFRUMgmtSwitch
- HWInvByFRUMgmtHLSwitch
- HWInvByFRUCDUMgmtSwitch
- HWInvByFRUNode
- HWInvByFRUProcessor
- HWInvByFRUNodeAccel
Expand Down Expand Up @@ -8518,6 +8590,45 @@ definitions:
HSNBoardFRUInfo:
$ref: '#/definitions/HWInventory.1.0.0_RedfishChassisFRUInfo'
type: object
HWInvByFRUMgmtSwitch:
description: >-
This is a subtype of HWInventoryByFRU for HMSType MgmtSwitch.
It represents a management switch. It is selected via the
'discriminator: HWInventoryByFRUType' of HWInventoryByFRU when
HWInventoryByFRUType is 'HWInvByFRUMgmtSwitch'.
allOf:
- $ref: '#/definitions/HWInventory.1.0.0_HWInventoryByFRU'
- type: object
properties:
MgmtSwitchFRUInfo:
$ref: '#/definitions/HWInventory.1.0.0_RedfishChassisFRUInfo'
type: object
HWInvByFRUMgmtHLSwitch:
description: >-
This is a subtype of HWInventoryByFRU for HMSType MgmtHLSwitch.
It represents a high level management switch. It is selected via the
'discriminator: HWInventoryByFRUType' of HWInventoryByFRU when
HWInventoryByFRUType is 'HWInvByFRUMgmtHLSwitch'.
allOf:
- $ref: '#/definitions/HWInventory.1.0.0_HWInventoryByFRU'
- type: object
properties:
MgmtHLSwitchFRUInfo:
$ref: '#/definitions/HWInventory.1.0.0_RedfishChassisFRUInfo'
type: object
HWInvByFRUCDUMgmtSwitch:
description: >-
This is a subtype of HWInventoryByFRU for HMSType CDUMgmtSwitch.
It represents a CDU management switch. It is selected via the
'discriminator: HWInventoryByFRUType' of HWInventoryByFRU when
HWInventoryByFRUType is 'HWInvByFRUCDUMgmtSwitch'.
allOf:
- $ref: '#/definitions/HWInventory.1.0.0_HWInventoryByFRU'
- type: object
properties:
CDUMgmtSwitchFRUInfo:
$ref: '#/definitions/HWInventory.1.0.0_RedfishChassisFRUInfo'
type: object
HWInvByFRUNode:
description: >-
This is a subtype of HWInventoryByFRU for HMSType Node.
Expand Down Expand Up @@ -11679,6 +11790,9 @@ definitions:
- NodeEnclosure
- NodeEnclosurePowerSupply
- HSNBoard
- MgmtSwitch
- MgmtHLSwitch
- CDUMgmtSwitch
- Node
- Processor
- Drive
Expand Down Expand Up @@ -11964,6 +12078,9 @@ parameters:
- NodeEnclosure
- NodeEnclosurePowerSupply
- HSNBoard
- MgmtSwitch
- MgmtHLSwitch
- CDUMgmtSwitch
- Node
- Processor
- Drive
Expand Down
18 changes: 18 additions & 0 deletions cmd/smd/discover.go
Original file line number Diff line number Diff line change
Expand Up @@ -945,6 +945,15 @@ func (s *SmD) DiscoverHWInvByLocChassis(chEP *rf.EpChassis) (*sm.HWInvByLoc, err
case base.HSNBoard:
hwloc.HMSHSNBoardLocationInfo = &chEP.ChassisRF.ChassisLocationInfoRF
hwloc.HWInventoryByLocationType = sm.HWInvByLocHSNBoard
case base.MgmtSwitch:
hwloc.HMSMgmtSwitchLocationInfo = &chEP.ChassisRF.ChassisLocationInfoRF
hwloc.HWInventoryByLocationType = sm.HWInvByLocMgmtSwitch
case base.MgmtHLSwitch:
hwloc.HMSMgmtHLSwitchLocationInfo = &chEP.ChassisRF.ChassisLocationInfoRF
hwloc.HWInventoryByLocationType = sm.HWInvByLocMgmtHLSwitch
case base.CDUMgmtSwitch:
hwloc.HMSCDUMgmtSwitchLocationInfo = &chEP.ChassisRF.ChassisLocationInfoRF
hwloc.HWInventoryByLocationType = sm.HWInvByLocCDUMgmtSwitch
case base.HMSTypeInvalid:
err := base.ErrHMSTypeInvalid
return nil, err
Expand Down Expand Up @@ -1390,6 +1399,15 @@ func (s *SmD) DiscoverHWInvByFRUChassis(chEP *rf.EpChassis) (*sm.HWInvByFRU, err
case base.HSNBoard:
hwfru.HMSHSNBoardFRUInfo = rfChassisFRUInfo
hwfru.HWInventoryByFRUType = sm.HWInvByFRUHSNBoard
case base.MgmtSwitch:
hwfru.HMSMgmtSwitchFRUInfo = rfChassisFRUInfo
hwfru.HWInventoryByFRUType = sm.HWInvByFRUMgmtSwitch
case base.MgmtHLSwitch:
hwfru.HMSMgmtHLSwitchFRUInfo = rfChassisFRUInfo
hwfru.HWInventoryByFRUType = sm.HWInvByFRUMgmtHLSwitch
case base.CDUMgmtSwitch:
hwfru.HMSCDUMgmtSwitchFRUInfo = rfChassisFRUInfo
hwfru.HWInventoryByFRUType = sm.HWInvByFRUCDUMgmtSwitch
case base.HMSTypeInvalid:
err := base.ErrHMSTypeInvalid
return nil, err
Expand Down
3 changes: 2 additions & 1 deletion cmd/smd/routers.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ func (s *SmD) NewRouter(routes []Route) *mux.Router {
var handler http.Handler
handler = route.HandlerFunc
if s.lgLvl >= LOG_DEBUG ||
(route.Name != "doReadyGet" && route.Name != "doLivenessGet") {
(!strings.Contains(route.Name, "doReadyGet") &&
!strings.Contains(route.Name, "doLivenessGet")) {
handler = s.Logger(handler, route.Name)
}

Expand Down
8 changes: 6 additions & 2 deletions pkg/redfish/rfcomponents.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// MIT License
//
// (C) Copyright [2019-2022] Hewlett Packard Enterprise Development LP
// (C) Copyright [2019-2023] Hewlett Packard Enterprise Development LP
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
Expand Down Expand Up @@ -415,7 +415,11 @@ func (c *EpChassis) discoverLocalPhase2() {

// Check if we have something valid to insert into the data store
hmsType := base.GetHMSType(c.ID)
if !base.IsHMSTypeContainer(hmsType) || c.Type != hmsType.String() {
if (!base.IsHMSTypeContainer(hmsType) &&
hmsType != base.MgmtSwitch &&
hmsType != base.MgmtHLSwitch &&
hmsType != base.CDUMgmtSwitch) ||
c.Type != hmsType.String() {
errlog.Printf("Error: Bad xname ID ('%s') or Type ('%s' != %s) for %s\n",
c.ID, c.Type, hmsType.String(), c.ChassisURL)
c.LastStatus = VerificationFailed
Expand Down
31 changes: 28 additions & 3 deletions pkg/redfish/rfendpoints.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// MIT License
//
// (C) Copyright [2019-2021] Hewlett Packard Enterprise Development LP
// (C) Copyright [2019-2023] Hewlett Packard Enterprise Development LP
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
Expand Down Expand Up @@ -339,7 +339,10 @@ func NewRedfishEPDescription(rep *RawRedfishEP) (*RedfishEPDescription, error) {
// Get type from ID (or hostname if ID not given). It should be a
// valid controller type.
hmsType := base.GetHMSType(ep.ID)
if base.IsHMSTypeController(hmsType) {
if base.IsHMSTypeController(hmsType) ||
hmsType == base.MgmtSwitch ||
hmsType == base.MgmtHLSwitch ||
hmsType == base.CDUMgmtSwitch {
ep.Type = hmsType.String()
} else if hmsType == base.HMSTypeInvalid {
// No type found. Not a valid xname
Expand Down Expand Up @@ -1140,7 +1143,11 @@ func (ep *RedfishEP) CheckPrePhase1() error {
return err
}
hmsType := base.GetHMSType(ep.ID)
if !base.IsHMSTypeController(hmsType) || ep.Type != hmsType.String() {
if (!base.IsHMSTypeController(hmsType) &&
hmsType != base.MgmtSwitch &&
hmsType != base.MgmtHLSwitch &&
hmsType != base.CDUMgmtSwitch) ||
ep.Type != hmsType.String() {
err := fmt.Errorf("bad xname ID ('%s') or Type ('%s') for %s\n",
ep.ID, ep.Type, ep.FQDN)
return err
Expand Down Expand Up @@ -1194,6 +1201,11 @@ func (ep *RedfishEP) getChassisHMSID(c *EpChassis, hmsType string, ordinal int)
// Invalid ordinal or initial -1 value.
return ""
}
if hmsTypeStr == base.MgmtSwitch.String() ||
hmsTypeStr == base.MgmtHLSwitch.String() ||
hmsTypeStr == base.CDUMgmtSwitch.String() {
return ep.ID
}
// If the RedfishEndpoint ID is valid, there will be a b in the xname.
epIDSplit := strings.SplitN(ep.ID, "b", 2)
if len(epIDSplit) == 1 {
Expand Down Expand Up @@ -1289,6 +1301,13 @@ func (ep *RedfishEP) getChassisHMSType(c *EpChassis) string {
}
}
return base.HMSTypeInvalid.String()
case RFSubtypeDrawer:
if ep.Type == base.MgmtSwitch.String() ||
ep.Type == base.MgmtHLSwitch.String() ||
ep.Type == base.CDUMgmtSwitch.String() {
return ep.Type
}
return base.HMSTypeInvalid.String()
default:
// Other types are usually subcomponents we don't track and are
// often not represented very consistently by different manufacturers.
Expand Down Expand Up @@ -1772,6 +1791,12 @@ func (ep *RedfishEP) getManagerHMSID(m *EpManager, hmsType string, ordinal int)
// xname (once/if the ordinal is added) per retur "unicode"ned type, given a
// particular Redfish endpoint xname and type.
func (ep *RedfishEP) getManagerHMSType(m *EpManager) string {
// Don't discover Management switch BMCs.
if ep.Type == base.MgmtSwitch.String() ||
ep.Type == base.MgmtHLSwitch.String() ||
ep.Type == base.CDUMgmtSwitch.String() {
return base.HMSTypeInvalid.String()
}
// Just one? That's this endpoint's type.
// example: RouterBMC
if ep.Managers.Num == 1 {
Expand Down
Loading

0 comments on commit 4af8fe0

Please sign in to comment.