From d6c813e247b21432bbc56e776eb21d6deb530570 Mon Sep 17 00:00:00 2001 From: Mikhail Malyshev Date: Tue, 29 Oct 2024 16:16:37 +0100 Subject: [PATCH] Handle SetServer request - Setting server URL in both /config/server and real config partition Signed-off-by: Mikhail Malyshev --- pkg/pillar/cmd/monitor/ipc_server.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pkg/pillar/cmd/monitor/ipc_server.go b/pkg/pillar/cmd/monitor/ipc_server.go index 4734d45556..be31712c40 100644 --- a/pkg/pillar/cmd/monitor/ipc_server.go +++ b/pkg/pillar/cmd/monitor/ipc_server.go @@ -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 @@ -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() }