Adding Unit Test cases for rtmgr
[ric-plt/rtmgr.git] / pkg / rpe / rmr.go
index 9cda9d9..6fc8c9f 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.
    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).
+
 ==================================================================================
 */
 /*
 ==================================================================================
 */
 /*
@@ -26,6 +31,7 @@
 package rpe
 
 import (
 package rpe
 
 import (
+       "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
        "routing-manager/pkg/rtmgr"
        "strconv"
 )
        "routing-manager/pkg/rtmgr"
        "strconv"
 )
@@ -34,19 +40,10 @@ type Rmr struct {
        Rpe
 }
 
        Rpe
 }
 
-type RmrPub struct {
-       Rmr
-}
-
 type RmrPush struct {
        Rmr
 }
 
 type RmrPush struct {
        Rmr
 }
 
-func NewRmrPub() *RmrPub {
-       instance := new(RmrPub)
-       return instance
-}
-
 func NewRmrPush() *RmrPush {
        instance := new(RmrPush)
        return instance
 func NewRmrPush() *RmrPush {
        instance := new(RmrPush)
        return instance
@@ -57,7 +54,7 @@ Produces the raw route message consumable by RMR
 */
 func (r *Rmr) generateRMRPolicies(eps rtmgr.Endpoints, key string) *[]string {
        rawrt := []string{key + "newrt|start\n"}
 */
 func (r *Rmr) generateRMRPolicies(eps rtmgr.Endpoints, key string) *[]string {
        rawrt := []string{key + "newrt|start\n"}
-       rt := r.getRouteTable(eps)
+       rt := r.generateRouteTable(eps)
        for _, rte := range *rt {
                rawrte := key + "mse|" + rte.MessageType
                for _, tx := range rte.TxList {
        for _, rte := range *rt {
                rawrte := key + "mse|" + rte.MessageType
                for _, tx := range rte.TxList {
@@ -81,28 +78,28 @@ func (r *Rmr) generateRMRPolicies(eps rtmgr.Endpoints, key string) *[]string {
                        }
                }
                rawrte += group
                        }
                }
                rawrte += group
+
+                if (rte.RouteType == "%meid") {
+                        rawrte += group + rte.RouteType
+                }
+
                rawrt = append(rawrt, rawrte+"\n")
        }
        rawrt = append(rawrt, key+"newrt|end\n")
                rawrt = append(rawrt, rawrte+"\n")
        }
        rawrt = append(rawrt, key+"newrt|end\n")
-       rtmgr.Logger.Debug("rmr.GeneratePolicies returns: %v", rawrt)
-       return &rawrt
-}
 
 
-func (r *RmrPub) GeneratePolicies(eps rtmgr.Endpoints) *[]string {
-       rtmgr.Logger.Debug("Invoked rmr.GeneratePolicies, args: %v: ", eps)
-       return r.generateRMRPolicies(eps, "00000           ")
+        count := 0
+        rawrt = append(rawrt, key+"meid_map|start\n")
+        rawrt = append(rawrt, key+"meid_map|end|" + strconv.Itoa(count) +"\n")
+
+       xapp.Logger.Debug("rmr.GeneratePolicies returns: %v", rawrt)
+       return &rawrt
 }
 
 func (r *RmrPush) GeneratePolicies(eps rtmgr.Endpoints) *[]string {
 }
 
 func (r *RmrPush) GeneratePolicies(eps rtmgr.Endpoints) *[]string {
-       rtmgr.Logger.Debug("Invoked rmr.GeneratePolicies, args: %v: ", eps)
+       xapp.Logger.Debug("Invoked rmr.GeneratePolicies, args: %v: ", eps)
        return r.generateRMRPolicies(eps, "")
 }
 
        return r.generateRMRPolicies(eps, "")
 }
 
-func (r *RmrPub) GetRouteTable(eps rtmgr.Endpoints) *rtmgr.RouteTable {
-       return r.getRouteTable(eps)
-}
-
-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)
 }
 }
-