From e9bc54cac2094da80c0ab8b083ee87fe5d3297ad Mon Sep 17 00:00:00 2001 From: kavyamani596 <101591350+kavyamani596@users.noreply.github.com> Date: Thu, 16 Feb 2023 13:28:51 +0530 Subject: [PATCH 1/2] dell xr11 bug --- plugin-dell/dphandler/update.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugin-dell/dphandler/update.go b/plugin-dell/dphandler/update.go index b6fa1eb5a..117d8c4de 100644 --- a/plugin-dell/dphandler/update.go +++ b/plugin-dell/dphandler/update.go @@ -57,7 +57,9 @@ func SimpleUpdate(ctx iris.Context) { uri = strings.Replace(uri, key, value, -1) reqData = strings.Replace(string(deviceDetails.PostBody), key, value, -1) } - + //removing targets from req payload + reqArr := strings.Split(reqData, ",") + reqData = reqArr[0] + "}" device := &dputilities.RedfishDevice{ Host: deviceDetails.Host, Username: deviceDetails.Username, From 854229fef5cd3a7ba93c5797dc73fd3ca76cb735 Mon Sep 17 00:00:00 2001 From: kavyamani596 <101591350+kavyamani596@users.noreply.github.com> Date: Thu, 16 Feb 2023 19:01:24 +0530 Subject: [PATCH 2/2] removal targets --- plugin-dell/dphandler/update.go | 37 ++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/plugin-dell/dphandler/update.go b/plugin-dell/dphandler/update.go index 117d8c4de..32d734b8d 100644 --- a/plugin-dell/dphandler/update.go +++ b/plugin-dell/dphandler/update.go @@ -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 @@ -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) @@ -50,16 +63,26 @@ 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 { uri = strings.Replace(uri, key, value, -1) reqData = strings.Replace(string(deviceDetails.PostBody), key, value, -1) } - //removing targets from req payload - reqArr := strings.Split(reqData, ",") - reqData = reqArr[0] + "}" + device := &dputilities.RedfishDevice{ Host: deviceDetails.Host, Username: deviceDetails.Username,