Reverting the code after releasing the image
[ric-plt/rtmgr.git] / pkg / rpe / rmr.go
index 41c1c4c..346644c 100644 (file)
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
+
+
+   This source code is part of the near-RT RIC (RAN Intelligent Controller)
+   platform project (RICP).
+
 ==================================================================================
 */
 /*
 package rpe
 
 import (
+       "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
        "routing-manager/pkg/rtmgr"
        "strconv"
+       //"strings"
 )
 
 type Rmr struct {
        Rpe
 }
 
-type RmrPub struct {
-       Rmr
-}
-
 type RmrPush struct {
        Rmr
 }
 
-func NewRmrPub() *RmrPub {
-       instance := new(RmrPub)
-       return instance
-}
-
 func NewRmrPush() *RmrPush {
        instance := new(RmrPush)
        return instance
@@ -55,17 +53,11 @@ func NewRmrPush() *RmrPush {
 /*
 Produces the raw route message consumable by RMR
 */
-func (r *Rmr) generateRMRPolicies(eps rtmgr.Endpoints, key string) *[]string {
+func (r *Rmr) generateRMRPolicies(eps rtmgr.Endpoints, rcs *rtmgr.RicComponents, key string) *[]string {
        rawrt := []string{key + "newrt|start\n"}
-       rt := r.getRouteTable(eps)
+       rt := r.generateRouteTable(eps)
        for _, rte := range *rt {
-               rawrte := key //+ "rte|" + rte.MessageType
-               if rte.SubID == -1 {
-                       rawrte += "rte|"
-               } else {
-                       rawrte += "mse|"
-               }
-               rawrte += rte.MessageType
+               rawrte := key + "mse|" + rte.MessageType
                for _, tx := range rte.TxList {
                        rawrte += "," + tx.Ip + ":" + strconv.Itoa(int(tx.Port))
                }
@@ -87,28 +79,34 @@ func (r *Rmr) generateRMRPolicies(eps rtmgr.Endpoints, key string) *[]string {
                        }
                }
                rawrte += group
+
+                if (rte.RouteType == "%meid") {
+                        rawrte += group + rte.RouteType
+                }
+
                rawrt = append(rawrt, rawrte+"\n")
        }
        rawrt = append(rawrt, key+"newrt|end\n")
-       rtmgr.Logger.Debug("rmr.GeneratePolicies returns: %v", rawrt)
+        count := 0
+
+       meidrt := key +"meid_map|start\n"
+        for _, value := range rcs.MeidMap {
+            meidrt += key + value + "\n"
+            count++
+        }
+        meidrt += key+"meid_map|end|" + strconv.Itoa(count) +"\n"
+
+       rawrt = append(rawrt, meidrt)
+       xapp.Logger.Debug("rmr.GeneratePolicies returns: %v", rawrt)
+       xapp.Logger.Debug("rmr.GeneratePolicies returns: %v", rcs)
        return &rawrt
 }
 
-func (r *RmrPub) GeneratePolicies(eps rtmgr.Endpoints) *[]string {
-       rtmgr.Logger.Debug("Invoked rmr.GeneratePolicies, args: %v: ", eps)
-       return r.generateRMRPolicies(eps, "00000           ")
-}
-
-func (r *RmrPush) GeneratePolicies(eps rtmgr.Endpoints) *[]string {
-       rtmgr.Logger.Debug("Invoked rmr.GeneratePolicies, args: %v: ", eps)
-       return r.generateRMRPolicies(eps, "")
-}
-
-func (r *RmrPub) GetRouteTable(eps rtmgr.Endpoints) *rtmgr.RouteTable {
-       return r.getRouteTable(eps)
+func (r *RmrPush) GeneratePolicies(eps rtmgr.Endpoints, rcs *rtmgr.RicComponents) *[]string {
+       xapp.Logger.Debug("Invoked rmr.GeneratePolicies, args: %v: ", eps)
+       return r.generateRMRPolicies(eps, rcs, "")
 }
 
-func (r *RmrPush) GetRouteTable(eps rtmgr.Endpoints) *rtmgr.RouteTable {
-       return r.getRouteTable(eps)
+func (r *RmrPush) GenerateRouteTable(eps rtmgr.Endpoints) *rtmgr.RouteTable {
+       return r.generateRouteTable(eps)
 }
-