From: Abukar Mohamed Date: Thu, 11 Mar 2021 12:59:02 +0000 (+0000) Subject: Symptom data collection X-Git-Tag: 0.5.3~5 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=21fd77f34ed1dac834bc5822696f104abffd481f;p=ric-plt%2Fappmgr.git Symptom data collection Change-Id: Idde3b26e046610f4df4107b2c37f0a21c1f66832 Signed-off-by: Abukar Mohamed --- diff --git a/pkg/restful/restful.go b/pkg/restful/restful.go index 86f2cf0..c911895 100755 --- a/pkg/restful/restful.go +++ b/pkg/restful/restful.go @@ -23,7 +23,6 @@ import ( "encoding/json" "errors" "fmt" - //"io/ioutil" "log" "net/http" "os" @@ -76,6 +75,7 @@ func (r *Restful) Run() { appmgr.Logger.Info("Xapp manager started ... serving on %s:%d\n", server.Host, server.Port) + go r.symptomdataServer() go r.RetrieveApps() if err := server.Serve(); err != nil { log.Fatal(err.Error()) @@ -427,3 +427,26 @@ func (r *Restful) getAppConfig() (configList models.AllXappConfig) { } return } + +func (r *Restful) symptomdataServer() { + http.HandleFunc("/ric/v1/symptomdata", func(w http.ResponseWriter, req *http.Request) { + d, _ := r.GetApps() + xappData := struct { + XappList models.AllDeployedXapps `json:"xappList"` + ConfigList models.AllXappConfig `json:"configList"` + SubscriptionList models.AllSubscriptions `json:"subscriptionList"` + }{ + d, + r.getAppConfig(), + r.rh.GetAllSubscriptions(), + } + + w.Header().Set("Content-Type", "application/json") + w.Header().Set("Content-Disposition", "attachment; filename=platform/apps_info.json") + w.WriteHeader(http.StatusOK) + resp, _ := json.MarshalIndent(xappData, "", " ") + w.Write(resp) + }) + + http.ListenAndServe(":8081", nil) +}