From 3aeb0d181e6dc5cc70f2d005aa355bc4778b460a Mon Sep 17 00:00:00 2001 From: akshata-s-banoshi <133867635+akshata-s-banoshi@users.noreply.github.com> Date: Fri, 15 Sep 2023 13:27:52 +0530 Subject: [PATCH] fix bootorder and bios setting for Dell server (#15) Co-authored-by: akshata-s-banoshi Co-authored-by: Jeevan Kamkar <68366409+jeevan-kamkar@users.noreply.github.com> --- controllers/bmc/bmc_controller.go | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/controllers/bmc/bmc_controller.go b/controllers/bmc/bmc_controller.go index a291005..492d00f 100644 --- a/controllers/bmc/bmc_controller.go +++ b/controllers/bmc/bmc_controller.go @@ -670,13 +670,19 @@ func (bu *bmcUtils) ResetSystem(isBiosUpdation bool, updateBmcDependents bool) b biosUtil := bios.GetBiosUtils(bu.ctx, biosObj, bu.commonRec, bu.bmcRestClient, bu.namespace) biosAttribute := getUpdatedBiosAttributes(bu.ctx, biosObj.Status.BiosAttributes, bu.bmcObj, biosUtil) biosUtil.UpdateBiosAttributesOnReset(bu.bmcObj.Spec.BmcDetails.Address, biosAttribute) - sysDetails := bu.commonUtil.GetBmcSystemDetails(bu.ctx, bu.bmcObj) - if sysDetails != nil { - bootUtil := boot.GetBootUtils(bu.ctx, nil, bu.commonRec, bu.bmcRestClient, bu.commonUtil, bu.namespace) - bootAttribute := bootUtil.GetBootAttributes(sysDetails) - if bootAttribute != nil { - bootUtil.UpdateBootAttributesOnReset(bu.bmcObj.ObjectMeta.Name, bootAttribute) + bootObj := bu.commonRec.GetBootObject(bu.ctx, constants.MetadataName, bu.bmcObj.ObjectMeta.Name, bu.namespace) + oldBootAttribute := bootObj.Status.Boot + bootUtil := boot.GetBootUtils(bu.ctx, nil, bu.commonRec, bu.bmcRestClient, bu.commonUtil, bu.namespace) + for i := 0; i < 10; i++ { + sysDetails := bu.commonUtil.GetBmcSystemDetails(bu.ctx, bu.bmcObj) + if sysDetails != nil { + bootAttribute := bootUtil.GetBootAttributes(sysDetails) + if bootAttribute != nil && !reflect.DeepEqual(bootAttribute, oldBootAttribute) { + bootUtil.UpdateBootAttributesOnReset(bu.bmcObj.ObjectMeta.Name, bootAttribute) + break + } } + time.Sleep(time.Duration(constants.SleepTime) * time.Second) } if strings.Contains(bu.bmcObj.Status.SystemReset, "Volume") { strArr := strings.Split(bu.bmcObj.Status.SystemReset, " ") @@ -698,9 +704,9 @@ func (bu *bmcUtils) ResetSystem(isBiosUpdation bool, updateBmcDependents bool) b func getUpdatedBiosAttributes(ctx context.Context, oldBiosAttributes map[string]string, bmcObj *infraiov1.Bmc, biosUtil bios.BiosInterface) map[string]string { var updatedBiosAttributes map[string]string - for i := 0; i < 5; i++ { + for i := 0; i < 10; i++ { biosAttribute := biosUtil.GetBiosAttributes(bmcObj) - if !reflect.DeepEqual(biosAttribute, oldBiosAttributes) { + if biosAttribute != nil && !reflect.DeepEqual(biosAttribute, oldBiosAttributes) { updatedBiosAttributes = biosAttribute break }