+### v0.4.14
+* Restart/Start of RM, fetch E2T data from E2manager - implementation in RM for v1/e2t/list API handling
+
### v0.4.13
* Corrected route table syntax in case of broadcast message
triggerSBI := make(chan bool)
- nbiErr := nbiEngine.Initialize(xapp.Config.GetString("xmurl"), xapp.Config.GetString("nbiurl"), xapp.Config.GetString("rtfile"), xapp.Config.GetString("cfgfile"),
+ nbiErr := nbiEngine.Initialize(xapp.Config.GetString("xmurl"), xapp.Config.GetString("nbiurl"), xapp.Config.GetString("rtfile"), xapp.Config.GetString("cfgfile"), xapp.Config.GetString("e2murl"),
sdlEngine, rpeEngine, triggerSBI, m)
if nbiErr != nil {
xapp.Logger.Error("Failed to initialize nbi due to: " + nbiErr.Error())
# By default this file is in the docker build directory,
# but the location can configured in the JJB template.
---
-tag: 0.4.13
+tag: 0.4.14
return nil, nil
}
-func (g *HttpGetter) Initialize(xmurl string, nbiif string, fileName string, configfile string,
+func (g *HttpGetter) Initialize(xmurl string, nbiif string, fileName string, configfile string, e2murl string,
sdlEngine sdl.Engine, rpeEngine rpe.Engine, triggerSBI chan<- bool, m *sync.Mutex) error {
return nil
}
var (
XMURL = "http://127.0.0.1:3000/ric/v1/xapps"
+ E2MURL = "http://127.0.0.1:8080/ric/v1/e2t/list"
)
func TestFetchXappListInvalidData(t *testing.T) {
return nil, nil
}
-func retrieveStartupData(xmurl string, nbiif string, fileName string, configfile string, sdlEngine sdl.Engine) error {
- var readErr error
- var maxRetries = 10
- for i := 1; i <= maxRetries; i++ {
- time.Sleep(2 * time.Second)
- xappData, err := httpGetXApps(xmurl)
- if xappData != nil && err == nil {
- pcData, confErr := rtmgr.GetPlatformComponents(configfile)
- if confErr != nil {
- xapp.Logger.Error(confErr.Error())
- return confErr
- }
- xapp.Logger.Info("Recieved intial xapp 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: make(map[string]rtmgr.E2TInstance)}
- 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
+func httpGetE2TList(e2murl string) (*[]rtmgr.E2tIdentity, error) {
+ xapp.Logger.Info("Invoked httprestful.httpGetE2TList: " + e2murl)
+ r, err := myClient.Get(e2murl)
+ if err != nil {
+ return nil, err
+ }
+ defer r.Body.Close()
+
+ if r.StatusCode == 200 {
+ xapp.Logger.Debug("http client raw response: %v", r)
+ var E2Tlist []rtmgr.E2tIdentity
+ err = json.NewDecoder(r.Body).Decode(&E2Tlist)
+ if err != nil {
+ xapp.Logger.Warn("Json decode failed: " + err.Error())
+ }
+ xapp.Logger.Info("HTTP GET: OK")
+ xapp.Logger.Debug("httprestful.httpGetXApps returns: %v", E2Tlist)
+ return &E2Tlist, err
+ }
+ xapp.Logger.Warn("httprestful got an unexpected http status code: %v", r.StatusCode)
+ return nil, nil
+}
+
+func PopulateE2TMap(e2tDataList *[]rtmgr.E2tIdentity, e2ts map[string]rtmgr.E2TInstance, meids []string) {
+ xapp.Logger.Info("Invoked httprestful.PopulateE2TMap ")
+
+ for _, e2tData := range *e2tDataList {
+ var str string
+
+ e2tinst := rtmgr.E2TInstance{
+ Ranlist: make([]string, len(e2tData.Rannames)),
+ }
+
+ e2tinst.Fqdn = e2tData.E2taddress
+ e2tinst.Name = "E2TERMINST"
+ copy(e2tinst.Ranlist, e2tData.Rannames)
+
+ if len(e2tData.Rannames) > 0 {
+ var meidar string
+ for _, meid := range e2tData.Rannames {
+ meidar += meid + " "
}
+ str += "mme_ar|" + e2tData.E2taddress + "|" + strings.TrimSuffix(meidar, " ")
+ }
+
+ e2ts[e2tinst.Fqdn] = e2tinst
+ meids = append(meids,str)
+ }
+}
+
+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 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)
+
+ 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
+ }
+ }
+
+ if ( readErr != nil) {
+ return readErr
+ }
+
+ var meids []string
+ 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)
+ if e2tDataList != nil && err == nil {
+ PopulateE2TMap(e2tDataList, e2ts, meids[:])
+ break
} else if err == nil {
readErr = errors.New("unexpected HTTP status code")
} else {
- xapp.Logger.Warn("cannot get xapp data due to: " + err.Error())
+ xapp.Logger.Warn("cannot get E2T data from E2M due to: " + err.Error())
readErr = err
}
}
+
+ if ( readErr != nil) {
+ return readErr
+ }
+
+ 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
+ ricData := &rtmgr.RicComponents{XApps: *xappData, Pcs: *pcData, E2Ts: e2ts, MeidMap: meids}
+ 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
+ }
return readErr
}
-func (r *HttpRestful) Initialize(xmurl string, nbiif string, fileName string, configfile string,
+func (r *HttpRestful) Initialize(xmurl string, nbiif string, fileName string, configfile string, e2murl string,
sdlEngine sdl.Engine, rpeEngine rpe.Engine, triggerSBI chan<- bool, m *sync.Mutex) error {
- err := r.RetrieveStartupData(xmurl, nbiif, fileName, configfile, sdlEngine)
+ err := r.RetrieveStartupData(xmurl, nbiif, fileName, configfile, e2murl, sdlEngine)
if err != nil {
xapp.Logger.Error("Exiting as nbi failed to get the initial startup data from the xapp manager: " + err.Error())
return err
var SubscriptionResp = []byte(`{"ID":"deadbeef1234567890", "Version":0, "EventType":"all"}`)
+var E2TListResp = []byte(`[{"e2tAddress":"127.0.0.1:0","ranNames":["RanM0","RanN0"]},{"e2tAddress":"127.0.0.1:1","ranNames":["RanM1","RanN1"]},{"e2tAddress":"127.0.0.1:2","ranNames":["RanM2","RanN2"]},{"e2tAddress":"127.0.0.1:3","ranNames":["RanM3","RanN3"]}]`)
+
var InvalidSubResp = []byte(`{"Version":0, "EventType":all}`)
func TestValidateXappCallbackData_1(t *testing.T) {
//ts.Start()
//defer ts.Close()
var m sync.Mutex
- err = httpinstance.Initialize(XMURL, "httpgetter", "rt.json", "config.json", sdlEngine, rpeEngine, triggerSBI, &m)
+ err = httpinstance.Initialize(XMURL, "httpgetter", "rt.json", "config.json", E2MURL, sdlEngine, rpeEngine, triggerSBI, &m)
}
func TestXappCallbackDataChannelwithdata(t *testing.T) {
//subdel test
}
-func createMockAppmgrWithData(url string, g []byte, p []byte) *httptest.Server {
+func createMockAppmgrWithData(url string, g []byte, p []byte, t []byte) *httptest.Server {
l, err := net.Listen("tcp", url)
if err != nil {
fmt.Println("Failed to create listener: " + err.Error())
w.WriteHeader(http.StatusCreated)
w.Write(p)
}
+ if r.Method == "GET" && r.URL.String() == "/ric/v1/e2t/list" {
+ w.Header().Add("Content-Type", "application/json")
+ w.WriteHeader(http.StatusOK)
+ w.Write(t)
+ }
}))
ts.Listener.Close()
func TestHttpGetXAppsWithValidData(t *testing.T) {
var expected = 1
- ts := createMockAppmgrWithData("127.0.0.1:3000", BasicXAppLists, nil)
+ ts := createMockAppmgrWithData("127.0.0.1:3000", BasicXAppLists, nil, nil)
ts.Start()
defer ts.Close()
func TestRetrieveStartupDataTimeout(t *testing.T) {
sdlEngine, _ := sdl.GetSdl("file")
createMockPlatformComponents()
- err := retrieveStartupData(XMURL, "httpgetter", "rt.json", "config.json", sdlEngine)
+ err := retrieveStartupData(XMURL, "httpgetter", "rt.json", "config.json", E2MURL, sdlEngine)
if err == nil {
t.Error("Cannot retrieve startup data: " + err.Error())
}
}
func TestRetrieveStartupData(t *testing.T) {
- ts := createMockAppmgrWithData("127.0.0.1:3000", BasicXAppLists, SubscriptionResp)
+ ts := createMockAppmgrWithData("127.0.0.1:3000", BasicXAppLists, SubscriptionResp, nil)
ts.Start()
defer ts.Close()
+
+ ts1 := createMockAppmgrWithData("127.0.0.1:8080", nil, nil, E2TListResp)
+ ts1.Start()
+ defer ts1.Close()
+
sdlEngine, _ := sdl.GetSdl("file")
var httpRestful, _ = GetNbi("httpRESTful")
createMockPlatformComponents()
- err := httpRestful.(*HttpRestful).RetrieveStartupData(XMURL, "httpgetter", "rt.json", "config.json", sdlEngine)
+ err := httpRestful.(*HttpRestful).RetrieveStartupData(XMURL, "httpgetter", "rt.json", "config.json", E2MURL, sdlEngine)
//err := retrieveStartupData(XMURL, "httpgetter", "rt.json", "config.json", sdlEngine)
if err != nil {
t.Error("Cannot retrieve startup data: " + err.Error())
}
func TestRetrieveStartupDataWithInvalidSubResp(t *testing.T) {
- ts := createMockAppmgrWithData("127.0.0.1:3000", BasicXAppLists, InvalidSubResp)
+ ts := createMockAppmgrWithData("127.0.0.1:3000", BasicXAppLists, InvalidSubResp, nil)
ts.Start()
defer ts.Close()
sdlEngine, _ := sdl.GetSdl("file")
var httpRestful, _ = GetNbi("httpRESTful")
createMockPlatformComponents()
- err := httpRestful.(*HttpRestful).RetrieveStartupData(XMURL, "httpgetter", "rt.json", "config.json", sdlEngine)
+ err := httpRestful.(*HttpRestful).RetrieveStartupData(XMURL, "httpgetter", "rt.json", "config.json", E2MURL, sdlEngine)
if err == nil {
t.Error("Cannot retrieve startup data: " + err.Error())
}
type RecvNewE2TdataHandler func(<-chan *models.E2tData) (*rtmgr.E2TInstance, string, error)
type LaunchRestHandler func(*string, chan<- *models.XappCallbackData, chan<- *models.XappSubscriptionData, chan<- *rtmgr.XappList, chan<- *models.XappSubscriptionData, chan<- *models.E2tData, chan<- models.RanE2tMap, chan<- models.RanE2tMap, chan<- *models.E2tDeleteData)
type ProvideXappHandleHandlerImpl func(chan<- *models.XappCallbackData, *models.XappCallbackData) error
-type RetrieveStartupDataHandler func(string, string, string, string, sdl.Engine) error
+type RetrieveStartupDataHandler func(string, string, string, string, string, sdl.Engine) error
type EngineConfig struct {
Name string
}
type Engine interface {
- Initialize(string, string, string, string, sdl.Engine, rpe.Engine, chan<- bool, *sync.Mutex) error
+ Initialize(string, string, string, string, string, sdl.Engine, rpe.Engine, chan<- bool, *sync.Mutex) error
Terminate() error
}
Ranlist []string `json:"ranlist"`
}
+type E2tIdentity struct {
+ E2taddress string `json:"e2tAddress"`
+ Rannames []string `json:"ranNames"`
+}
+
type ConfigRtmgr struct {
Pcs PlatformComponents `json:"PlatformComponents"`
}