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.
17 ==================================================================================
21 Abstract: Contains RPE (Route Policy Engine) module definitions and generic RPE components
35 SupportedRpes = []*RpeEngineConfig{
42 generatePolicies(generateRMRPolicies),
50 for _, rpe := range SupportedRpes {
52 rtmgr.Logger.Info(rpe.Engine.Name + "/" + rpe.Engine.Version)
57 func GetRpe(rpeName string) (*RpeEngineConfig, error) {
58 for _, rpe := range SupportedRpes {
59 if rpe.Engine.Name == rpeName && rpe.IsAvailable {
63 return nil, errors.New("SBI:" + rpeName + "is not supported or still not a available")
67 Gets the raw xApp list and generates the list of sender endpoints and receiver endpoint groups
68 Returns the Tx EndpointList map where the key is the messge type and also returns the nested map of Rx EndpointList's map where keys are message type and xapp type
69 Endpoint object's message type already transcoded to integer id
71 func getEndpointLists(xapps *[]rtmgr.XApp) (*map[string]rtmgr.EndpointList, *map[string]map[string]rtmgr.EndpointList) {
72 txlist := make(map[string]rtmgr.EndpointList)
73 rxgroups := make(map[string]map[string]rtmgr.EndpointList)
74 for _, xapp := range *xapps {
75 for _, instance := range xapp.Instances {
79 instance.Ip + ":" + strconv.Itoa(instance.Port),
81 for _, message := range instance.RxMessages {
82 messageid := rtmgr.MESSAGETYPES[message]
83 if _, ok := rxgroups[messageid]; !ok {
84 rxgroups[messageid] = make(map[string]rtmgr.EndpointList)
86 rxgroups[messageid][xapp.Name] = append(rxgroups[messageid][xapp.Name], ep)
88 for _, message := range instance.TxMessages {
89 messageid := rtmgr.MESSAGETYPES[message]
90 txlist[messageid] = append(txlist[messageid], ep)
94 return &txlist, &rxgroups
98 Gets the raw xapp list and creates a route table for
99 Returns the array of route table entries
101 func getRouteTable(xapps *[]rtmgr.XApp) *rtmgr.RouteTable {
102 tx, rx := getEndpointLists(xapps)
103 var rt rtmgr.RouteTable
104 for _, messagetype := range rtmgr.MESSAGETYPES {
105 if _, ok := (*tx)[messagetype]; !ok {
108 if _, ok := (*rx)[messagetype]; !ok {
111 var rxgroups []rtmgr.EndpointList
112 for _, endpointlist := range (*rx)[messagetype] {
113 rxgroups = append(rxgroups, endpointlist)
115 rte := rtmgr.RouteTableEntry{