Added debug API to request route and configuration details in routing manager 44/2444/1
authorwahidw <abdulwahid.w@nokia.com>
Fri, 7 Feb 2020 06:55:25 +0000 (06:55 +0000)
committerwahidw <abdulwahid.w@nokia.com>
Fri, 7 Feb 2020 06:55:31 +0000 (06:55 +0000)
Change-Id: Ie0ba11c38d3de7c82ac992a927075ecd51f15f9c
Signed-off-by: wahidw <abdulwahid.w@nokia.com>
RELNOTES
api/routing_manager.yaml
container-tag.yaml
pkg/nbi/httprestful.go

index e78a029..f9624b7 100644 (file)
--- a/RELNOTES
+++ b/RELNOTES
@@ -1,3 +1,6 @@
+### v0.4.12
+* Added debug API to request route and configuration details in routing manager 
+
 ### v0.4.11
 * Added code for subscription merge and added RMR from xapp-framework 
 
index c8a742b..bdf19f1 100644 (file)
@@ -1,4 +1,3 @@
-#
 #==================================================================================
 #   Copyright (c) 2019 AT&T Intellectual Property.
 #   Copyright (c) 2019 Nokia
@@ -38,6 +37,8 @@ tags:
 #    url: "http://127.0.0.1"
 - name: "health"
   description: "Health of the system"
+- name: "debug"
+  description: "Debug Information"
 schemes:
 #- "https"
 - "http"
@@ -60,6 +61,24 @@ paths:
           description: "The health of the system"
           schema:
             "$ref": "#/definitions/health-status"
+  /getdebuginfo:
+    get:
+      tags:
+      - "debug"
+      summary: "Get Information for debugging"
+      description: "By performing a GET method, API caller is able to get the dump of routes tables, subcription list and E2T's"
+      operationId: "get_debuginfo"
+      consumes:
+      - "application/json"
+      produces:
+      - "application/json"
+      responses:
+        200:
+          description: "Debug Info from routing manager"
+          schema:
+            "$ref": "#/definitions/debuginfo"
+        201:
+          description: "Error while fetching Debug data"    
   /handles:
     get:
       tags:
@@ -368,10 +387,31 @@ definitions:
         $ref: '#/definitions/ranNamelist'
       ranAssocList:
         $ref: "#/definitions/ran-e2t-map"
-          
+  endpoint:
+    type: "object"
+    properties:
+      EndPointName:
+        type: "string"
+      EndPointFqdn:
+        type: "string"
+      EndPointPort:
+        type: "integer"
+        format: "uint16"
+        minimum: 0
+        maximum: 65535
+    
+  debuginfo:
+    type: "object"
+    required:
+      - "RouteTable"
+    properties:
+      RouteTable:
+        type: "array"
+        items:
+          type: "string"
+      RouteConfigs:
+        type: "string"
 
 externalDocs:
   description: "Routing Manager"
   url: "http://placeholder"
-
-
index f8f7249..371dd3c 100644 (file)
@@ -2,4 +2,4 @@
 # By default this file is in the docker build directory,
 # but the location can configured in the JJB template.
 ---
-tag: 0.4.11
+tag: 0.4.12
index ac56aa0..c43631e 100644 (file)
@@ -44,6 +44,7 @@ import (
        "routing-manager/pkg/models"
        "routing-manager/pkg/restapi"
        "routing-manager/pkg/restapi/operations"
+       "routing-manager/pkg/restapi/operations/debug"
        "routing-manager/pkg/restapi/operations/handle"
        "routing-manager/pkg/rpe"
        "routing-manager/pkg/rtmgr"
@@ -359,6 +360,23 @@ func deleteE2tHandleHandlerImpl(e2tdelchan chan<- *models.E2tDeleteData,
        return nil
 }
 
+func dumpDebugData() (models.Debuginfo, error) {
+       var response models.Debuginfo
+       sdlEngine, _ := sdl.GetSdl("file")
+       rpeEngine, _ := rpe.GetRpe("rmrpush")
+       data, err := sdlEngine.ReadAll(xapp.Config.GetString("rtfile"))
+       if err != nil || data == nil {
+               xapp.Logger.Error("Cannot get data from sdl interface due to: " + err.Error())
+               return response, err
+       }
+       response.RouteTable = *rpeEngine.GeneratePolicies(rtmgr.Eps, data)
+
+       prettyJSON, err := json.MarshalIndent(data, "", "")
+       response.RouteConfigs = string(prettyJSON)
+
+       return response, err
+}
+
 func launchRest(nbiif *string, datach chan<- *models.XappCallbackData, subchan chan<- *models.XappSubscriptionData, subupdatechan chan<- *rtmgr.XappList,
        subdelchan chan<- *models.XappSubscriptionData, e2taddchan chan<- *models.E2tData, assranchan chan<- models.RanE2tMap, disassranchan chan<- models.RanE2tMap, e2tdelchan chan<- *models.E2tDeleteData) {
        swaggerSpec, err := loads.Embedded(restapi.SwaggerJSON, restapi.FlatSwaggerJSON)
@@ -470,6 +488,15 @@ func launchRest(nbiif *string, datach chan<- *models.XappCallbackData, subchan c
                                return handle.NewDeleteE2tHandleCreated()
                        }
                })
+       api.DebugGetDebuginfoHandler = debug.GetDebuginfoHandlerFunc(
+               func(params debug.GetDebuginfoParams) middleware.Responder {
+                       response, err := dumpDebugData()
+                       if err != nil {
+                               return debug.NewGetDebuginfoCreated()
+                       } else {
+                               return debug.NewGetDebuginfoOK().WithPayload(&response)
+                       }
+               })
        // start to serve API
        xapp.Logger.Info("Starting the HTTP Rest service")
        if err := server.Serve(); err != nil {