From: wahidw Date: Thu, 2 Jul 2020 07:36:05 +0000 (+0000) Subject: Routing manager needs to support for xApps that terminate other protocols than E2 X-Git-Tag: 0.6.3^0 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=ab07a4edbce65cc015e025109f51ea32022b2040;p=ric-plt%2Frtmgr.git Routing manager needs to support for xApps that terminate other protocols than E2 Change-Id: I97e3eebecca617ab94ed928abcdb1e986c4d361d Signed-off-by: wahidw --- diff --git a/RELNOTES b/RELNOTES index d2a370b..019508c 100644 --- a/RELNOTES +++ b/RELNOTES @@ -1,3 +1,6 @@ +### v0.6.3 +* [RIC-369] Routing manager needs to support for xApps that terminate other protocols than E2 + ### v0.6.2 * Distribution of routes is synchronous. diff --git a/api/routing_manager.yaml b/api/routing_manager.yaml index bdf19f1..fc93ab5 100644 --- a/api/routing_manager.yaml +++ b/api/routing_manager.yaml @@ -295,6 +295,53 @@ paths: description: "Invalid data" 201: description: "ran instances disociated" + /handles/addrmrroute: + post: + tags: + - "handle" + summary: "API to add RMR routes" + description: "By performing a POST method to add RMR routes" + operationId: "add_rmr_route" + consumes: + - "application/json" + produces: + - "application/json" + parameters: + - in: body + name: routes-list + description: "list of routes to add" + required: true + schema: + $ref: "#/definitions/routelist" + responses: + 400: + description: "Invalid data" + 201: + description: "rmr routes added" + + /handles/delrmrroute: + delete: + tags: + - "handle" + summary: "API to delete RMR routes" + description: "By performing a DELETE method to add RMR routes" + operationId: "del_rmr_route" + consumes: + - "application/json" + produces: + - "application/json" + parameters: + - in: body + name: routes-list + description: "list of routes to delete" + required: true + schema: + $ref: "#/definitions/routelist" + responses: + 400: + description: "Invalid data" + 201: + description: "rmr routes added" definitions: health-status: type: "object" @@ -412,6 +459,28 @@ definitions: RouteConfigs: type: "string" + add-rmr-route: + type: "object" + required: + - "TargetEndPoint" + - "MessageType" + properties: + TargetEndPoint: + type: "string" + MessageType: + type: "integer" + format: "uint32" + SenderEndPoint: + type: "string" + SubscriptionID: + type: "integer" + format: "int32" + + routelist: + type: "array" + items: + $ref: '#/definitions/add-rmr-route' + externalDocs: description: "Routing Manager" url: "http://placeholder" diff --git a/container-tag.yaml b/container-tag.yaml index bff5250..fb1cfa5 100644 --- a/container-tag.yaml +++ b/container-tag.yaml @@ -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.6.2 +tag: 0.6.3 diff --git a/pkg/nbi/httprestful.go b/pkg/nbi/httprestful.go index f49f3ae..e10f42b 100644 --- a/pkg/nbi/httprestful.go +++ b/pkg/nbi/httprestful.go @@ -491,6 +491,26 @@ func launchRest(nbiif *string){ return debug.NewGetDebuginfoOK().WithPayload(&response) } }) + api.HandleAddRmrRouteHandler = handle.AddRmrRouteHandlerFunc( + func(params handle.AddRmrRouteParams) middleware.Responder { + err := adddelrmrroute(params.RoutesList,true) + if err != nil { + return handle.NewAddRmrRouteBadRequest() + } else { + return handle.NewAddRmrRouteCreated() + } + + }) + api.HandleDelRmrRouteHandler = handle.DelRmrRouteHandlerFunc( + func(params handle.DelRmrRouteParams) middleware.Responder { + err := adddelrmrroute(params.RoutesList,false) + if err != nil { + return handle.NewDelRmrRouteBadRequest() + } else { + return handle.NewDelRmrRouteCreated() + } + }) + // start to serve API xapp.Logger.Info("Starting the HTTP Rest service") if err := server.Serve(); err != nil { @@ -655,7 +675,26 @@ func retrieveStartupData(xmurl string, nbiif string, fileName string, configfile // post subscription req to appmgr readErr = PostSubReq(xmurl, nbiif) + if readErr != nil { + return readErr + } + + //rlist := make(map[string]string) + xapp.Logger.Info("Reading SDL for any routes") + rlist,sdlerr := xapp.Sdl.Read("routes") + readErr = sdlerr if readErr == nil { + xapp.Logger.Info("Value is %s",rlist["routes"]) + if rlist["routes"] != nil { + formstring := fmt.Sprintf("%s",rlist["routes"]) + xapp.Logger.Info("Value of formed string = %s",formstring) + newstring := strings.Split(formstring," ") + for i,_ := range newstring { + xapp.Logger.Info("in Loop Value of formed string = %s",newstring) + rtmgr.DynamicRouteList = append(rtmgr.DynamicRouteList,newstring[i]) + } + } + return nil } @@ -769,3 +808,56 @@ func PopulateSubscription(sub_list xfmodel.SubscriptionList) { } } } + +func adddelrmrroute(routelist models.Routelist,rtflag bool) error { + xapp.Logger.Info("Updating rmrroute with Route list: %v,flag: %v", routelist,rtflag) + for _, rlist := range routelist { + var subid int32 + var data string + if rlist.SubscriptionID == 0 { + subid = -1 + } else { + subid = rlist.SubscriptionID + } + if rlist.SenderEndPoint == "" && rlist.SubscriptionID != 0 { + data = fmt.Sprintf("mse|%d|%d|%s\n",*rlist.MessageType,rlist.SubscriptionID,*rlist.TargetEndPoint) + } else if rlist.SenderEndPoint == "" && rlist.SubscriptionID == 0 { + data = fmt.Sprintf("mse|%d|-1|%s\n",*rlist.MessageType,*rlist.TargetEndPoint) + } else { + data = fmt.Sprintf("mse|%d,%s|%d|%s\n",*rlist.MessageType,rlist.SenderEndPoint,subid,*rlist.TargetEndPoint) + } + err := checkrepeatedroute(data) + + if rtflag == true { + if err == true { + xapp.Logger.Info("Given route %s is a duplicate",data) + } + rtmgr.DynamicRouteList = append(rtmgr.DynamicRouteList,data) + routearray := strings.Join(rtmgr.DynamicRouteList," ") + xapp.Sdl.Store("routes",routearray) + } else { + if err == true { + xapp.Logger.Info("Successfully deleted route: %s",data) + routearray := strings.Join(rtmgr.DynamicRouteList," ") + xapp.Sdl.Store("routes",routearray) + }else { + xapp.Logger.Info("No such route: %s",data) + return errors.New("No such route: " + data) + } + + } + } + return sendRoutesToAll() +} + +func checkrepeatedroute (data string) bool { + for i:=0;i