Symptom data collection 56/5756/1
authorAbukar Mohamed <abukar.mohamed@nokia.com>
Thu, 11 Mar 2021 12:59:02 +0000 (12:59 +0000)
committerAbukar Mohamed <abukar.mohamed@nokia.com>
Fri, 12 Mar 2021 07:00:22 +0000 (07:00 +0000)
Change-Id: Idde3b26e046610f4df4107b2c37f0a21c1f66832
Signed-off-by: Abukar Mohamed <abukar.mohamed@nokia.com>
pkg/restful/restful.go

index 86f2cf0..c911895 100755 (executable)
@@ -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)
+}