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 | |
| 19 | This source code is part of the near-RT RIC (RAN Intelligent Controller) |
| 20 | platform project (RICP). |
| 21 | |
Balint Uveges | 871fa39 | 2019-04-02 20:31:11 +0000 | [diff] [blame] | 22 | ================================================================================== |
| 23 | */ |
| 24 | /* |
| 25 | Mnemonic: rmr.go |
| 26 | Abstract: RMR Route Policy implementation |
| 27 | Produces RMR (RIC Management Routing) formatted route messages |
| 28 | Date: 16 March 2019 |
| 29 | */ |
| 30 | |
| 31 | package rpe |
| 32 | |
Peter Szilagyi | 16d84d6 | 2019-04-24 14:51:02 +0000 | [diff] [blame] | 33 | import ( |
wahidw | a8596ec | 2019-12-05 06:30:42 +0000 | [diff] [blame] | 34 | "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp" |
kalnagy | 9216265 | 2019-07-02 15:15:49 +0200 | [diff] [blame] | 35 | "routing-manager/pkg/rtmgr" |
Peter Szilagyi | 16d84d6 | 2019-04-24 14:51:02 +0000 | [diff] [blame] | 36 | "strconv" |
prabhukaliswamy | e110ee0 | 2019-12-23 09:51:01 +0000 | [diff] [blame] | 37 | "strings" |
Peter Szilagyi | 16d84d6 | 2019-04-24 14:51:02 +0000 | [diff] [blame] | 38 | ) |
Balint Uveges | 871fa39 | 2019-04-02 20:31:11 +0000 | [diff] [blame] | 39 | |
kalnagy | 9216265 | 2019-07-02 15:15:49 +0200 | [diff] [blame] | 40 | type Rmr struct { |
| 41 | Rpe |
| 42 | } |
| 43 | |
kalnagy | 9216265 | 2019-07-02 15:15:49 +0200 | [diff] [blame] | 44 | type RmrPush struct { |
| 45 | Rmr |
| 46 | } |
| 47 | |
kalnagy | 9216265 | 2019-07-02 15:15:49 +0200 | [diff] [blame] | 48 | func NewRmrPush() *RmrPush { |
| 49 | instance := new(RmrPush) |
| 50 | return instance |
| 51 | } |
| 52 | |
Balint Uveges | 871fa39 | 2019-04-02 20:31:11 +0000 | [diff] [blame] | 53 | /* |
| 54 | Produces the raw route message consumable by RMR |
| 55 | */ |
prabhukaliswamy | e110ee0 | 2019-12-23 09:51:01 +0000 | [diff] [blame] | 56 | func (r *Rmr) generateRMRPolicies(eps rtmgr.Endpoints, rcs *rtmgr.RicComponents, key string) *[]string { |
Balint Uveges | 871fa39 | 2019-04-02 20:31:11 +0000 | [diff] [blame] | 57 | rawrt := []string{key + "newrt|start\n"} |
zkoczka | eb2ff0d | 2019-09-26 16:59:54 +0200 | [diff] [blame] | 58 | rt := r.generateRouteTable(eps) |
Balint Uveges | 871fa39 | 2019-04-02 20:31:11 +0000 | [diff] [blame] | 59 | for _, rte := range *rt { |
1000044 | e90ddda | 2019-08-01 09:58:52 +0200 | [diff] [blame] | 60 | rawrte := key + "mse|" + rte.MessageType |
Balint Uveges | 871fa39 | 2019-04-02 20:31:11 +0000 | [diff] [blame] | 61 | for _, tx := range rte.TxList { |
Peter Szilagyi | 16d84d6 | 2019-04-24 14:51:02 +0000 | [diff] [blame] | 62 | rawrte += "," + tx.Ip + ":" + strconv.Itoa(int(tx.Port)) |
Balint Uveges | 871fa39 | 2019-04-02 20:31:11 +0000 | [diff] [blame] | 63 | } |
kalnagy | 9216265 | 2019-07-02 15:15:49 +0200 | [diff] [blame] | 64 | rawrte += "|" + strconv.Itoa(int(rte.SubID)) + "|" |
Balint Uveges | 871fa39 | 2019-04-02 20:31:11 +0000 | [diff] [blame] | 65 | group := "" |
| 66 | for _, rxg := range rte.RxGroups { |
| 67 | member := "" |
| 68 | for _, rx := range rxg { |
| 69 | if member == "" { |
Peter Szilagyi | 16d84d6 | 2019-04-24 14:51:02 +0000 | [diff] [blame] | 70 | member += rx.Ip + ":" + strconv.Itoa(int(rx.Port)) |
Balint Uveges | 871fa39 | 2019-04-02 20:31:11 +0000 | [diff] [blame] | 71 | } else { |
Peter Szilagyi | 16d84d6 | 2019-04-24 14:51:02 +0000 | [diff] [blame] | 72 | member += "," + rx.Ip + ":" + strconv.Itoa(int(rx.Port)) |
Balint Uveges | 871fa39 | 2019-04-02 20:31:11 +0000 | [diff] [blame] | 73 | } |
| 74 | } |
| 75 | if group == "" { |
| 76 | group += member |
| 77 | } else { |
| 78 | group += ";" + member |
| 79 | } |
| 80 | } |
| 81 | rawrte += group |
rangajal | 749099b | 2019-12-10 09:37:08 +0000 | [diff] [blame] | 82 | |
| 83 | if (rte.RouteType == "%meid") { |
| 84 | rawrte += group + rte.RouteType |
| 85 | } |
| 86 | |
Balint Uveges | 871fa39 | 2019-04-02 20:31:11 +0000 | [diff] [blame] | 87 | rawrt = append(rawrt, rawrte+"\n") |
| 88 | } |
| 89 | rawrt = append(rawrt, key+"newrt|end\n") |
rangajal | 749099b | 2019-12-10 09:37:08 +0000 | [diff] [blame] | 90 | count := 0 |
prabhukaliswamy | e110ee0 | 2019-12-23 09:51:01 +0000 | [diff] [blame] | 91 | meidrt := key +"meid_map|start\n" |
| 92 | for e2tkey, value := range rcs.E2Ts { |
| 93 | xapp.Logger.Debug("rmr.E2T Key: %v", e2tkey) |
| 94 | xapp.Logger.Debug("rmr.E2T Value: %v", value) |
| 95 | xapp.Logger.Debug("rmr.E2T RAN List: %v", rcs.E2Ts[e2tkey].Ranlist) |
| 96 | if ( len(rcs.E2Ts[e2tkey].Ranlist) != 0 ) { |
| 97 | ranList := strings.Join(rcs.E2Ts[e2tkey].Ranlist, " ") |
| 98 | meidrt += key + "mme_ar|" + e2tkey + "|" + ranList + "\n" |
| 99 | count++ |
| 100 | } else { |
| 101 | xapp.Logger.Debug("rmr.E2T Empty RAN LIST for FQDN: %v", e2tkey) |
| 102 | } |
| 103 | } |
| 104 | meidrt += key+"meid_map|end|" + strconv.Itoa(count) +"\n" |
rangajal | 749099b | 2019-12-10 09:37:08 +0000 | [diff] [blame] | 105 | |
prabhukaliswamy | e110ee0 | 2019-12-23 09:51:01 +0000 | [diff] [blame] | 106 | rawrt = append(rawrt, meidrt) |
wahidw | a8596ec | 2019-12-05 06:30:42 +0000 | [diff] [blame] | 107 | xapp.Logger.Debug("rmr.GeneratePolicies returns: %v", rawrt) |
prabhukaliswamy | e110ee0 | 2019-12-23 09:51:01 +0000 | [diff] [blame] | 108 | xapp.Logger.Debug("rmr.GeneratePolicies returns: %v", rcs) |
Balint Uveges | 871fa39 | 2019-04-02 20:31:11 +0000 | [diff] [blame] | 109 | return &rawrt |
| 110 | } |
Peter Szilagyi | 16d84d6 | 2019-04-24 14:51:02 +0000 | [diff] [blame] | 111 | |
prabhukaliswamy | e110ee0 | 2019-12-23 09:51:01 +0000 | [diff] [blame] | 112 | func (r *RmrPush) GeneratePolicies(eps rtmgr.Endpoints, rcs *rtmgr.RicComponents) *[]string { |
wahidw | a8596ec | 2019-12-05 06:30:42 +0000 | [diff] [blame] | 113 | xapp.Logger.Debug("Invoked rmr.GeneratePolicies, args: %v: ", eps) |
prabhukaliswamy | e110ee0 | 2019-12-23 09:51:01 +0000 | [diff] [blame] | 114 | return r.generateRMRPolicies(eps, rcs, "") |
Peter Szilagyi | 16d84d6 | 2019-04-24 14:51:02 +0000 | [diff] [blame] | 115 | } |
kalnagy | 9216265 | 2019-07-02 15:15:49 +0200 | [diff] [blame] | 116 | |
zkoczka | eb2ff0d | 2019-09-26 16:59:54 +0200 | [diff] [blame] | 117 | func (r *RmrPush) GenerateRouteTable(eps rtmgr.Endpoints) *rtmgr.RouteTable { |
| 118 | return r.generateRouteTable(eps) |
kalnagy | 9216265 | 2019-07-02 15:15:49 +0200 | [diff] [blame] | 119 | } |