X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=pkg%2Fnbi%2Fcontrol.go;h=db6c40563982751a3a2654ce7d3972ce5a994578;hb=refs%2Fchanges%2F91%2F4591%2F1;hp=0ab3f069e3a055033ee10d536fb23ee93c8b52d5;hpb=7aaff4b8442554103e1e332d475fc7f232969831;p=ric-plt%2Frtmgr.git diff --git a/pkg/nbi/control.go b/pkg/nbi/control.go index 0ab3f06..db6c405 100644 --- a/pkg/nbi/control.go +++ b/pkg/nbi/control.go @@ -136,26 +136,34 @@ func (c *Control) handleUpdateToRoutingManagerRequest(params *xapp.RMRParams) { xapp.Logger.Info("Update Route Table Request, msg.String() : %s", msg.String()) xapp.Logger.Info("Update Route Table Request, params.Payload : %s", string(params.Payload)) - /*m.Lock() + m.Lock() data, err := sdlEngine.ReadAll(xapp.Config.GetString("rtfile")) m.Unlock() if err != nil || data == nil { xapp.Logger.Error("Cannot get data from sdl interface due to: " + err.Error()) return - }*/ + } - sbiEngine.CreateEndpoint(string(params.Payload),msg.String()) - /*if ep == nil { + ep := sbiEngine.CheckEndpoint(string(params.Payload)) + 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 } + epstr,whid := sbiEngine.CreateEndpoint(msg.String()) + if epstr == nil || whid < 0 { + xapp.Logger.Error("Wormhole Id creation failed %d for %s",whid,msg.String() ) + return + } + /*This is to ensure the latest routes are sent. + Assumption is that in this time interval the routes are built for this endpoint */ + time.Sleep(100 * time.Millisecond) policies := rpeEngine.GeneratePolicies(rtmgr.Eps, data) - err = sbiEngine.DistributeToEp(policies, ep) + err = sbiEngine.DistributeToEp(policies, *epstr, whid) if err != nil { xapp.Logger.Error("Routing table cannot be published due to: " + err.Error()) return - }*/ + } } func sendRoutesToAll() (err error) {