Code Review
/
ric-plt
/
rtmgr.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
added UT's to cover LC:85%
[ric-plt/rtmgr.git]
/
pkg
/
nbi
/
nbi.go
diff --git
a/pkg/nbi/nbi.go
b/pkg/nbi/nbi.go
index
2b9fa99
..
ddbf347
100644
(file)
--- a/
pkg/nbi/nbi.go
+++ b/
pkg/nbi/nbi.go
@@
-14,6
+14,11
@@
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
+
+
+ This source code is part of the near-RT RIC (RAN Intelligent Controller)
+ platform project (RICP).
+
==================================================================================
*/
/*
==================================================================================
*/
/*
@@
-26,15
+31,16
@@
package nbi
import (
"errors"
import (
"errors"
- httptransport "github.com/go-openapi/runtime/client"
- "github.com/go-openapi/strfmt"
- "github.com/go-openapi/swag"
"net/url"
apiclient "routing-manager/pkg/appmgr_client"
"routing-manager/pkg/appmgr_client/operations"
"routing-manager/pkg/appmgr_model"
"net/url"
apiclient "routing-manager/pkg/appmgr_client"
"routing-manager/pkg/appmgr_client/operations"
"routing-manager/pkg/appmgr_model"
- "routing-manager/pkg/rtmgr"
"time"
"time"
+
+ "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
+ httptransport "github.com/go-openapi/runtime/client"
+ "github.com/go-openapi/strfmt"
+ "github.com/go-openapi/swag"
)
var (
)
var (
@@
-70,13
+76,17
@@
func GetNbi(nbiName string) (Engine, error) {
func CreateSubReq(restUrl string, restPort string) *appmgr_model.SubscriptionRequest {
// TODO: parameterize function
func CreateSubReq(restUrl string, restPort string) *appmgr_model.SubscriptionRequest {
// TODO: parameterize function
- sub
Req := appmgr_model.SubscriptionRequest
{
+ sub
Data := appmgr_model.SubscriptionData
{
TargetURL: swag.String(restUrl + ":" + restPort + "/ric/v1/handles/xapp-handle/"),
TargetURL: swag.String(restUrl + ":" + restPort + "/ric/v1/handles/xapp-handle/"),
- EventType:
swag.String("all")
,
+ EventType:
appmgr_model.EventTypeAll
,
MaxRetries: swag.Int64(5),
RetryTimer: swag.Int64(10),
}
MaxRetries: swag.Int64(5),
RetryTimer: swag.Int64(10),
}
+ subReq := appmgr_model.SubscriptionRequest{
+ Data: &subData,
+ }
+
return &subReq
}
return &subReq
}
@@
-84,12
+94,12
@@
func PostSubReq(xmUrl string, nbiif string) error {
// setting up POST request to Xapp Manager
appmgrUrl, err := url.Parse(xmUrl)
if err != nil {
// setting up POST request to Xapp Manager
appmgrUrl, err := url.Parse(xmUrl)
if err != nil {
-
rtmgr
.Logger.Error("Invalid XApp manager url/hostname: " + err.Error())
+
xapp
.Logger.Error("Invalid XApp manager url/hostname: " + err.Error())
return err
}
nbiifUrl, err := url.Parse(nbiif)
if err != nil {
return err
}
nbiifUrl, err := url.Parse(nbiif)
if err != nil {
-
rtmgr
.Logger.Error("Invalid NBI address/port: " + err.Error())
+
xapp
.Logger.Error("Invalid NBI address/port: " + err.Error())
return err
}
transport := httptransport.New(appmgrUrl.Hostname()+":"+appmgrUrl.Port(), "/ric/v1", []string{"http"})
return err
}
transport := httptransport.New(appmgrUrl.Hostname()+":"+appmgrUrl.Port(), "/ric/v1", []string{"http"})
@@
-99,11
+109,11
@@
func PostSubReq(xmUrl string, nbiif string) error {
subReq := CreateSubReq(nbiifUrl.Scheme+"://"+nbiifUrl.Hostname(), nbiifUrl.Port())
resp, postErr := client.Operations.AddSubscription(addSubParams.WithSubscriptionRequest(subReq))
if postErr != nil {
subReq := CreateSubReq(nbiifUrl.Scheme+"://"+nbiifUrl.Hostname(), nbiifUrl.Port())
resp, postErr := client.Operations.AddSubscription(addSubParams.WithSubscriptionRequest(subReq))
if postErr != nil {
-
rtmgr
.Logger.Error("POST unsuccessful:" + postErr.Error())
+
xapp
.Logger.Error("POST unsuccessful:" + postErr.Error())
return postErr
} else {
// TODO: use the received ID
return postErr
} else {
// TODO: use the received ID
-
rtmgr
.Logger.Info("POST received: " + string(resp.Payload.ID))
+
xapp
.Logger.Info("POST received: " + string(resp.Payload.ID))
return nil
}
}
return nil
}
}