2 ==================================================================================
3 Copyright (c) 2019 AT&T Intellectual Property.
4 Copyright (c) 2019 Nokia
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
10 http://www.apache.org/licenses/LICENSE-2.0
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.
18 This source code is part of the near-RT RIC (RAN Intelligent Controller)
19 platform project (RICP).
21 ==================================================================================
24 Mnemonic: rtmgr/rtmgr.go
25 Abstract: Contains RTMGR (Routing Manager) module's generic variables and functions
34 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
35 "github.com/ghodss/yaml"
44 PrsCfg *PlatformRoutes
46 DynamicRouteList []string
47 RMRConnStatus map[string]bool
50 func GetPlatformComponents(configfile string) (*PlatformComponents, error) {
51 xapp.Logger.Debug("Invoked rtmgr.GetPlatformComponents(" + configfile + ")")
53 var rtroutes RtmgrRoutes
54 var mtypes MessageTypeIdentifier
55 yamlFile, err := os.Open(configfile)
57 return nil, errors.New("cannot open the file due to: " + err.Error())
59 defer yamlFile.Close()
60 byteValue, err := ioutil.ReadAll(yamlFile)
62 return nil, errors.New("cannot read the file due to: " + err.Error())
64 jsonByteValue, err := yaml.YAMLToJSON(byteValue)
66 return nil, errors.New("cannot read the file due to: " + err.Error())
68 err = json.Unmarshal(jsonByteValue, &rtroutes)
70 return nil, errors.New("cannot parse data due to: " + err.Error())
72 PrsCfg = &(rtroutes.Prs)
74 err = json.Unmarshal(jsonByteValue, &mtypes)
76 return nil, errors.New("cannot parse data due to: " + err.Error())
78 xapp.Logger.Debug("Messgaetypes = %v", mtypes)
79 for _, m := range mtypes.Mit {
80 splitstr := strings.Split(m, "=")
81 Mtype[splitstr[0]] = splitstr[1]
84 err = json.Unmarshal(jsonByteValue, &rcfg)
86 return nil, errors.New("cannot parse data due to: " + err.Error())
88 xapp.Logger.Debug("Platform components read from the configfile: %v", rcfg.Pcs)
89 return &(rcfg.Pcs), nil