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.
18 ==================================================================================
22 Abstract: Contains SBI (SouthBound Interface) module definitions and generic SBI components
30 "routing-manager/pkg/rtmgr"
34 const DEFAULT_NNG_PIPELINE_SOCKET_PREFIX = "tcp://"
35 const DEFAULT_NNG_PIPELINE_SOCKET_NUMBER = 4561
36 const PLATFORMTYPE = "platform"
39 SupportedSbis = []*SbiEngineConfig{
43 Protocol: "nngpipeline",
44 Instance: NewNngPush(),
50 func GetSbi(sbiName string) (SbiEngine, error) {
51 for _, sbi := range SupportedSbis {
52 if sbi.Name == sbiName && sbi.IsAvailable {
53 return sbi.Instance, nil
56 return nil, errors.New("SBI:" + sbiName + " is not supported or still not available")
62 func (s *Sbi) pruneEndpointList(sbi SbiEngine) {
63 for _, ep := range rtmgr.Eps {
65 rtmgr.Logger.Debug("deleting %v", ep)
66 sbi.DeleteEndpoint(ep)
67 delete(rtmgr.Eps, ep.Uuid)
69 rtmgr.Eps[ep.Uuid].Keepalive = false
74 func (s *Sbi) updateEndpoints(rcs *rtmgr.RicComponents, sbii SbiEngine) {
75 for _, xapp := range (*rcs).Xapps {
76 for _, instance := range xapp.Instances {
77 uuid := instance.Ip + ":" + strconv.Itoa(int(instance.Port))
78 if _, ok := rtmgr.Eps[uuid]; ok {
79 rtmgr.Eps[uuid].Keepalive = true
81 ep := &rtmgr.Endpoint{
93 if err := sbii.AddEndpoint(ep); err != nil {
94 rtmgr.Logger.Error("can't create socket for endpoint: " + ep.Name + " due to:" + err.Error())
101 s.updatePlatformEndpoints(&((*rcs).Pcs), sbii)
102 s.pruneEndpointList(sbii)
105 func (s *Sbi) updatePlatformEndpoints(pcs *rtmgr.PlatformComponents, sbii SbiEngine) {
106 rtmgr.Logger.Debug("updatePlatformEndpoints invoked. PCS: %v", *pcs)
107 for _, pc := range *pcs {
108 uuid := pc.Fqdn + ":" + strconv.Itoa(int(pc.Port))
109 if _, ok := rtmgr.Eps[uuid]; ok {
110 rtmgr.Eps[uuid].Keepalive = true
112 ep := &rtmgr.Endpoint{
118 rtmgr.PLATFORMMESSAGETYPES[pc.Name]["tx"],
119 rtmgr.PLATFORMMESSAGETYPES[pc.Name]["rx"],
124 rtmgr.Logger.Debug("ep created: %v", ep)
125 if err := sbii.AddEndpoint(ep); err != nil {
126 rtmgr.Logger.Error("can't create socket for endpoint: " + ep.Name + " due to:" + err.Error())