J release: Release container Image
[ric-plt/submgr.git] / pkg / teststub / rmrenv.go
index 5a57b56..8c1f125 100644 (file)
@@ -20,7 +20,6 @@
 package teststub
 
 import (
-       "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/xapptweaks"
        "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
        "os"
        "strconv"
@@ -53,9 +52,9 @@ func (rrt *RmrRouteTable) AddRoute(mtype int, src string, subid int, trg string)
 func (rrt *RmrRouteTable) AddMeid(trg string, meids []string) {
 
        line := "mme_ar"
-       line += "|"
+       line += " | "
        line += trg
-       line += "|"
+       line += " | "
        for _, str := range meids {
                line += " " + str
        }
@@ -65,7 +64,7 @@ func (rrt *RmrRouteTable) AddMeid(trg string, meids []string) {
 func (rrt *RmrRouteTable) DelMeid(meids []string) {
 
        line := "mme_del"
-       line += "|"
+       line += " | "
        for _, str := range meids {
                line += " " + str
        }
@@ -82,6 +81,7 @@ func (rrt *RmrRouteTable) Table() string {
                allrt += val + "\n"
        }
        allrt += "newrt|end\n"
+       allrt += "\n"
        allrt += "meid_map | start\n"
        for _, val := range rrt.meids {
                allrt += val + "\n"
@@ -91,20 +91,21 @@ func (rrt *RmrRouteTable) Table() string {
 }
 
 func (rrt *RmrRouteTable) Enable() {
-       if len(rrt.tmpfile) > 0 {
-               os.Remove(rrt.tmpfile)
+       if len(rrt.tmpfile) == 0 {
+               rrt.tmpfile, _ = CreateTmpFile(rrt.Table())
        }
-       rrt.tmpfile, _ = CreateTmpFile(rrt.Table())
        os.Setenv("RMR_SEED_RT", rrt.tmpfile)
-       xapp.Logger.Info("Using rt file %s", os.Getenv("RMR_SEED_RT"))
+       os.Setenv("RMR_RTG_SVC", "-1")
+       xapp.Logger.Debug("Using rt file %s", os.Getenv("RMR_SEED_RT"))
 }
 
 func (rrt *RmrRouteTable) Disable() {
        if len(rrt.tmpfile) > 0 {
                os.Remove(rrt.tmpfile)
                os.Unsetenv("RMR_SEED_RT")
+               os.Unsetenv("RMR_RTG_SVC")
                rrt.tmpfile = ""
-               xapp.Logger.Info("Not using rt file ")
+               xapp.Logger.Debug("Not using rt file ")
        }
 }
 
@@ -113,36 +114,36 @@ func (rrt *RmrRouteTable) Disable() {
 //-----------------------------------------------------------------------------
 
 type RmrSrcId struct {
-       xapptweaks.RmrEndpoint
+       xapp.RmrEndpoint
 }
 
 func (rsi *RmrSrcId) Enable() {
        if rsi.Port > 0 {
                os.Setenv("RMR_SRC_ID", rsi.String())
-               xapp.Logger.Info("Using src id  %s", os.Getenv("RMR_SRC_ID"))
+               xapp.Logger.Debug("Using src id  %s", os.Getenv("RMR_SRC_ID"))
        }
 }
 
 func (rsi *RmrSrcId) Disable() {
        os.Unsetenv("RMR_SRC_ID")
-       xapp.Logger.Info("Not using Using src id")
+       xapp.Logger.Debug("Not using Using src id")
 }
 
 //-----------------------------------------------------------------------------
 //
 //-----------------------------------------------------------------------------
 type RmrRtgSvc struct {
-       xapptweaks.RmrEndpoint
+       xapp.RmrEndpoint
 }
 
 func (rrs *RmrRtgSvc) Enable() {
        if rrs.Port > 0 {
                os.Setenv("RMR_RTG_SVC", rrs.String())
-               xapp.Logger.Info("Using rtg svc  %s", os.Getenv("RMR_SRC_ID"))
+               xapp.Logger.Debug("Using rtg svc  %s", os.Getenv("RMR_SRC_ID"))
        }
 }
 
 func (rrs *RmrRtgSvc) Disable() {
        os.Unsetenv("RMR_RTG_SVC")
-       xapp.Logger.Info("Not using Using rtg svc")
+       xapp.Logger.Debug("Not using Using rtg svc")
 }