+func (f *File) WriteXApps(file string, xApps *[]rtmgr.XApp) error {
+ xapp.Logger.Debug("Invoked sdl.WriteXApps")
+ xapp.Logger.Debug("file.fileWriteXApps writes into file: " + file)
+ xapp.Logger.Debug("file.fileWriteXApps writes data: %v", *xApps)
+
+ ricData, err := NewFile().ReadAll(file)
+ if err != nil {
+ xapp.Logger.Error("cannot get data from sdl interface due to: " + err.Error())
+ return errors.New("cannot read full ric data to modify xApps data, due to: " + err.Error())
+ }
+ ricData.XApps = *xApps
+
+ byteValue, err := json.Marshal(ricData)
+ if err != nil {
+ return errors.New("cannot convert data due to: " + err.Error())
+ }
+ err = ioutil.WriteFile(file, byteValue, 0644)
+ if err != nil {
+ return errors.New("cannot write file due to: " + err.Error())
+ }
+ return nil
+}
+
+func (f *File) WriteNewE2TInstance(file string, E2TInst *rtmgr.E2TInstance, meiddata string) error {
+ xapp.Logger.Debug("Invoked sdl.WriteNewE2TInstance")
+ xapp.Logger.Debug("file.WriteNewE2TInstance writes into file: " + file)
+ xapp.Logger.Debug("file.WriteNewE2TInstance writes data: %v", *E2TInst)
+
+ ricData, err := NewFile().ReadAll(file)
+ if err != nil {
+ xapp.Logger.Error("cannot get data from sdl interface due to: " + err.Error())
+ return errors.New("cannot read full ric data to modify xApps data, due to: " + err.Error())
+ }
+ ricData.E2Ts[E2TInst.Fqdn] = *E2TInst
+ if len(meiddata) > 0 {
+ ricData.MeidMap = append(ricData.MeidMap, meiddata)
+ }
+ /*{
+ ricData.MeidMap = []string {meiddata}
+ }
+ else {
+ ricData.MeidMap = []string {}
+ }*/
+
+ byteValue, err := json.Marshal(ricData)
+ if err != nil {
+ return errors.New("cannot convert data due to: " + err.Error())
+ }
+ err = ioutil.WriteFile(file, byteValue, 0644)
+ if err != nil {
+ return errors.New("cannot write file due to: " + err.Error())
+ }
+ return nil
+}
+
+func (f *File) WriteAssRANToE2TInstance(file string, rane2tmap models.RanE2tMap) error {
+ xapp.Logger.Debug("Invoked sdl.WriteAssRANToE2TInstance")
+ xapp.Logger.Debug("file.WriteAssRANToE2TInstance writes into file: " + file)
+ xapp.Logger.Debug("file.WriteAssRANToE2TInstance writes data: %v", rane2tmap)
+
+ ricData, err := NewFile().ReadAll(file)
+ if err != nil {
+ xapp.Logger.Error("cannot get data from sdl interface due to: " + err.Error())
+ return errors.New("cannot read full ric data to modify xApps data, due to: " + err.Error())
+ }
+
+ //ricData.MeidMap = []string{}
+ for _, element := range rane2tmap {
+ xapp.Logger.Info("data received")
+ var str, meidar string
+ for _, meid := range element.RanNamelist {
+ meidar += meid + " "
+ }
+ str = "mme_ar|" + *element.E2TAddress + "|" + strings.TrimSuffix(meidar, " ")
+ ricData.MeidMap = append(ricData.MeidMap, str)
+
+ for key, _ := range ricData.E2Ts {
+ if key == *element.E2TAddress {
+ var estObj rtmgr.E2TInstance
+ estObj = ricData.E2Ts[key]
+ estObj.Ranlist = append(ricData.E2Ts[key].Ranlist, element.RanNamelist...)
+ ricData.E2Ts[key] = estObj
+ }
+ }
+ }
+
+ byteValue, err := json.Marshal(ricData)
+ if err != nil {
+ return errors.New("cannot convert data due to: " + err.Error())
+ }
+ err = ioutil.WriteFile(file, byteValue, 0644)
+ if err != nil {
+ return errors.New("cannot write file due to: " + err.Error())
+ }
+ return nil
+}
+
+func (f *File) WriteDisAssRANFromE2TInstance(file string, disassranmap models.RanE2tMap) error {
+ xapp.Logger.Debug("Invoked sdl.WriteDisAssRANFromE2TInstance")
+ xapp.Logger.Debug("file.WriteDisAssRANFromE2TInstance writes into file: " + file)
+ xapp.Logger.Debug("file.WriteDisAssRANFromE2TInstance writes data: %v", disassranmap)