Skip to content

Commit

Permalink
outofband: host required to be powered off based on task parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
joelrebel committed Oct 23, 2023
1 parent cc7c706 commit 33d1de8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions internal/outofband/action_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ var (
ErrInstalledFirmwareEqual = errors.New("installed and expected firmware equal")
ErrInstalledVersionUnknown = errors.New("installed version unknown")
ErrComponentNotFound = errors.New("component not found for firmware install")
ErrRequireHostPoweredOff = errors.New("expected host to be powered off")
)

// actionHandler implements the actionTransitionHandler methods
Expand Down Expand Up @@ -99,7 +100,7 @@ func sleepWithContext(ctx context.Context, t time.Duration) error {
}
}

func (h *actionHandler) conditionPowerOnDevice(_ *model.Action, tctx *sm.HandlerContext) (bool, error) {
func (h *actionHandler) hostPoweredOff(_ *model.Action, tctx *sm.HandlerContext) (bool, error) {
// init out of band device queryor - if one isn't already initialized
// this is done conditionally to enable tests to pass in a device queryor
if tctx.DeviceQueryor == nil {
Expand Down Expand Up @@ -129,12 +130,16 @@ func (h *actionHandler) powerOnDevice(a sw.StateSwitch, c sw.TransitionArgs) err
return err
}

powerOnRequired, err := h.conditionPowerOnDevice(action, tctx)
hostPoweredOff, err := h.hostPoweredOff(action, tctx)
if err != nil {
return err
}

if !powerOnRequired {
if !hostPoweredOff {
if tctx.Task.Parameters.RequireHostPoweredOff {
return ErrRequireHostPoweredOff
}

return nil
}

Expand Down

0 comments on commit 33d1de8

Please sign in to comment.