Balint Uveges | 871fa39 | 2019-04-02 20:31:11 +0000 | [diff] [blame] | 1 | /* |
| 2 | ================================================================================== |
| 3 | Copyright (c) 2019 AT&T Intellectual Property. |
| 4 | Copyright (c) 2019 Nokia |
| 5 | |
| 6 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | you may not use this file except in compliance with the License. |
| 8 | You may obtain a copy of the License at |
| 9 | |
| 10 | http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | |
| 12 | Unless required by applicable law or agreed to in writing, software |
| 13 | distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | See the License for the specific language governing permissions and |
| 16 | limitations under the License. |
wahidw | 761934a | 2019-11-27 06:07:26 +0000 | [diff] [blame] | 17 | |
| 18 | This source code is part of the near-RT RIC (RAN Intelligent Controller) |
| 19 | platform project (RICP). |
| 20 | |
Balint Uveges | 871fa39 | 2019-04-02 20:31:11 +0000 | [diff] [blame] | 21 | ================================================================================== |
| 22 | */ |
| 23 | /* |
| 24 | Mnemonic: file.go |
| 25 | Abstract: File SDL implementation. Only for testing purpose. |
| 26 | Date: 16 March 2019 |
| 27 | */ |
| 28 | |
| 29 | package sdl |
| 30 | |
| 31 | import ( |
| 32 | "encoding/json" |
| 33 | "errors" |
wahidw | a8596ec | 2019-12-05 06:30:42 +0000 | [diff] [blame] | 34 | "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp" |
Balint Uveges | 871fa39 | 2019-04-02 20:31:11 +0000 | [diff] [blame] | 35 | "io/ioutil" |
| 36 | "os" |
prabhukaliswamy | e110ee0 | 2019-12-23 09:51:01 +0000 | [diff] [blame] | 37 | "routing-manager/pkg/models" |
wahidw | 0770de6 | 2021-04-30 13:58:07 +0000 | [diff] [blame] | 38 | "routing-manager/pkg/rtmgr" |
| 39 | "strings" |
Balint Uveges | 871fa39 | 2019-04-02 20:31:11 +0000 | [diff] [blame] | 40 | ) |
| 41 | |
| 42 | /* |
| 43 | Reads the content of the rt.json file |
| 44 | Parses the JSON content and loads each xApp entry into an xApp object |
| 45 | Returns an array os xApp object |
| 46 | */ |
kalnagy | 9216265 | 2019-07-02 15:15:49 +0200 | [diff] [blame] | 47 | |
| 48 | type File struct { |
| 49 | Sdl |
| 50 | } |
| 51 | |
| 52 | func NewFile() *File { |
| 53 | instance := new(File) |
| 54 | return instance |
| 55 | } |
| 56 | |
| 57 | func (f *File) ReadAll(file string) (*rtmgr.RicComponents, error) { |
wahidw | a8596ec | 2019-12-05 06:30:42 +0000 | [diff] [blame] | 58 | xapp.Logger.Debug("Invoked sdl.ReadAll(" + file + ")") |
kalnagy | 9216265 | 2019-07-02 15:15:49 +0200 | [diff] [blame] | 59 | var rcs *rtmgr.RicComponents |
Balint Uveges | 871fa39 | 2019-04-02 20:31:11 +0000 | [diff] [blame] | 60 | jsonFile, err := os.Open(file) |
| 61 | if err != nil { |
wahidw | 2bff80d | 2021-10-15 02:34:33 +0000 | [diff] [blame] | 62 | return nil, errors.New("Cannot open the file due to: " + err.Error()) |
Balint Uveges | 871fa39 | 2019-04-02 20:31:11 +0000 | [diff] [blame] | 63 | } |
| 64 | defer jsonFile.Close() |
| 65 | byteValue, err := ioutil.ReadAll(jsonFile) |
| 66 | if err != nil { |
| 67 | return nil, errors.New("cannot read the file due to: " + err.Error()) |
| 68 | } |
prabhukaliswamy | e110ee0 | 2019-12-23 09:51:01 +0000 | [diff] [blame] | 69 | |
kalnagy | 9216265 | 2019-07-02 15:15:49 +0200 | [diff] [blame] | 70 | err = json.Unmarshal(byteValue, &rcs) |
Balint Uveges | 871fa39 | 2019-04-02 20:31:11 +0000 | [diff] [blame] | 71 | if err != nil { |
| 72 | return nil, errors.New("cannot parse data due to: " + err.Error()) |
| 73 | } |
wahidw | a8596ec | 2019-12-05 06:30:42 +0000 | [diff] [blame] | 74 | xapp.Logger.Debug("file.fileReadAll returns: %v", rcs) |
kalnagy | 9216265 | 2019-07-02 15:15:49 +0200 | [diff] [blame] | 75 | return rcs, nil |
Balint Uveges | 871fa39 | 2019-04-02 20:31:11 +0000 | [diff] [blame] | 76 | } |
| 77 | |
kalnagy | 9216265 | 2019-07-02 15:15:49 +0200 | [diff] [blame] | 78 | func (f *File) WriteAll(file string, rcs *rtmgr.RicComponents) error { |
wahidw | 2bff80d | 2021-10-15 02:34:33 +0000 | [diff] [blame] | 79 | xapp.Logger.Debug("Invoked sdl.WriteAll:" + file + ", file.fileWriteAll writes data: %v", *rcs ) |
kalnagy | 9216265 | 2019-07-02 15:15:49 +0200 | [diff] [blame] | 80 | byteValue, err := json.Marshal(rcs) |
| 81 | if err != nil { |
wahidw | 2bff80d | 2021-10-15 02:34:33 +0000 | [diff] [blame] | 82 | return errors.New("Cannot convert data due to: " + err.Error()) |
kalnagy | 9216265 | 2019-07-02 15:15:49 +0200 | [diff] [blame] | 83 | } |
| 84 | err = ioutil.WriteFile(file, byteValue, 0644) |
| 85 | if err != nil { |
| 86 | return errors.New("cannot write file due to: " + err.Error()) |
| 87 | } |
| 88 | return nil |
| 89 | } |
| 90 | |
zkoczka | aaf8d39 | 2019-10-02 17:16:06 +0200 | [diff] [blame] | 91 | func (f *File) WriteXApps(file string, xApps *[]rtmgr.XApp) error { |
wahidw | 2bff80d | 2021-10-15 02:34:33 +0000 | [diff] [blame] | 92 | xapp.Logger.Debug("Invoked sdl.WriteXApps: " + file + ", file.fileWriteXApps writes data: %v", *xApps ) |
kalnagy | 9216265 | 2019-07-02 15:15:49 +0200 | [diff] [blame] | 93 | |
| 94 | ricData, err := NewFile().ReadAll(file) |
zkoczka | aaf8d39 | 2019-10-02 17:16:06 +0200 | [diff] [blame] | 95 | if err != nil { |
wahidw | 2bff80d | 2021-10-15 02:34:33 +0000 | [diff] [blame] | 96 | xapp.Logger.Error("Cannot get data from sdl interface due to: " + err.Error()) |
| 97 | return errors.New("Cannot read full ric data to modify xApps data, due to: " + err.Error()) |
kalnagy | 9216265 | 2019-07-02 15:15:49 +0200 | [diff] [blame] | 98 | } |
zkoczka | aaf8d39 | 2019-10-02 17:16:06 +0200 | [diff] [blame] | 99 | ricData.XApps = *xApps |
kalnagy | 9216265 | 2019-07-02 15:15:49 +0200 | [diff] [blame] | 100 | |
| 101 | byteValue, err := json.Marshal(ricData) |
Balint Uveges | 871fa39 | 2019-04-02 20:31:11 +0000 | [diff] [blame] | 102 | if err != nil { |
| 103 | return errors.New("cannot convert data due to: " + err.Error()) |
| 104 | } |
| 105 | err = ioutil.WriteFile(file, byteValue, 0644) |
| 106 | if err != nil { |
| 107 | return errors.New("cannot write file due to: " + err.Error()) |
| 108 | } |
| 109 | return nil |
| 110 | } |
rangajal | 749099b | 2019-12-10 09:37:08 +0000 | [diff] [blame] | 111 | |
wahidw | 0770de6 | 2021-04-30 13:58:07 +0000 | [diff] [blame] | 112 | func (f *File) WriteNewE2TInstance(file string, E2TInst *rtmgr.E2TInstance, meiddata string) error { |
wahidw | 2bff80d | 2021-10-15 02:34:33 +0000 | [diff] [blame] | 113 | xapp.Logger.Debug("Invoked sdl.WriteNewE2TInstance: " + file + ", file.WriteNewE2TInstance writes data: %v", *E2TInst ) |
rangajal | 749099b | 2019-12-10 09:37:08 +0000 | [diff] [blame] | 114 | |
wahidw | 0770de6 | 2021-04-30 13:58:07 +0000 | [diff] [blame] | 115 | ricData, err := NewFile().ReadAll(file) |
wahidw | 2bff80d | 2021-10-15 02:34:33 +0000 | [diff] [blame] | 116 | if err != nil { |
| 117 | xapp.Logger.Error("Cannot get data from sdl interface due to: " + err.Error()) |
| 118 | return errors.New("cannot read full ric data to modify xApps data due to: " + err.Error()) |
wahidw | 51db012 | 2020-01-12 04:24:29 +0000 | [diff] [blame] | 119 | } |
wahidw | 0770de6 | 2021-04-30 13:58:07 +0000 | [diff] [blame] | 120 | ricData.E2Ts[E2TInst.Fqdn] = *E2TInst |
| 121 | if len(meiddata) > 0 { |
| 122 | ricData.MeidMap = append(ricData.MeidMap, meiddata) |
| 123 | } |
| 124 | /*{ |
| 125 | ricData.MeidMap = []string {meiddata} |
| 126 | } |
| 127 | else { |
| 128 | ricData.MeidMap = []string {} |
| 129 | }*/ |
wahidw | 51db012 | 2020-01-12 04:24:29 +0000 | [diff] [blame] | 130 | |
wahidw | 0770de6 | 2021-04-30 13:58:07 +0000 | [diff] [blame] | 131 | byteValue, err := json.Marshal(ricData) |
| 132 | if err != nil { |
| 133 | return errors.New("cannot convert data due to: " + err.Error()) |
| 134 | } |
| 135 | err = ioutil.WriteFile(file, byteValue, 0644) |
| 136 | if err != nil { |
| 137 | return errors.New("cannot write file due to: " + err.Error()) |
| 138 | } |
| 139 | return nil |
rangajal | 749099b | 2019-12-10 09:37:08 +0000 | [diff] [blame] | 140 | } |
prabhukaliswamy | e110ee0 | 2019-12-23 09:51:01 +0000 | [diff] [blame] | 141 | |
| 142 | func (f *File) WriteAssRANToE2TInstance(file string, rane2tmap models.RanE2tMap) error { |
wahidw | 2bff80d | 2021-10-15 02:34:33 +0000 | [diff] [blame] | 143 | xapp.Logger.Debug("Invoked sdl.WriteAssRANToE2TInstance: " + file + ", file.WriteAssRANToE2TInstance writes data: %v", rane2tmap) |
prabhukaliswamy | e110ee0 | 2019-12-23 09:51:01 +0000 | [diff] [blame] | 144 | |
wahidw | 0770de6 | 2021-04-30 13:58:07 +0000 | [diff] [blame] | 145 | ricData, err := NewFile().ReadAll(file) |
| 146 | if err != nil { |
wahidw | 2bff80d | 2021-10-15 02:34:33 +0000 | [diff] [blame] | 147 | xapp.Logger.Error("Cannot get data from sdl interface due to: " + err.Error()) |
| 148 | return errors.New("cannot read full ric data to modify xApps data due to: " + err.Error()) |
wahidw | 0770de6 | 2021-04-30 13:58:07 +0000 | [diff] [blame] | 149 | } |
wahidw | 51db012 | 2020-01-12 04:24:29 +0000 | [diff] [blame] | 150 | |
wahidw | 0770de6 | 2021-04-30 13:58:07 +0000 | [diff] [blame] | 151 | //ricData.MeidMap = []string{} |
prabhukaliswamy | e110ee0 | 2019-12-23 09:51:01 +0000 | [diff] [blame] | 152 | for _, element := range rane2tmap { |
wahidw | 2bff80d | 2021-10-15 02:34:33 +0000 | [diff] [blame] | 153 | xapp.Logger.Info("Data received") |
wahidw | 0770de6 | 2021-04-30 13:58:07 +0000 | [diff] [blame] | 154 | var str, meidar string |
wahidw | 51db012 | 2020-01-12 04:24:29 +0000 | [diff] [blame] | 155 | for _, meid := range element.RanNamelist { |
wahidw | 0770de6 | 2021-04-30 13:58:07 +0000 | [diff] [blame] | 156 | meidar += meid + " " |
wahidw | 51db012 | 2020-01-12 04:24:29 +0000 | [diff] [blame] | 157 | } |
wahidw | 0770de6 | 2021-04-30 13:58:07 +0000 | [diff] [blame] | 158 | str = "mme_ar|" + *element.E2TAddress + "|" + strings.TrimSuffix(meidar, " ") |
| 159 | ricData.MeidMap = append(ricData.MeidMap, str) |
wahidw | 51db012 | 2020-01-12 04:24:29 +0000 | [diff] [blame] | 160 | |
prabhukaliswamy | e110ee0 | 2019-12-23 09:51:01 +0000 | [diff] [blame] | 161 | for key, _ := range ricData.E2Ts { |
| 162 | if key == *element.E2TAddress { |
| 163 | var estObj rtmgr.E2TInstance |
| 164 | estObj = ricData.E2Ts[key] |
| 165 | estObj.Ranlist = append(ricData.E2Ts[key].Ranlist, element.RanNamelist...) |
wahidw | 0770de6 | 2021-04-30 13:58:07 +0000 | [diff] [blame] | 166 | ricData.E2Ts[key] = estObj |
prabhukaliswamy | e110ee0 | 2019-12-23 09:51:01 +0000 | [diff] [blame] | 167 | } |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | byteValue, err := json.Marshal(ricData) |
wahidw | 0770de6 | 2021-04-30 13:58:07 +0000 | [diff] [blame] | 172 | if err != nil { |
| 173 | return errors.New("cannot convert data due to: " + err.Error()) |
| 174 | } |
| 175 | err = ioutil.WriteFile(file, byteValue, 0644) |
| 176 | if err != nil { |
| 177 | return errors.New("cannot write file due to: " + err.Error()) |
| 178 | } |
| 179 | return nil |
prabhukaliswamy | e110ee0 | 2019-12-23 09:51:01 +0000 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | func (f *File) WriteDisAssRANFromE2TInstance(file string, disassranmap models.RanE2tMap) error { |
wahidw | 2bff80d | 2021-10-15 02:34:33 +0000 | [diff] [blame] | 183 | xapp.Logger.Debug("Invoked sdl.WriteDisAssRANFromE2TInstance: " + file + ",file.WriteDisAssRANFromE2TInstance writes data: %v", disassranmap) |
prabhukaliswamy | e110ee0 | 2019-12-23 09:51:01 +0000 | [diff] [blame] | 184 | |
wahidw | 0770de6 | 2021-04-30 13:58:07 +0000 | [diff] [blame] | 185 | ricData, err := NewFile().ReadAll(file) |
| 186 | if err != nil { |
wahidw | 2bff80d | 2021-10-15 02:34:33 +0000 | [diff] [blame] | 187 | xapp.Logger.Error("Cannot get data from sdl interface due to: " + err.Error()) |
| 188 | return errors.New("cannot read full ric data to modify xApps data due to: " + err.Error()) |
wahidw | 0770de6 | 2021-04-30 13:58:07 +0000 | [diff] [blame] | 189 | } |
wahidw | 51db012 | 2020-01-12 04:24:29 +0000 | [diff] [blame] | 190 | |
wahidw | 0770de6 | 2021-04-30 13:58:07 +0000 | [diff] [blame] | 191 | var str, meiddel, meiddisdel string |
| 192 | //ricData.MeidMap = []string{} |
prabhukaliswamy | e110ee0 | 2019-12-23 09:51:01 +0000 | [diff] [blame] | 193 | for _, element := range disassranmap { |
wahidw | 2bff80d | 2021-10-15 02:34:33 +0000 | [diff] [blame] | 194 | xapp.Logger.Info("Data received") |
wahidw | 51db012 | 2020-01-12 04:24:29 +0000 | [diff] [blame] | 195 | for _, meid := range element.RanNamelist { |
wahidw | 0770de6 | 2021-04-30 13:58:07 +0000 | [diff] [blame] | 196 | meiddisdel += meid + " " |
wahidw | 51db012 | 2020-01-12 04:24:29 +0000 | [diff] [blame] | 197 | } |
wahidw | 0770de6 | 2021-04-30 13:58:07 +0000 | [diff] [blame] | 198 | if len(element.RanNamelist) > 0 { |
| 199 | str = "mme_del|" + strings.TrimSuffix(meiddisdel, " ") |
| 200 | ricData.MeidMap = append(ricData.MeidMap, str) |
| 201 | } |
prabhukaliswamy | e110ee0 | 2019-12-23 09:51:01 +0000 | [diff] [blame] | 202 | e2taddress_key := *element.E2TAddress |
wahidw | 0770de6 | 2021-04-30 13:58:07 +0000 | [diff] [blame] | 203 | //Check whether the provided E2T Address is available in SDL as a key. |
prabhukaliswamy | e110ee0 | 2019-12-23 09:51:01 +0000 | [diff] [blame] | 204 | //If exist, proceed further to check RAN list, Otherwise move to next E2T Instance |
| 205 | if _, exist := ricData.E2Ts[e2taddress_key]; exist { |
| 206 | var estObj rtmgr.E2TInstance |
| 207 | estObj = ricData.E2Ts[e2taddress_key] |
| 208 | // If RAN list is empty, then routing manager assumes that all RANs attached associated to the particular E2T Instance to be removed. |
| 209 | if len(element.RanNamelist) == 0 { |
| 210 | xapp.Logger.Debug("RAN List is empty. So disassociating all RANs from the E2T Instance: %v ", *element.E2TAddress) |
wahidw | 0770de6 | 2021-04-30 13:58:07 +0000 | [diff] [blame] | 211 | for _, meid := range estObj.Ranlist { |
| 212 | meiddel += meid + " " |
| 213 | } |
| 214 | str = "mme_del|" + strings.TrimSuffix(meiddel, " ") |
| 215 | ricData.MeidMap = append(ricData.MeidMap, str) |
wahidw | 51db012 | 2020-01-12 04:24:29 +0000 | [diff] [blame] | 216 | |
wahidw | 0770de6 | 2021-04-30 13:58:07 +0000 | [diff] [blame] | 217 | estObj.Ranlist = []string{} |
prabhukaliswamy | e110ee0 | 2019-12-23 09:51:01 +0000 | [diff] [blame] | 218 | } else { |
| 219 | xapp.Logger.Debug("Remove only selected rans from E2T Instance: %v and %v ", ricData.E2Ts[e2taddress_key].Ranlist, element.RanNamelist) |
| 220 | for _, disRanValue := range element.RanNamelist { |
| 221 | for ranIndex, ranValue := range ricData.E2Ts[e2taddress_key].Ranlist { |
| 222 | if disRanValue == ranValue { |
| 223 | estObj.Ranlist[ranIndex] = estObj.Ranlist[len(estObj.Ranlist)-1] |
| 224 | estObj.Ranlist[len(estObj.Ranlist)-1] = "" |
| 225 | estObj.Ranlist = estObj.Ranlist[:len(estObj.Ranlist)-1] |
| 226 | } |
| 227 | } |
| 228 | } |
| 229 | } |
wahidw | 0770de6 | 2021-04-30 13:58:07 +0000 | [diff] [blame] | 230 | ricData.E2Ts[e2taddress_key] = estObj |
prabhukaliswamy | e110ee0 | 2019-12-23 09:51:01 +0000 | [diff] [blame] | 231 | } |
| 232 | } |
| 233 | |
| 234 | xapp.Logger.Debug("Final data after disassociate: %v", ricData) |
| 235 | |
| 236 | byteValue, err := json.Marshal(ricData) |
wahidw | 0770de6 | 2021-04-30 13:58:07 +0000 | [diff] [blame] | 237 | if err != nil { |
| 238 | return errors.New("cannot convert data due to: " + err.Error()) |
| 239 | } |
| 240 | err = ioutil.WriteFile(file, byteValue, 0644) |
| 241 | if err != nil { |
| 242 | return errors.New("cannot write file due to: " + err.Error()) |
| 243 | } |
prabhukaliswamy | e110ee0 | 2019-12-23 09:51:01 +0000 | [diff] [blame] | 244 | return nil |
| 245 | } |
| 246 | |
| 247 | func (f *File) WriteDeleteE2TInstance(file string, E2TInst *models.E2tDeleteData) error { |
wahidw | 2bff80d | 2021-10-15 02:34:33 +0000 | [diff] [blame] | 248 | xapp.Logger.Debug("Invoked sdl.WriteDeleteE2TInstance: " + file + ",file.WriteDeleteE2TInstance writes data: %v", *E2TInst) |
prabhukaliswamy | e110ee0 | 2019-12-23 09:51:01 +0000 | [diff] [blame] | 249 | |
| 250 | ricData, err := NewFile().ReadAll(file) |
| 251 | if err != nil { |
wahidw | 2bff80d | 2021-10-15 02:34:33 +0000 | [diff] [blame] | 252 | xapp.Logger.Error("Cannot get data from sdl interface due to: " + err.Error()) |
| 253 | return errors.New("cannot read full ric data to modify xApps data due to: " + err.Error()) |
prabhukaliswamy | e110ee0 | 2019-12-23 09:51:01 +0000 | [diff] [blame] | 254 | } |
| 255 | |
wahidw | 0770de6 | 2021-04-30 13:58:07 +0000 | [diff] [blame] | 256 | //ricData.MeidMap = []string{} |
| 257 | var delrow, meiddel string |
| 258 | if len(E2TInst.RanNamelistTobeDissociated) > 0 { |
| 259 | for _, meid := range E2TInst.RanNamelistTobeDissociated { |
wahidw | 51db012 | 2020-01-12 04:24:29 +0000 | [diff] [blame] | 260 | meiddel += meid + " " |
| 261 | } |
wahidw | 0770de6 | 2021-04-30 13:58:07 +0000 | [diff] [blame] | 262 | delrow = "mme_del|" + strings.TrimSuffix(meiddel, " ") |
| 263 | ricData.MeidMap = append(ricData.MeidMap, delrow) |
wahidw | 51db012 | 2020-01-12 04:24:29 +0000 | [diff] [blame] | 264 | } else { |
wahidw | 0770de6 | 2021-04-30 13:58:07 +0000 | [diff] [blame] | 265 | if len(ricData.E2Ts[*E2TInst.E2TAddress].Ranlist) > 0 { |
| 266 | for _, meid := range ricData.E2Ts[*E2TInst.E2TAddress].Ranlist { |
| 267 | meiddel += meid + " " |
| 268 | } |
| 269 | delrow = "mme_del|" + strings.TrimSuffix(meiddel, " ") |
| 270 | ricData.MeidMap = append(ricData.MeidMap, delrow) |
| 271 | } |
wahidw | 51db012 | 2020-01-12 04:24:29 +0000 | [diff] [blame] | 272 | } |
| 273 | |
prabhukaliswamy | e110ee0 | 2019-12-23 09:51:01 +0000 | [diff] [blame] | 274 | delete(ricData.E2Ts, *E2TInst.E2TAddress) |
| 275 | |
prabhukaliswamy | e110ee0 | 2019-12-23 09:51:01 +0000 | [diff] [blame] | 276 | for _, element := range E2TInst.RanAssocList { |
wahidw | 0770de6 | 2021-04-30 13:58:07 +0000 | [diff] [blame] | 277 | var str, meidar string |
wahidw | 2bff80d | 2021-10-15 02:34:33 +0000 | [diff] [blame] | 278 | xapp.Logger.Info("Data received") |
wahidw | 51db012 | 2020-01-12 04:24:29 +0000 | [diff] [blame] | 279 | for _, meid := range element.RanNamelist { |
| 280 | meidar = meid + " " |
| 281 | } |
wahidw | 0770de6 | 2021-04-30 13:58:07 +0000 | [diff] [blame] | 282 | str = "mme_ar|" + *element.E2TAddress + "|" + strings.TrimSuffix(meidar, " ") |
| 283 | ricData.MeidMap = append(ricData.MeidMap, str) |
prabhukaliswamy | e110ee0 | 2019-12-23 09:51:01 +0000 | [diff] [blame] | 284 | key := *element.E2TAddress |
| 285 | |
| 286 | if val, ok := ricData.E2Ts[key]; ok { |
| 287 | var estObj rtmgr.E2TInstance |
| 288 | estObj = val |
| 289 | estObj.Ranlist = append(ricData.E2Ts[key].Ranlist, element.RanNamelist...) |
wahidw | 0770de6 | 2021-04-30 13:58:07 +0000 | [diff] [blame] | 290 | ricData.E2Ts[key] = estObj |
prabhukaliswamy | e110ee0 | 2019-12-23 09:51:01 +0000 | [diff] [blame] | 291 | } else { |
| 292 | xapp.Logger.Error("file.WriteDeleteE2TInstance E2T instance is not found for provided E2TAddress : %v", errors.New(key).Error()) |
| 293 | } |
| 294 | |
| 295 | } |
| 296 | |
| 297 | byteValue, err := json.Marshal(ricData) |
| 298 | if err != nil { |
wahidw | 0770de6 | 2021-04-30 13:58:07 +0000 | [diff] [blame] | 299 | return errors.New("cannot convert data due to: " + err.Error()) |
prabhukaliswamy | e110ee0 | 2019-12-23 09:51:01 +0000 | [diff] [blame] | 300 | } |
| 301 | err = ioutil.WriteFile(file, byteValue, 0644) |
| 302 | if err != nil { |
wahidw | 0770de6 | 2021-04-30 13:58:07 +0000 | [diff] [blame] | 303 | return errors.New("cannot write file due to: " + err.Error()) |
prabhukaliswamy | e110ee0 | 2019-12-23 09:51:01 +0000 | [diff] [blame] | 304 | } |
| 305 | return nil |
| 306 | } |