Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DellXR11 issue with SimpleUpdate #1133

Merged
merged 4 commits into from
Feb 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 29 additions & 4 deletions plugin-dell/dphandler/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,28 @@
package dphandler

import (
"encoding/json"
"io/ioutil"
"net/http"
"strings"

pluginConfig "github.com/ODIM-Project/ODIM/plugin-dell/config"
"github.com/ODIM-Project/ODIM/plugin-dell/dpmodel"
"github.com/ODIM-Project/ODIM/plugin-dell/dputilities"
iris "github.com/kataras/iris/v12"
log "github.com/sirupsen/logrus"
"io/ioutil"
"net/http"
"strings"
)

// SimpleUpdatePostBody struct defines the received request body for update action
type SimpleUpdatePostBody struct {
ImageURI string `json:"ImageURI"`
Password string `json:"Password,omitempty"`
Targets []string `json:"Targets,omitempty"`
TransferProtocol string `json:"TransferProtocol,omitempty"`
Username string `json:"Username,omitempty"`
RedfishOperationApplyTime string `json:"@Redfish.OperationApplyTime,omitempty"`
}

// SimpleUpdate updates the BMC resources
func SimpleUpdate(ctx iris.Context) {
//Get token from Request
Expand All @@ -41,6 +53,7 @@ func SimpleUpdate(ctx iris.Context) {
}
}
var deviceDetails dpmodel.Device
reqPostBody := &SimpleUpdatePostBody{}
uri := ctx.Request().RequestURI
//Get device details from request
err := ctx.ReadJSON(&deviceDetails)
Expand All @@ -50,7 +63,19 @@ func SimpleUpdate(ctx iris.Context) {
ctx.WriteString("Error: bad request.")
return
}

err = json.Unmarshal(deviceDetails.PostBody,reqPostBody)
if err!= nil{
errMsg := "While trying to unmarshal request body, got:" + err.Error()
log.Error(errMsg)
return
}
reqPostBody.Targets = nil
deviceDetails.PostBody,err = json.Marshal(reqPostBody)
if err!= nil{
errMsg := "While trying to marshal request body, got:" + err.Error()
log.Error(errMsg)
return
}
var reqData string
//replacing the request url with south bound translation URL
for key, value := range pluginConfig.Data.URLTranslation.SouthBoundURL {
Expand Down