3 ==================================================================================
4 Copyright (c) 2019 AT&T Intellectual Property.
5 Copyright (c) 2019 Nokia
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
11 http://www.apache.org/licenses/LICENSE-2.0
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
19 This source code is part of the near-RT RIC (RAN Intelligent Controller)
20 platform project (RICP).
22 ==================================================================================
26 Abstract: Contains SBI (SouthBound Interface) module definitions and generic SBI components
34 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
35 "routing-manager/pkg/rtmgr"
40 const DefaultNngPipelineSocketPrefix = "tcp://"
41 const DefaultNngPipelineSocketNumber = 4561
42 const PlatformType = "platform"
45 SupportedSbis = []*EngineConfig{
49 Protocol: "nngpipeline",
50 Instance: NewNngPush(),
56 func GetSbi(sbiName string) (Engine, error) {
57 for _, sbi := range SupportedSbis {
58 if sbi.Name == sbiName && sbi.IsAvailable {
59 return sbi.Instance, nil
62 return nil, errors.New("SBI:" + sbiName + " is not supported or still not available")
68 func (s *Sbi) pruneEndpointList(sbi Engine) {
69 xapp.Logger.Debug("pruneEndpointList invoked.")
70 for _, ep := range rtmgr.Eps {
72 xapp.Logger.Debug("deleting %v", ep)
73 sbi.DeleteEndpoint(ep)
74 delete(rtmgr.Eps, ep.Uuid)
76 rtmgr.Eps[ep.Uuid].Keepalive = false
81 func (s *Sbi) updateEndpoints(rcs *rtmgr.RicComponents, sbi Engine) {
82 for _, xapps := range (*rcs).XApps {
83 for _, instance := range xapps.Instances {
84 uuid := instance.Ip + ":" + strconv.Itoa(int(instance.Port))
85 if _, ok := rtmgr.Eps[uuid]; ok {
86 rtmgr.Eps[uuid].Keepalive = true
88 ep := &rtmgr.Endpoint{
94 TxMessages: instance.TxMessages,
95 RxMessages: instance.RxMessages,
96 Policies: instance.Policies,
101 if err := sbi.AddEndpoint(ep); err != nil {
102 xapp.Logger.Error("can't create socket for endpoint: " + ep.Name + " due to:" + err.Error())
109 s.updatePlatformEndpoints(&((*rcs).Pcs), sbi)
110 s.updateE2TEndpoints(&((*rcs).E2Ts), sbi)
111 s.pruneEndpointList(sbi)
114 func (s *Sbi) updatePlatformEndpoints(pcs *rtmgr.PlatformComponents, sbi Engine) {
115 xapp.Logger.Debug("updatePlatformEndpoints invoked. PCS: %v", *pcs)
116 for _, pc := range *pcs {
117 uuid := pc.Fqdn + ":" + strconv.Itoa(int(pc.Port))
118 if _, ok := rtmgr.Eps[uuid]; ok {
119 rtmgr.Eps[uuid].Keepalive = true
121 ep := &rtmgr.Endpoint{
124 XAppType: PlatformType,
127 TxMessages: rtmgr.PLATFORMMESSAGETYPES[pc.Name]["tx"],
128 RxMessages: rtmgr.PLATFORMMESSAGETYPES[pc.Name]["rx"],
133 xapp.Logger.Debug("ep created: %v", ep)
134 if err := sbi.AddEndpoint(ep); err != nil {
135 xapp.Logger.Error("can't create socket for endpoint: " + ep.Name + " due to:" + err.Error())
143 func (s *Sbi) updateE2TEndpoints(E2Ts *map[string]rtmgr.E2TInstance, sbi Engine) {
144 xapp.Logger.Debug("updateE2TEndpoints invoked. E2T: %v", *E2Ts)
145 for _, e2t := range *E2Ts {
147 stringSlice := strings.Split(e2t.Fqdn, ":")
148 ipaddress := stringSlice[0]
149 port, _ := strconv.Atoi(stringSlice[1])
150 if _, ok := rtmgr.Eps[uuid]; ok {
151 rtmgr.Eps[uuid].Keepalive = true
153 ep := &rtmgr.Endpoint{
156 XAppType: PlatformType,
159 TxMessages: rtmgr.PLATFORMMESSAGETYPES[e2t.Name]["tx"],
160 RxMessages: rtmgr.PLATFORMMESSAGETYPES[e2t.Name]["rx"],
165 xapp.Logger.Debug("ep created: %v", ep)
166 if err := sbi.AddEndpoint(ep); err != nil {
167 xapp.Logger.Error("can't create socket for endpoint: " + ep.Name + " due to:" + err.Error())