Skip to content

Commit

Permalink
Turn off machine LED on machine free. (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit91 authored Nov 18, 2021
1 parent 0873d61 commit 379c3ca
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions cmd/metal-api/internal/service/machine-service.go
Original file line number Diff line number Diff line change
Expand Up @@ -1653,6 +1653,11 @@ func (r machineResource) freeMachine(request *restful.Request, response *restful
}
logger := utils.Logger(request).Sugar()

err = publishMachineCmd(logger, m, r.Publisher, metal.ChassisIdentifyLEDOffCmd)
if err != nil {
logger.Error("unable to publish machine command", zap.String("command", string(metal.ChassisIdentifyLEDOffCmd)), zap.String("machineID", m.ID), zap.Error(err))
}

err = r.actor.freeMachine(r.Publisher, m)
if checkError(request, response, utils.CurrentFuncName(), err) {
return
Expand Down
4 changes: 2 additions & 2 deletions cmd/metal-api/internal/service/machine-service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,12 +557,12 @@ func TestFreeMachine(t *testing.T) {
testdata.InitMockDBData(mock)

pub := &emptyPublisher{}
events := []string{"1-machine", "releaseMachineNetworks", "1-switch"}
events := []string{"1-machine", "1-machine", "releaseMachineNetworks", "1-switch"}
eventidx := 0
pub.doPublish = func(topic string, data interface{}) error {
require.Equal(t, events[eventidx], topic)
eventidx++
if eventidx == 1 {
if eventidx == 2 {
dv := data.(metal.MachineEvent)
require.Equal(t, "1", dv.OldMachineID)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/v1/supwd.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/api/v1/wait.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 379c3ca

Please sign in to comment.