-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(supermicro): Reset Intrusion Alert if alerting
- Loading branch information
1 parent
06312b0
commit 95992ee
Showing
7 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package actions | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/g-portal/redfish_exporter/pkg/api" | ||
"github.com/g-portal/redfish_exporter/pkg/config" | ||
) | ||
|
||
const ( | ||
ResetIntrusionAlert config.Action = "reset_intrusion_alert" | ||
) | ||
|
||
func Execute(action config.Action, client api.Client) error { | ||
switch action { | ||
case ResetIntrusionAlert: | ||
err := client.ResetChassisIntrusion() | ||
if err != nil { | ||
return fmt.Errorf("error resetting chassis intrusion: %w", err) | ||
} | ||
|
||
return nil | ||
default: | ||
//nolint: err113 | ||
return fmt.Errorf("unknown action %s", action) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package redfish | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/stmcginnis/gofish/redfish" | ||
) | ||
|
||
func (rf *Redfish) ResetChassisIntrusion() error { | ||
chassisCollection, err := rf.client.Service.Chassis() | ||
if err != nil { | ||
return fmt.Errorf("error getting chassis: %w", err) | ||
} | ||
|
||
for _, chassis := range chassisCollection { | ||
if chassis.PhysicalSecurity.IntrusionSensor == redfish.HardwareIntrusionIntrusionSensor { | ||
if err = chassis.Patch(chassis.ODataID, map[string]interface{}{ | ||
"PhysicalSecurity": map[string]interface{}{ | ||
"IntrusionSensor": redfish.NormalIntrusionSensor, | ||
}, | ||
}); err != nil { | ||
return fmt.Errorf("error updating chassis: %w", err) | ||
} | ||
} | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters