Skip to content

Commit

Permalink
Pass ResetType to Manager.Reset (#345)
Browse files Browse the repository at this point in the history
* expose the ActionInfo property under Actions under the Managers collection

* differentiate between HPE systems and system that report SupportedResetTypes under actionsInfo
  • Loading branch information
iamsli authored May 23, 2024
1 parent e6c6d93 commit 8061ec5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions redfish/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,8 @@ type Manager struct {
modifyRedundancySetTarget string
// resetTarget is the internal URL to send reset targets to.
resetTarget string
// resetInfo contains URI for an ActionInfo Resource that describes this action.
actionInfo string
// SupportedResetTypes, if provided, is the reset types this system supports.
SupportedResetTypes []ResetType
resetToDefaultsTarget string
Expand All @@ -393,6 +395,7 @@ func (manager *Manager) UnmarshalJSON(b []byte) error {
ForceFailover common.ActionTarget `json:"#Manager.ForceFailover"`
ModifyRedundancySet common.ActionTarget `json:"#Manager.ModifyRedundancySet"`
Reset struct {
ActionInfo string `json:"@Redfish.ActionInfo"`
AllowedResetTypes []ResetType `json:"[email protected]"`
Target string
} `json:"#Manager.Reset"`
Expand Down Expand Up @@ -479,6 +482,7 @@ func (manager *Manager) UnmarshalJSON(b []byte) error {
manager.SupportedResetTypes = t.Actions.Reset.AllowedResetTypes
manager.resetTarget = t.Actions.Reset.Target
manager.resetToDefaultsTarget = t.Actions.ResetToDefaults.Target
manager.actionInfo = t.Actions.Reset.ActionInfo

// This is a read/write object, so we need to save the raw object data for later
manager.rawData = b
Expand Down Expand Up @@ -584,6 +588,14 @@ func (manager *Manager) ModifyRedundancySet(addManagers, removeManagers []*Manag
// Reset shall perform a reset of the manager.
func (manager *Manager) Reset(resetType ResetType) error {
if len(manager.SupportedResetTypes) == 0 {
if manager.actionInfo != "" {
// reset without confirming the type is supported by the manager.
// done to minimize overhead though technically not as correct as first checking the supported reset types
t := struct {
ResetType ResetType
}{ResetType: resetType}
return manager.Post(manager.resetTarget, t)
}
// reset directly without reset type. HPE server has the behavior
return manager.Post(manager.resetTarget, struct{}{})
}
Expand Down

0 comments on commit 8061ec5

Please sign in to comment.