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"
42 //TODO: temporary solution
43 // CamelCase Message Types are for being able to test with old fashioned admin control xApps
44 // TODO: Add a separate message definition file (Not using the one from RMR to not create dependency on that library).
45 MessageTypes = map[string]string{
46 "HandoverPreparation": "0",
47 "HandoverCancel": "1",
48 "LoadIndication": "2",
49 "ErrorIndication": "3",
50 "SNStatusTransfer": "4",
51 "UEContextRelease": "5",
54 "E2_TERM_INIT": "1100",
55 "E2_TERM_KEEP_ALIVE_REQ": "1101",
56 "E2_TERM_KEEP_ALIVE_RESP": "1102",
57 "RAN_CONNECTED": "1200",
58 "RAN_RESTARTED": "1210",
59 "RAN_RECONFIGURED": "1220",
60 "RIC_SCTP_CLEAR_ALL": "1090",
61 "RIC_SCTP_CONNECTION_FAILURE": "1080",
62 "RIC_X2_SETUP": "10000",
63 "RIC_X2_RESPONSE": "10001",
64 "RIC_X2_RESOURCE_STATUS_REQUEST": "10002",
65 "RIC_X2_RESOURCE_STATUS_RESPONSE": "10003",
66 "RIC_X2_LOAD_INFORMATION": "10004",
67 "RIC_E2_TERMINATION_HC_REQUEST": "10005",
68 "RIC_E2_TERMINATION_HC_RESPONSE": "10006",
69 "RIC_E2_MANAGER_HC_REQUEST": "10007",
70 "RIC_E2_MANAGER_HC_RESPONSE": "10008",
71 "RIC_ENB_LOAD_INFORMATION": "10020",
72 "RIC_ERROR_INDICATION": "10030",
73 "RIC_X2_SETUP_REQ": "10060",
74 "RIC_X2_SETUP_RESP": "10061",
75 "RIC_X2_SETUP_FAILURE": "10062",
76 "RIC_X2_RESET_REQ": "10070",
77 "RIC_X2_RESET_RESP": "10071",
78 "RIC_ENB_CONF_UPDATE": "10080",
79 "RIC_ENB_CONF_UPDATE_ACK": "10081",
80 "RIC_ENB_CONF_UPDATE_FAILURE": "10082",
81 "RIC_RES_STATUS_REQ": "10090",
82 "RIC_RES_STATUS_RESP": "10091",
83 "RIC_RES_STATUS_FAILURE": "10092",
84 "RIC_RESOURCE_STATUS_UPDATE": "10100",
85 "RIC_ENDC_X2_SETUP_REQ": "10360",
86 "RIC_ENDC_X2_SETUP_RESP": "10361",
87 "RIC_ENDC_X2_SETUP_FAILURE": "10362",
88 "RIC_ENDC_CONF_UPDATE": "10370",
89 "RIC_ENDC_CONF_UPDATE_ACK": "10371",
90 "RIC_ENDC_CONF_UPDATE_FAILURE": "10372",
91 "RIC_GNB_STATUS_INDICATION": "10450",
92 "RIC_SUB_REQ": "12010",
93 "RIC_SUB_RESP": "12011",
94 "RIC_SUB_FAILURE": "12012",
95 "RIC_SUB_DEL_REQ": "12020",
96 "RIC_SUB_DEL_RESP": "12021",
97 "RIC_SUB_DEL_FAILURE": "12022",
98 "RIC_CONTROL_REQ": "12040",
99 "RIC_CONTROL_ACK": "12041",
100 "RIC_CONTROL_FAILURE": "12042",
101 "RIC_INDICATION": "12050",
102 "DC_ADM_INT_CONTROL": "20000",
103 "DC_ADM_INT_CONTROL_ACK": "20001",
104 "A1_POLICY_REQ": "20010",
105 "A1_POLICY_RESPONSE": "20011",
106 "A1_POLICY_QUERY": "20012",
107 "RIC_CONTROL_XAPP_CONFIG_REQUEST": "100000",
108 "RIC_CONTROL_XAPP_CONFIG_RESPONSE": "100001",
111 // Messagetype mappings for the platform components.
112 // This implements static default routes needed by the RIC. Needs to be changed in case new components/message types needes to be added/updated.
113 // Representation : {"componentName1": {"tx": <tx message type list>, "rx": <rx message type list>}}
114 PLATFORMMESSAGETYPES = map[string]map[string][]string{
115 "E2TERM": {"tx": []string{"RIC_X2_SETUP_REQ", "RIC_X2_SETUP_RESP", "RIC_X2_SETUP_FAILURE", "RIC_X2_RESET", "RIC_X2_RESET_RESP", "RIC_ENDC_X2_SETUP_REQ", "RIC_ENDC_X2_SETUP_RESP", "RIC_ENDC_X2_SETUP_FAILURE", "RIC_SUB_RESP", "RIC_SUB_FAILURE", "RIC_SUB_DEL_RESP", "RIC_SUB_DEL_FAILURE"}, "rx": []string{"RIC_X2_SETUP_REQ", "RIC_X2_SETUP_RESP", "RIC_X2_SETUP_FAILURE", "RIC_X2_RESET", "RIC_X2_RESET_RESP", "RIC_ENDC_X2_SETUP_REQ", "RIC_ENDC_X2_SETUP_RESP", "RIC_ENDC_X2_SETUP_FAILURE", "RIC_SUB_REQ", "RIC_SUB_DEL_REQ", "RIC_CONTROL_REQ"}},
116 "E2MAN": {"tx": []string{"RIC_X2_SETUP_REQ", "RIC_X2_SETUP_RESP", "RIC_X2_SETUP_FAILURE", "RIC_X2_RESET", "RIC_X2_RESET_RESP", "RIC_ENDC_X2_SETUP_REQ", "RIC_ENDC_X2_SETUP_RESP", "RIC_ENDC_X2_SETUP_FAILURE"}, "rx": []string{"RIC_X2_SETUP_REQ", "RIC_X2_SETUP_RESP", "RIC_X2_SETUP_FAILURE", "RIC_X2_RESET", "RIC_X2_RESET_RESP", "RIC_ENDC_X2_SETUP_REQ", "RIC_ENDC_X2_SETUP_RESP", "RIC_ENDC_X2_SETUP_FAILURE"}},
117 "SUBMAN": {"tx": []string{"RIC_SUB_REQ", "RIC_SUB_DEL_REQ"}, "rx": []string{"RIC_SUB_RESP", "RIC_SUB_FAILURE", "RIC_SUB_DEL_RESP", "RIC_SUB_DEL_FAILURE"}},
118 "UEMAN": {"tx": []string{"RIC_CONTROL_REQ"}, "rx": []string{}},
119 "RSM": {"tx": []string{"RIC_RES_STATUS_REQ"}, "rx": []string{"RAN_CONNECTED", "RAN_RESTARTED", "RAN_RECONFIGURED"}},
120 "A1MEDIATOR": {"tx": []string{}, "rx": []string{"A1_POLICY_QUERY", "A1_POLICY_RESPONSE"}},
124 Subs SubscriptionList
125 PrsCfg *PlatformRoutes
126 Mtype MessageTypeList
129 func GetPlatformComponents(configfile string) (*PlatformComponents, error) {
130 xapp.Logger.Debug("Invoked rtmgr.GetPlatformComponents(" + configfile + ")")
132 var rtroutes RtmgrRoutes
133 var mtypes MessageTypeIdentifier
134 yamlFile, err := os.Open(configfile)
136 return nil, errors.New("cannot open the file due to: " + err.Error())
138 defer yamlFile.Close()
139 byteValue, err := ioutil.ReadAll(yamlFile)
141 return nil, errors.New("cannot read the file due to: " + err.Error())
143 jsonByteValue, err := yaml.YAMLToJSON(byteValue)
145 return nil, errors.New("cannot read the file due to: " + err.Error())
147 err = json.Unmarshal(jsonByteValue,&rtroutes)
149 return nil, errors.New("cannot parse data due to: " + err.Error())
151 PrsCfg = &(rtroutes.Prs)
153 err = json.Unmarshal(jsonByteValue,&mtypes)
155 return nil, errors.New("cannot parse data due to: " + err.Error())
157 xapp.Logger.Debug("Messgaetypes = %v", mtypes)
158 for _,m := range mtypes.Mit {
159 splitstr := strings.Split(m,"=")
160 Mtype[splitstr[0]] = splitstr[1]
163 err = json.Unmarshal(jsonByteValue, &rcfg)
165 return nil, errors.New("cannot parse data due to: " + err.Error())
167 xapp.Logger.Debug("Platform components read from the configfile: %v", rcfg.Pcs)
168 return &(rcfg.Pcs), nil