2 ==================================================================================
3 Copyright (c) 2019 AT&T Intellectual Property.
4 Copyright (c) 2019 Nokia
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
10 http://www.apache.org/licenses/LICENSE-2.0
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.
17 ==================================================================================
23 rtmgrclient "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/rtmgr_client"
24 rtmgrhandle "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/rtmgr_client/handle"
25 "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/rtmgr_models"
29 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
32 type RtmgrClient struct {
33 rtClient *rtmgrclient.RoutingManager
34 xappHandleParams *rtmgrhandle.ProvideXappSubscriptionHandleParams
37 func (rc *RtmgrClient) SubscriptionRequestUpdate() error {
38 xapp.Logger.Debug("SubscriptionRequestUpdate() invoked")
39 subRouteAction := <-SubscriptionReqChan
40 // Routing manager handles subscription id as int32 to accomodate -1 and uint16 values
41 subID := int32(subRouteAction.SubID)
43 xapp.Logger.Debug("Subscription action details received: ", subRouteAction)
45 xappSubReq := rtmgr_models.XappSubscriptionData{&subRouteAction.Address, &subRouteAction.Port, &subID}
47 switch subRouteAction.Command {
49 _, postErr := rc.rtClient.Handle.ProvideXappSubscriptionHandle(rc.xappHandleParams.WithXappSubscriptionData(&xappSubReq))
50 if postErr != nil && !(strings.Contains(postErr.Error(), "status 200")) {
51 xapp.Logger.Error("Updating routing manager about subscription id = %d failed with error: %v", subID, postErr)
54 xapp.Logger.Info("Succesfully updated routing manager about the subscription: %d", subID)
62 func (rc *RtmgrClient) SplitSource(src string) (*string, *uint16, error) {
63 tcpSrc := strings.Split(src, ":")
65 err := errors.New("Unable to get the source details of the xapp. Check the source string received from the rmr.")
69 xapp.Logger.Info("---Debugging Inside splitsource tcpsrc[0] = %s and tcpsrc[1]= %s ", tcpSrc[0], tcpSrc[1])
70 srcPort, err := strconv.ParseUint(tcpSrc[1], 10, 16)
74 srcPortInt := uint16(srcPort)
75 return &srcAddr, &srcPortInt, nil