X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=pkg%2Fcontrol%2Frestendpoint.go;h=3b4f8f5f6c23506100e4584729ad4cf0b0eaca4f;hb=55d2a285e4914afce7492c6b4b6feebe5485210b;hp=b872c47c09b10f8facc2c24426353becbed66bd4;hpb=afbf95f5756a7b781859beb1e68b41f7319ed208;p=ric-plt%2Fsubmgr.git diff --git a/pkg/control/restendpoint.go b/pkg/control/restendpoint.go index b872c47..3b4f8f5 100644 --- a/pkg/control/restendpoint.go +++ b/pkg/control/restendpoint.go @@ -22,6 +22,7 @@ package control import ( "fmt" "strconv" + "strings" "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/models" "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp" @@ -30,6 +31,7 @@ import ( //----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- + func ConstructEndpointAddresses(clientEndpoint models.SubscriptionParamsClientEndpoint) (string, string, error) { var HTTP_port int64 = *clientEndpoint.HTTPPort @@ -38,18 +40,22 @@ func ConstructEndpointAddresses(clientEndpoint models.SubscriptionParamsClientEn var xAppHTTPEndPoint string var xAppRMREndPoint string + if host == "" || (HTTP_port == 0 && RMR_port == 0) { + err := fmt.Errorf("ClientEndpoint provided without PORT numbers") + return "INVALID_HTTP_ADDRESS:" + host + (string)(*clientEndpoint.HTTPPort), + "INVALID_RMR_ADDRESS:" + host + (string)(*clientEndpoint.RMRPort), + err + } + if *clientEndpoint.HTTPPort > 0 { xAppHTTPEndPoint = host + ":" + strconv.FormatInt(*clientEndpoint.HTTPPort, 10) } if *clientEndpoint.RMRPort > 0 { + if i := strings.Index(host, "http"); i != -1 { + host = strings.Replace(host, "http", "rmr", -1) + } xAppRMREndPoint = host + ":" + strconv.FormatInt(*clientEndpoint.RMRPort, 10) } - if host == "" || (HTTP_port == 0 && RMR_port == 0) { - err := fmt.Errorf("ClientEndpoint aprovided no PORT numbers") - return "INVALID_HTTP_ADDRESS:" + host + (string)(*clientEndpoint.HTTPPort), - "INVALID_RMR_ADDRESS:" + host + (string)(*clientEndpoint.RMRPort), - err - } xapp.Logger.Info("xAppHttpEndPoint=%v, xAppRrmEndPoint=%v", xAppHTTPEndPoint, xAppRMREndPoint)