Skip to content

Commit

Permalink
internal/install: fix install cli command for recent runner changes
Browse files Browse the repository at this point in the history
This was broken because of changes to the way the firwmare install is
planned.
  • Loading branch information
joelrebel committed Apr 30, 2024
1 parent ca5af94 commit db2e212
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
17 changes: 11 additions & 6 deletions internal/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,22 @@ func (i *Installer) Install(ctx context.Context, params *Params) {
taskParams := &rctypes.FirmwareInstallTaskParameters{
ForceInstall: params.Force,
DryRun: params.DryRun,
Firmwares: []rctypes.Firmware{
{
Component: params.Component,
Version: params.Version,
Models: []string{params.Model},
Vendor: params.Vendor,
},
},
}

task, err := model.NewTask(uuid.New(), taskParams)
if err != nil {
i.logger.Fatal(err)
}

task.Parameters.DryRun = params.DryRun
task.Asset = &model.Asset{
BmcAddress: net.ParseIP(params.BmcAddr),
BmcUsername: params.User,
Expand All @@ -75,12 +84,8 @@ func (i *Installer) Install(ctx context.Context, params *Params) {

func (i *Installer) runTask(ctx context.Context, params *Params, task *model.Task, le *logrus.Entry) {
h := &handler{
fwFile: params.File,
fwComponent: params.Component,
fwVersion: params.Version,
model: params.Model,
vendor: params.Vendor,
onlyPlan: params.OnlyPlan,
fwFile: params.File,
onlyPlan: params.OnlyPlan,
taskCtx: &runner.TaskHandlerContext{
Task: task,
Publisher: nil,
Expand Down
24 changes: 11 additions & 13 deletions internal/install/task_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,9 @@ var (
//
// The handler is instantiated to run a single task
type handler struct {
taskCtx *runner.TaskHandlerContext
fwFile string
fwComponent string
fwVersion string
model string
vendor string
onlyPlan bool
taskCtx *runner.TaskHandlerContext
fwFile string
onlyPlan bool
}

func (t *handler) Initialize(ctx context.Context) error {
Expand Down Expand Up @@ -66,11 +62,13 @@ func (t *handler) Query(ctx context.Context) error {
func (t *handler) PlanActions(ctx context.Context) error {
t.taskCtx.Logger.Debug("create the plan")

param := t.taskCtx.Task.Parameters.Firmwares[0]

firmware := &model.Firmware{
Component: t.fwComponent,
Version: t.fwVersion,
Models: []string{t.model},
Vendor: t.vendor,
Component: param.Component,
Vendor: param.Vendor,
Models: []string{param.Vendor},
Version: param.Version,
}

actionCtx := &runner.ActionHandlerContext{
Expand All @@ -85,8 +83,8 @@ func (t *handler) PlanActions(ctx context.Context) error {
if err != nil {
return err
}
// Setting this causes the action SM to not download the file
// FirmwareTempFile: t.fwFile,\

action.FirmwareTempFile = t.fwFile

//nolint:errcheck // SetState never returns an error
action.SetState(model.StatePending)
Expand Down

0 comments on commit db2e212

Please sign in to comment.