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 "routing-manager/pkg/rtmgr"
38 const DefaultNngPipelineSocketPrefix = "tcp://"
39 const DefaultNngPipelineSocketNumber = 4561
40 const PlatformType = "platform"
43 SupportedSbis = []*EngineConfig{
47 Protocol: "nngpipeline",
48 Instance: NewNngPush(),
54 func GetSbi(sbiName string) (Engine, error) {
55 for _, sbi := range SupportedSbis {
56 if sbi.Name == sbiName && sbi.IsAvailable {
57 return sbi.Instance, nil
60 return nil, errors.New("SBI:" + sbiName + " is not supported or still not available")
66 func (s *Sbi) pruneEndpointList(sbi Engine) {
67 for _, ep := range rtmgr.Eps {
69 rtmgr.Logger.Debug("deleting %v", ep)
70 sbi.DeleteEndpoint(ep)
71 delete(rtmgr.Eps, ep.Uuid)
73 rtmgr.Eps[ep.Uuid].Keepalive = false
78 func (s *Sbi) updateEndpoints(rcs *rtmgr.RicComponents, sbi Engine) {
79 for _, xapp := range (*rcs).XApps {
80 for _, instance := range xapp.Instances {
81 uuid := instance.Ip + ":" + strconv.Itoa(int(instance.Port))
82 if _, ok := rtmgr.Eps[uuid]; ok {
83 rtmgr.Eps[uuid].Keepalive = true
85 ep := &rtmgr.Endpoint{
91 TxMessages: instance.TxMessages,
92 RxMessages: instance.RxMessages,
97 if err := sbi.AddEndpoint(ep); err != nil {
98 rtmgr.Logger.Error("can't create socket for endpoint: " + ep.Name + " due to:" + err.Error())
105 s.updatePlatformEndpoints(&((*rcs).Pcs), sbi)
106 s.pruneEndpointList(sbi)
109 func (s *Sbi) updatePlatformEndpoints(pcs *rtmgr.PlatformComponents, sbi Engine) {
110 rtmgr.Logger.Debug("updatePlatformEndpoints invoked. PCS: %v", *pcs)
111 for _, pc := range *pcs {
112 uuid := pc.Fqdn + ":" + strconv.Itoa(int(pc.Port))
113 if _, ok := rtmgr.Eps[uuid]; ok {
114 rtmgr.Eps[uuid].Keepalive = true
116 ep := &rtmgr.Endpoint{
119 XAppType: PlatformType,
122 TxMessages: rtmgr.PLATFORMMESSAGETYPES[pc.Name]["tx"],
123 RxMessages: rtmgr.PLATFORMMESSAGETYPES[pc.Name]["rx"],
128 rtmgr.Logger.Debug("ep created: %v", ep)
129 if err := sbi.AddEndpoint(ep); err != nil {
130 rtmgr.Logger.Error("can't create socket for endpoint: " + ep.Name + " due to:" + err.Error())