-func parseArgs() {
- // TODO: arguments should be validated (filename; xm-url; sbi-if; rest-url; rest-port)
- args = make(map[string]*string)
- args["configfile"] = flag.String("configfile", "/etc/rtmgrcfg.json", "Routing manager's configuration file path")
- args["nbi"] = flag.String("nbi", "httpRESTful", "Northbound interface module to be used. Valid values are: 'httpGetter | httpRESTful'")
- args["sbi"] = flag.String("sbi", "nngpush", "Southbound interface module to be used. Valid values are: 'nngpush")
- args["rpe"] = flag.String("rpe", "rmrpush", "Route Policy Engine to be used. Valid values are: 'rmrpush'")
- args["sdl"] = flag.String("sdl", "file", "Data store engine to be used. Valid values are: 'file'")
- args["xm-url"] = flag.String("xm-url", "http://localhost:3000/xapps", "HTTP URL where xApp Manager exposes the entire xApp List")
- args["nbi-if"] = flag.String("nbi-if", "http://localhost:8888", "Base HTTP URL where routing manager will be listening on")
- args["sbi-if"] = flag.String("sbi-if", "0.0.0.0", "IPv4 address of interface where Southbound socket to be opened")
- args["filename"] = flag.String("filename", "/db/rt.json", "Absolute path of file where the route information to be stored")
- args["loglevel"] = flag.String("loglevel", "INFO", "INFO | WARN | ERROR | DEBUG | TRACE")
- flag.Parse()
-}
-
-func initRtmgr() (nbiEngine nbi.Engine, sbiEngine sbi.Engine, sdlEngine sdl.Engine, rpeEngine rpe.Engine, err error) {
- if nbiEngine, err = nbi.GetNbi(*args["nbi"]); err == nil && nbiEngine != nil {
- if sbiEngine, err = sbi.GetSbi(*args["sbi"]); err == nil && sbiEngine != nil {
- if sdlEngine, err = sdl.GetSdl(*args["sdl"]); err == nil && sdlEngine != nil {
- if rpeEngine, err = rpe.GetRpe(*args["rpe"]); err == nil && rpeEngine != nil {
- return nbiEngine, sbiEngine, sdlEngine, rpeEngine, nil
- }
- }
- }
- }
- return nil, nil, nil, nil, err
-}
-
-func serveSBI(triggerSBI <-chan bool, sbiEngine sbi.Engine, sdlEngine sdl.Engine, rpeEngine rpe.Engine) {
- for {
- if <-triggerSBI {
- data, err := sdlEngine.ReadAll(*args["filename"])
- if err != nil || data == nil {
- rtmgr.Logger.Error("Cannot get data from sdl interface due to: " + err.Error())
- continue
- }
- sbiEngine.UpdateEndpoints(data)
- policies := rpeEngine.GeneratePolicies(rtmgr.Eps)
- err = sbiEngine.DistributeAll(policies)
- if err != nil {
- rtmgr.Logger.Error("Routing table cannot be published due to: " + err.Error())
- }
- }
- }
-}