X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=pkg%2Frtmgr%2Frtmgr.go;h=3c4f4e58a8f9277a55106f02c869ae432e9efece;hb=87c46ef443a44730cfdcab1ba00b25f60825e037;hp=9dd956ed97d11d2c1681f4e44a2774104b5be619;hpb=16d84d6f7d3489e65e0a83ba9c0d5d62c3914c7f;p=ric-plt%2Frtmgr.git diff --git a/pkg/rtmgr/rtmgr.go b/pkg/rtmgr/rtmgr.go index 9dd956e..3c4f4e5 100644 --- a/pkg/rtmgr/rtmgr.go +++ b/pkg/rtmgr/rtmgr.go @@ -14,59 +14,77 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + + This source code is part of the near-RT RIC (RAN Intelligent Controller) + platform project (RICP). + ================================================================================== */ /* Mnemonic: rtmgr/rtmgr.go - Abstract: Containes RTMGR (Routing Manager) module's generic variables and functions + Abstract: Contains RTMGR (Routing Manager) module's generic variables and functions Date: 26 March 2019 */ package rtmgr import ( - "github.com/jcelliott/lumber" + "encoding/json" + "errors" + "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp" + "github.com/ghodss/yaml" + "io/ioutil" + "os" + "strings" ) var ( - //TODO: temporary solution - // CamelCase Message Types are for being able to test with old fashioned admin controll xApps - MESSAGETYPES = map[string]string{ - "HandoverPreparation": "0", - "HandoverCancel": "1", - "LoadIndication": "2", - "ErrorIndication": "3", - "SNStatusTransfer": "4", - "UEContextRelease": "5", - "X2Setup": "6", - "Reset": "7", - "RIC_X2_SETUP": "10000", - "RIC_X2_RESPONSE": "10001", - "RIC_X2_RESOURCE_STATUS_REQUEST": "10002", - "RIC_X2_RESOURCE_STATUS_RESPONSE": "10003", - "RIC_X2_LOAD_INFORMATION": "10004", - "RIC_E2_TERMINATION_HC_REQUEST": "10005", - "RIC_E2_TERMINATION_HC_RESPONSE": "10006", - "RIC_E2_MANAGER_HC_REQUEST": "10007", - "RIC_E2_MANAGER_HC_RESPONSE": "10008", - "RIC_CONTROL_XAPP_CONFIG_REQUEST": "100000", - "RIC_CONTROL_XAPP_CONFIG_RESPONSE": "100001", - } - Logger = lumber.NewConsoleLogger(lumber.INFO) - Eps Endpoints + Eps Endpoints + Subs SubscriptionList + PrsCfg *PlatformRoutes + Mtype MessageTypeList + DynamicRouteList []string + RMRConnStatus map[string]bool ) -func SetLogLevel(loglevel string) { - switch loglevel { - case "INFO": - Logger.Level(lumber.INFO) - case "WARN": - Logger.Level(lumber.WARN) - case "ERROR": - Logger.Level(lumber.ERROR) - case "DEBUG": - Logger.Info("debugmode") - Logger.Level(lumber.DEBUG) +func GetPlatformComponents(configfile string) (*PlatformComponents, error) { + xapp.Logger.Debug("Invoked rtmgr.GetPlatformComponents(" + configfile + ")") + var rcfg ConfigRtmgr + var rtroutes RtmgrRoutes + var mtypes MessageTypeIdentifier + yamlFile, err := os.Open(configfile) + if err != nil { + return nil, errors.New("cannot open the file due to: " + err.Error()) } -} + defer yamlFile.Close() + byteValue, err := ioutil.ReadAll(yamlFile) + if err != nil { + return nil, errors.New("cannot read the file due to: " + err.Error()) + } + jsonByteValue, err := yaml.YAMLToJSON(byteValue) + if err != nil { + return nil, errors.New("cannot read the file due to: " + err.Error()) + } + err = json.Unmarshal(jsonByteValue, &rtroutes) + if err != nil { + return nil, errors.New("cannot parse data due to: " + err.Error()) + } + PrsCfg = &(rtroutes.Prs) + err = json.Unmarshal(jsonByteValue, &mtypes) + if err != nil { + return nil, errors.New("cannot parse data due to: " + err.Error()) + } else { + xapp.Logger.Debug("Messgaetypes = %v", mtypes) + for _, m := range mtypes.Mit { + splitstr := strings.Split(m, "=") + Mtype[splitstr[0]] = splitstr[1] + } + } + err = json.Unmarshal(jsonByteValue, &rcfg) + if err != nil { + return nil, errors.New("cannot parse data due to: " + err.Error()) + } + xapp.Logger.Debug("Platform components read from the configfile: %v", rcfg.Pcs) + return &(rcfg.Pcs), nil +}