X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=pkg%2Fnbi%2Fhttprestful.go;fp=pkg%2Fnbi%2Fhttprestful.go;h=b07a8db1412126f283c0370c901bb05fc13c362b;hb=45b86cc64dc6071f160b0f2c9ab8dfb57d1ce039;hp=e764467c35b14e2d32811a3be01db605e364f4ca;hpb=41e32c6cd23e3ac33e4b004b0fde57e371d02c81;p=ric-plt%2Frtmgr.git diff --git a/pkg/nbi/httprestful.go b/pkg/nbi/httprestful.go index e764467..b07a8db 100644 --- a/pkg/nbi/httprestful.go +++ b/pkg/nbi/httprestful.go @@ -36,7 +36,6 @@ import ( "errors" "fmt" "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp" - xfmodel "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/models" "github.com/go-openapi/loads" "github.com/go-openapi/runtime/middleware" "net" @@ -580,25 +579,25 @@ func PopulateE2TMap(e2tDataList *[]rtmgr.E2tIdentity, e2ts map[string]rtmgr.E2TI func retrieveStartupData(xmurl string, nbiif string, fileName string, configfile string, e2murl string, sdlEngine sdl.Engine) error { xapp.Logger.Info("Invoked retrieveStartupData ") - var readErr error - var maxRetries = 10 + var readErr error + var maxRetries = 10 var xappData *[]rtmgr.XApp xappData = new([]rtmgr.XApp) xapp.Logger.Info("Trying to fetch XApps data from XAPP manager") - for i := 1; i <= maxRetries; i++ { - time.Sleep(2 * time.Second) + for i := 1; i <= maxRetries; i++ { + time.Sleep(2 * time.Second) - readErr = nil - xappData, err := httpGetXApps(xmurl) - if xappData != nil && err == nil { + readErr = nil + xappData, err := httpGetXApps(xmurl) + if xappData != nil && err == nil { break - } else if err == nil { - readErr = errors.New("unexpected HTTP status code") - } else { - xapp.Logger.Warn("cannot get xapp data due to: " + err.Error()) - readErr = err - } - } + } else if err == nil { + readErr = errors.New("unexpected HTTP status code") + } else { + xapp.Logger.Warn("cannot get xapp data due to: " + err.Error()) + readErr = err + } + } if ( readErr != nil) { return readErr @@ -608,6 +607,7 @@ func retrieveStartupData(xmurl string, nbiif string, fileName string, configfile e2ts := make(map[string]rtmgr.E2TInstance) xapp.Logger.Info("Trying to fetch E2T data from E2manager") for i := 1; i <= maxRetries; i++ { + time.Sleep(2 * time.Second) readErr = nil e2tDataList, err := httpGetE2TList(e2murl) @@ -620,7 +620,6 @@ func retrieveStartupData(xmurl string, nbiif string, fileName string, configfile xapp.Logger.Warn("cannot get E2T data from E2M due to: " + err.Error()) readErr = err } - time.Sleep(2 * time.Second) } if ( readErr != nil) { @@ -628,43 +627,22 @@ func retrieveStartupData(xmurl string, nbiif string, fileName string, configfile } pcData, confErr := rtmgr.GetPlatformComponents(configfile) - if confErr != nil { - xapp.Logger.Error(confErr.Error()) - return confErr - } - xapp.Logger.Info("Recieved intial xapp data, E2T data and platform data, writing into SDL.") - // Combine the xapps data and platform data before writing to the SDL + if confErr != nil { + xapp.Logger.Error(confErr.Error()) + return confErr + } + xapp.Logger.Info("Recieved intial xapp data, E2T data and platform data, writing into SDL.") + // Combine the xapps data and platform data before writing to the SDL ricData := &rtmgr.RicComponents{XApps: *xappData, Pcs: *pcData, E2Ts: e2ts, MeidMap: meids} - writeErr := sdlEngine.WriteAll(fileName, ricData) - if writeErr != nil { - xapp.Logger.Error(writeErr.Error()) - } - - xapp.Logger.Info("Trying to fetch Subscriptions data from Subscription manager") -/* for i := 1; i <= maxRetries; i++ { - readErr = nil - sub_list, err := xapp.Subscription.QuerySubscriptions() - - if sub_list != nil && err == nil { - PopulateSubscription(sub_list) - break - } else { - readErr = err - xapp.Logger.Warn("cannot get xapp data due to: " + readErr.Error()) + writeErr := sdlEngine.WriteAll(fileName, ricData) + if writeErr != nil { + xapp.Logger.Error(writeErr.Error()) + } + // post subscription req to appmgr + readErr = PostSubReq(xmurl, nbiif) + if readErr == nil { + return nil } - time.Sleep(2 * time.Second) - } - - if (readErr != nil) { - return readErr - } -*/ - // post subscription req to appmgr - readErr = PostSubReq(xmurl, nbiif) - if readErr == nil { - return nil - } - return readErr } @@ -863,21 +841,3 @@ func updateSubscription(data *rtmgr.XappList) { } } - -func PopulateSubscription(sub_list xfmodel.SubscriptionList) { - for _, sub_row := range sub_list { - var subdata models.XappSubscriptionData - id := int32(sub_row.SubscriptionID) - subdata.SubscriptionID = &id - for _, ep := range sub_row.Endpoint { - - stringSlice := strings.Split(ep, ":") - subdata.Address = &stringSlice[0] - intportval, _ := strconv.Atoi( stringSlice[1]) - value := uint16(intportval) - subdata.Port = &value - xapp.Logger.Debug("Adding Subscription List has Address :%v, port :%v, SubscriptionID :%v ", subdata.Address, subdata.Address, subdata.SubscriptionID) - addSubscription(&rtmgr.Subs, &subdata) - } - } -}