Skip to content

Commit

Permalink
Handle SetServer request
Browse files Browse the repository at this point in the history
- Setting server URL in both /config/server and real config partition

Signed-off-by: Mikhail Malyshev <mike.malyshev@gmail.com>
  • Loading branch information
rucoder committed Oct 31, 2024
1 parent f7a9b67 commit 8fb1a58
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pkg/pillar/cmd/monitor/ipc_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (r *Request) validate() error {
return errors.New("RequestData is nil")
}
// check supported request types
if r.RequestType != "SetDPC" {
if (r.RequestType != "SetDPC") && (r.RequestType != "SetServer") {
return errors.New("Unsupported RequestType " + r.RequestType)
}
return nil
Expand Down Expand Up @@ -230,6 +230,17 @@ func (r *Request) handleRequest(ctx *monitorContext) *response {
} else {
return r.malformedRequestResponse(err)
}
case "SetServer":
var server string
if err := json.Unmarshal(r.RequestData, &server); err == nil {
if err := ctx.updateServerFile(server); err != nil {
return r.errResponse("Failed to update server file", err)
} else {
return r.okResponse()
}
} else {
return r.malformedRequestResponse(err)
}
default:
return r.unknownRequestResponse()
}
Expand Down

0 comments on commit 8fb1a58

Please sign in to comment.