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"
39 const DefaultNngPipelineSocketPrefix = "tcp://"
40 const DefaultNngPipelineSocketNumber = 4561
41 const PlatformType = "platform"
44 SupportedSbis = []*EngineConfig{
48 Protocol: "nngpipeline",
49 Instance: NewNngPush(),
55 func GetSbi(sbiName string) (Engine, error) {
56 for _, sbi := range SupportedSbis {
57 if sbi.Name == sbiName && sbi.IsAvailable {
58 return sbi.Instance, nil
61 return nil, errors.New("SBI:" + sbiName + " is not supported or still not available")
67 func (s *Sbi) pruneEndpointList(sbi Engine) {
68 xapp.Logger.Debug("pruneEndpointList invoked.")
69 for _, ep := range rtmgr.Eps {
71 xapp.Logger.Debug("deleting %v", ep)
72 sbi.DeleteEndpoint(ep)
73 delete(rtmgr.Eps, ep.Uuid)
75 rtmgr.Eps[ep.Uuid].Keepalive = false
80 func (s *Sbi) updateEndpoints(rcs *rtmgr.RicComponents, sbi Engine) {
81 for _, xapps := range (*rcs).XApps {
82 for _, instance := range xapps.Instances {
83 uuid := instance.Ip + ":" + strconv.Itoa(int(instance.Port))
84 if _, ok := rtmgr.Eps[uuid]; ok {
85 rtmgr.Eps[uuid].Keepalive = true
87 ep := &rtmgr.Endpoint{
93 TxMessages: instance.TxMessages,
94 RxMessages: instance.RxMessages,
95 Policies: instance.Policies,
100 if err := sbi.AddEndpoint(ep); err != nil {
101 xapp.Logger.Error("can't create socket for endpoint: " + ep.Name + " due to:" + err.Error())
108 s.updatePlatformEndpoints(&((*rcs).Pcs), sbi)
109 s.pruneEndpointList(sbi)
112 func (s *Sbi) updatePlatformEndpoints(pcs *rtmgr.PlatformComponents, sbi Engine) {
113 xapp.Logger.Debug("updatePlatformEndpoints invoked. PCS: %v", *pcs)
114 for _, pc := range *pcs {
115 uuid := pc.Fqdn + ":" + strconv.Itoa(int(pc.Port))
116 if _, ok := rtmgr.Eps[uuid]; ok {
117 rtmgr.Eps[uuid].Keepalive = true
119 ep := &rtmgr.Endpoint{
122 XAppType: PlatformType,
125 TxMessages: rtmgr.PLATFORMMESSAGETYPES[pc.Name]["tx"],
126 RxMessages: rtmgr.PLATFORMMESSAGETYPES[pc.Name]["rx"],
131 xapp.Logger.Debug("ep created: %v", ep)
132 if err := sbi.AddEndpoint(ep); err != nil {
133 xapp.Logger.Error("can't create socket for endpoint: " + ep.Name + " due to:" + err.Error())