Removed Book Keeping of RMR CTL ports. Route Distribution only on demand
[ric-plt/rtmgr.git] / pkg / rpe / rpe.go
index 8f86b4d..4097ae0 100644 (file)
@@ -115,7 +115,8 @@ func (r *Rpe) addRoute(messageType string, tx *rtmgr.Endpoint, rx *rtmgr.Endpoin
                if rx != nil {
                        rxList = []rtmgr.EndpointList{[]rtmgr.Endpoint{*rx}}
                }
-               messageId := strconv.Itoa(xapp.RICMessageTypes[messageType])
+               //messageId := strconv.Itoa(xapp.RICMessageTypes[messageType])
+               messageId := rtmgr.Mtype[messageType]
                route := rtmgr.RouteTableEntry{
                        MessageType: messageId,
                        TxList:      txList,
@@ -143,7 +144,8 @@ func (r *Rpe) addRoute_rx_list(messageType string, tx *rtmgr.Endpoint, rx []rtmg
                }
        }
 
-       messageId := strconv.Itoa(xapp.RICMessageTypes[messageType])
+       //messageId := strconv.Itoa(xapp.RICMessageTypes[messageType])
+       messageId := rtmgr.Mtype[messageType]
        route := rtmgr.RouteTableEntry{
                MessageType: messageId,
                TxList:      txList,
@@ -218,18 +220,22 @@ func (r *Rpe) generateSubscriptionRoutes(selectedxAppEp *rtmgr.Endpoint, subManE
                xAppUuid := subscription.Fqdn + ":" + strconv.Itoa(int(subscription.Port))
                xapp.Logger.Debug("xApp UUID: %v", xAppUuid)
                xAppEp := getEndpointByUuid(xAppUuid)
-               if xAppEp.Uuid == selectedxAppEp.Uuid {
-                       xapp.Logger.Debug("xApp UUID is matched for selected xApp.UUID: %v and xApp.Name: %v", selectedxAppEp.Uuid, selectedxAppEp.Name)
-                       /// TODO
-                       //Subscription Manager -> xApp
-                       r.addRoute("RIC_SUB_RESP", subManEp, xAppEp, routeTable, subscription.SubID, "")
-                       r.addRoute("RIC_SUB_FAILURE", subManEp, xAppEp, routeTable, subscription.SubID, "")
-                       r.addRoute("RIC_SUB_DEL_RESP", subManEp, xAppEp, routeTable, subscription.SubID, "")
-                       r.addRoute("RIC_SUB_DEL_FAILURE", subManEp, xAppEp, routeTable, subscription.SubID, "")
-                       //E2 Termination -> xApp
-                       r.addRoute("RIC_INDICATION", nil, xAppEp, routeTable, subscription.SubID, "")
-                       r.addRoute("RIC_CONTROL_ACK", nil, xAppEp, routeTable, subscription.SubID, "")
-                       r.addRoute("RIC_CONTROL_FAILURE", nil, xAppEp, routeTable, subscription.SubID, "")
+               if xAppEp != nil {
+                       if xAppEp.Uuid == selectedxAppEp.Uuid {
+                               xapp.Logger.Debug("xApp UUID is matched for selected xApp.UUID: %v and xApp.Name: %v", selectedxAppEp.Uuid, selectedxAppEp.Name)
+                               /// TODO
+                               //Subscription Manager -> xApp
+                               r.addRoute("RIC_SUB_RESP", subManEp, xAppEp, routeTable, subscription.SubID, "")
+                               r.addRoute("RIC_SUB_FAILURE", subManEp, xAppEp, routeTable, subscription.SubID, "")
+                               r.addRoute("RIC_SUB_DEL_RESP", subManEp, xAppEp, routeTable, subscription.SubID, "")
+                               r.addRoute("RIC_SUB_DEL_FAILURE", subManEp, xAppEp, routeTable, subscription.SubID, "")
+                               //E2 Termination -> xApp
+                               r.addRoute("RIC_INDICATION", nil, xAppEp, routeTable, subscription.SubID, "")
+                               r.addRoute("RIC_CONTROL_ACK", nil, xAppEp, routeTable, subscription.SubID, "")
+                               r.addRoute("RIC_CONTROL_FAILURE", nil, xAppEp, routeTable, subscription.SubID, "")
+                       }
+               } else {
+                               xapp.Logger.Error("generateSubscriptionRoutes xAppEp is nil, xApp UUID: %v", xAppUuid)
                }
        }
 }
@@ -238,6 +244,10 @@ func (r *Rpe) generatePlatformRoutes(e2TermEp []rtmgr.Endpoint, subManEp *rtmgr.
        xapp.Logger.Debug("rpe.generatePlatformRoutes invoked")
        //Platform Routes --- Subscription Routes
        //Subscription Manager -> E2 Termination
+       if rtmgr.PrsCfg == nil {
+               xapp.Logger.Info("No static routes configuration")
+               return
+       }
        for _, routes := range *rtmgr.PrsCfg {
                var sendEp *rtmgr.Endpoint
                var Ep *rtmgr.Endpoint
@@ -246,8 +256,6 @@ func (r *Rpe) generatePlatformRoutes(e2TermEp []rtmgr.Endpoint, subManEp *rtmgr.
                        sendEp = subManEp
                case "E2MAN":
                        sendEp = e2ManEp
-               //case "UEMAN":
-               //      sendEp = ueManEp
                case "RSM":
                        sendEp = rsmEp
                case "A1MEDIATOR":
@@ -296,11 +304,6 @@ func (r *Rpe) generateRouteTable(endPointList rtmgr.Endpoints) *rtmgr.RouteTable
                xapp.Logger.Error("Platform component not found: %v", "E2 Manager")
                xapp.Logger.Debug("Endpoints: %v", endPointList)
        }
-       /*ueManEp := getEndpointByName(&endPointList, "UEMAN")
-       if ueManEp == nil {
-               xapp.Logger.Error("Platform component not found: %v", "UE Manger")
-               xapp.Logger.Debug("Endpoints: %v", endPointList)
-       }*/
        rsmEp := getEndpointByName(&endPointList, "RSM")
        if rsmEp == nil {
                xapp.Logger.Error("Platform component not found: %v", "Resource Status Manager")