Creating dymanic endpoints(Eps) and distributing routes to those endpoints on upgrad... 31/4531/1
authorrangajal <ranjit.angajala@nokia.com>
Tue, 11 Aug 2020 06:51:17 +0000 (06:51 +0000)
committerrangajal <ranjit.angajala@nokia.com>
Tue, 11 Aug 2020 06:51:30 +0000 (06:51 +0000)
Change-Id: I92bf9d51bcc429069175c1e964177e22f0e6e300
Signed-off-by: rangajal <ranjit.angajala@nokia.com>
Dockerfile
RELNOTES
cmd/rtmgr.go
container-tag.yaml
pkg/nbi/control.go
pkg/rtmgr/rtmgr.go
pkg/rtmgr/types.go
pkg/sbi/nngpush.go
pkg/sbi/sbi.go
pkg/sbi/types.go

index 20f4b60..c38c323 100644 (file)
@@ -23,7 +23,7 @@
 # a Docker tag from the string in file container-tag.yaml
 
 #FROM golang:1.12.1 as rtmgrbuild
-FROM nexus3.o-ran-sc.org:10004/o-ran-sc/bldr-ubuntu18-c-go:8-u18.04 as rtmgrbuild
+FROM nexus3.o-ran-sc.org:10004/o-ran-sc/bldr-ubuntu18-c-go:9-u18.04 as rtmgrbuild
 
 # Install RMr shared library
 ARG RMRVERSION=4.1.2
index 019508c..ab8b838 100644 (file)
--- a/RELNOTES
+++ b/RELNOTES
@@ -1,3 +1,6 @@
+### v0.6.4
+* Creating dymanic endpoints(Eps) and distributing routes to those endpoints on  upgrade route table request from xApp (this is fixed part MCxapp distribution issue for multiple route ports)
+
 ### v0.6.3
 * [RIC-369] Routing manager needs to support for xApps that terminate other protocols than E2 
 
index af0aba1..37934ad 100644 (file)
@@ -66,6 +66,7 @@ func main() {
        xapp.Logger.Info("Start " + SERVICENAME + " service")
        rtmgr.Eps = make(rtmgr.Endpoints)
        rtmgr.Mtype = make(rtmgr.MessageTypeList)
+       rtmgr.RmrEp = make(rtmgr.ProcessMultipleRMR)
        rtmgr.Rtmgr_ready = false
 
 // RMR thread is starting port: 4560
index 41de17d..2ff9714 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.6.4
+tag: 0.6.5
index 885230f..4f61299 100644 (file)
@@ -144,7 +144,7 @@ func (c *Control) handleUpdateToRoutingManagerRequest(params *xapp.RMRParams) {
                return
        }
 
-       ep := sbiEngine.CreateEndpoint(string(params.Payload))
+       ep := sbiEngine.CreateEndpoint(string(params.Payload),msg.String())
        if ep == nil {
                xapp.Logger.Error("Update Routing Table Request can't handle due to end point %s is not avail in complete ep list: ", string(params.Payload))
                return
index de7db00..7276bc8 100644 (file)
@@ -43,6 +43,7 @@ var (
        Subs SubscriptionList
        PrsCfg  *PlatformRoutes
        Mtype MessageTypeList
+       RmrEp ProcessMultipleRMR
        DynamicRouteList []string
 )
 
index 138c2b5..4501bb8 100644 (file)
@@ -41,6 +41,8 @@ type SubscriptionList []Subscription
 
 type MessageTypeList map[string]string
 
+type ProcessMultipleRMR map[string]int
+
 //TODO: uuid is not a real UUID but a string of "ip:port"
 // this should be changed to real UUID later on which should come from xApp Manager // petszila
 type Endpoint struct {
index 1f0e0e6..dbd5d59 100644 (file)
@@ -123,6 +123,10 @@ func (c *RmrPush) DistributeAll(policies *[]string) error {
         for _, ep := range rtmgr.Eps {
                 go c.send_sync(ep,  policies, channel, rmrcallid)
         }
+       for rEp, id := range rtmgr.RmrEp {
+                go c.send_rt_process(rEp,id,policies,rmrcallid)
+        }
+
        rmrcallid++
 
         count := 0
@@ -188,8 +192,8 @@ func (c *RmrPush) send_data(ep *rtmgr.Endpoint, policies *[]string, call_id int)
         return false
 }
 
-func (c *RmrPush) CreateEndpoint(payload string) *rtmgr.Endpoint {
-       return c.createEndpoint(payload, c)
+func (c *RmrPush) CreateEndpoint(payload string,rmrsrc string)*rtmgr.Endpoint  {
+       return c.createEndpoint(payload,rmrsrc, c)
 }
 
 func (c *RmrPush) DistributeToEp(policies *[]string, ep *rtmgr.Endpoint) error {
@@ -205,3 +209,39 @@ func (c *RmrPush) DistributeToEp(policies *[]string, ep *rtmgr.Endpoint) error {
 
        return nil
 }
+
+func (c *RmrPush) send_rt_process(ep string,whid int, policies *[]string, call_id int) bool {
+        xapp.Logger.Debug("Invoked send_rt_process to endpoint: " + ep + " call_id: " + strconv.Itoa(call_id) + "whid: " + strconv.Itoa(whid))
+        var state int
+        var retstr string
+
+        var policy = []byte{}
+
+        for _, pe := range *policies {
+                b:= []byte(pe)
+                for j:=0; j<len(b); j++{
+                        policy = append(policy,b[j])
+                }
+        }
+        params := &RMRParams{&xapp.RMRParams{}}
+        params.Mtype = 20
+        params.PayloadLen = len(policy)
+        params.Payload =[]byte(policy)
+        params.Mbuf = nil
+        params.Whid = whid
+        params.Callid = call_id
+        params.Timeout = 200
+        state, retstr = xapp.Rmr.SendCallMsg(params.RMRParams)
+        routestatus := strings.Split(retstr," ")
+        if state != C.RMR_OK && routestatus[0] == "OK" {
+                xapp.Logger.Error("Updating Routes to Endpoint: " + ep + " failed, call_id: " + strconv.Itoa(call_id) + ",whi_id: " + strconv.Itoa(whid) + " for xapp.Rmr.SendCallMsg " + " Route Update Status: " + routestatus[0])
+              return false
+        } else {
+                xapp.Logger.Info("Update Routes to Endpoint: " + ep + " successful, call_id: " + strconv.Itoa(call_id) + ", Payload length: " + strconv.Itoa(params.PayloadLen) + ",whi_id: " + strconv.Itoa(whid) + ", Route Update Status: " + routestatus[0] + "(# of Entries:" + strconv.Itoa(len(*policies)))
+      return true
+        }
+
+        xapp.Logger.Error("Route Update to endpoint: " + ep + " failed, call_id: " + strconv.Itoa(call_id) + ",whi_id: " + strconv.Itoa(whid) + " xapp.Rmr.SendCallMsg not called")
+        return false
+}
+
index 018c111..c576c34 100644 (file)
@@ -31,9 +31,9 @@ package sbi
 
 import (
        "errors"
-       "fmt"
+       //"fmt"
        "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
-       "net"
+       //"net"
        "routing-manager/pkg/rtmgr"
        "strconv"
        "strings"
@@ -176,19 +176,19 @@ func (s *Sbi) updateE2TEndpoints(E2Ts *map[string]rtmgr.E2TInstance, sbi Engine)
        }
 }
 
-func (s *Sbi) createEndpoint(payload string, sbi Engine) *rtmgr.Endpoint {
+func (s *Sbi) createEndpoint(payload string,rmrsrc string, sbi Engine) *rtmgr.Endpoint {
        xapp.Logger.Debug("CreateEndPoint %v", payload)
-       stringSlice := strings.Split(payload, " ")
-       uuid := stringSlice[0]
-       xapp.Logger.Debug(">>> uuid %v", stringSlice[0])
+//     stringSlice := strings.Split(payload, " ")
+//     uuid := stringSlice[0]
+//     xapp.Logger.Debug(">>> uuid %v", stringSlice[0])
 
-       if _, ok := rtmgr.Eps[uuid]; ok {
+/*     if _, ok := rtmgr.Eps[uuid]; ok {
                ep := rtmgr.Eps[uuid]
                return ep
-       }
+       }*/
 
        /* incase the stored Endpoint list is in the form of IP:port*/
-       stringsubsplit := strings.Split(uuid, ":")
+/*     stringsubsplit := strings.Split(uuid, ":")
        addr, err := net.LookupIP(stringsubsplit[0])
        if err == nil {
                convertedUuid := fmt.Sprintf("%s:%s", addr[0], stringsubsplit[1])
@@ -197,7 +197,18 @@ func (s *Sbi) createEndpoint(payload string, sbi Engine) *rtmgr.Endpoint {
                        ep := rtmgr.Eps[convertedUuid]
                        return ep
                }
+       }*/
+
+       /* Create a new mapping, this case is assumed for multiple process sending RMR request from a container */
+       srcString := strings.Split(rmrsrc," ")
+       srcStringSlice := strings.Split(srcString[0],"=")
+       Whid := int(xapp.Rmr.Openwh(srcStringSlice[1]))
+
+       xapp.Logger.Info("Wormhole Id created is %d for EndPoint %s",Whid,srcStringSlice[1])
+       if Whid > 0 {
+               rtmgr.RmrEp[srcStringSlice[1]] = Whid
+               xapp.Logger.Info("received %s and mapped to Whid = %d",srcStringSlice[1],Whid)
        }
 
        return nil
-}
+ }
index 232a1dc..9e6fe02 100644 (file)
@@ -45,7 +45,7 @@ type Engine interface {
        AddEndpoint(*rtmgr.Endpoint) error
        DeleteEndpoint(*rtmgr.Endpoint) error
        UpdateEndpoints(*rtmgr.RicComponents)
-       CreateEndpoint(string) (*rtmgr.Endpoint)
+       CreateEndpoint(string,string)*rtmgr.Endpoint
        DistributeToEp(*[]string, *rtmgr.Endpoint) error
 }