From e51b32404b59e1a8f675ba76faa2b26cdf8c8084 Mon Sep 17 00:00:00 2001 From: subhash kumar singh Date: Thu, 19 Aug 2021 19:45:25 +0000 Subject: [PATCH] Implement subscription operatoin Implement subscription operation for all the identified NBs. Signed-off-by: subhash kumar singh Change-Id: I3d4e6a3202488662dc75c66a5a50ff57f390da8f --- config/config-file.json | 5 +++- go.mod | 4 +-- hwApp.go | 74 ++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 79 insertions(+), 4 deletions(-) diff --git a/config/config-file.json b/config/config-file.json index e0ccec8..7d05181 100644 --- a/config/config-file.json +++ b/config/config-file.json @@ -70,7 +70,10 @@ "policies": [1] }, "controls": { - "fileStrorage": false + "fileStrorage": false, + "logger": { + "level": 3 + } }, "db" : { "waitForSdl": false diff --git a/go.mod b/go.mod index 66f57a0..9c38263 100644 --- a/go.mod +++ b/go.mod @@ -2,9 +2,9 @@ module gerrit.o-ran-sc.org/r/hw-go go 1.15 -require gerrit.o-ran-sc.org/r/ric-plt/xapp-frame v0.8.4 +require gerrit.o-ran-sc.org/r/ric-plt/xapp-frame v0.8.1 -replace gerrit.o-ran-sc.org/r/ric-plt/xapp-frame => gerrit.o-ran-sc.org/r/ric-plt/xapp-frame.git v0.8.4 +replace gerrit.o-ran-sc.org/r/ric-plt/xapp-frame => gerrit.o-ran-sc.org/r/ric-plt/xapp-frame.git v0.8.1 replace gerrit.o-ran-sc.org/r/ric-plt/sdlgo => gerrit.o-ran-sc.org/r/ric-plt/sdlgo.git v0.7.0 diff --git a/hwApp.go b/hwApp.go index 52342b0..cd1d7b5 100755 --- a/hwApp.go +++ b/hwApp.go @@ -21,6 +21,8 @@ package main import ( + "encoding/json" + "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/clientmodel" "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp" ) @@ -30,6 +32,21 @@ type HWApp struct { var ( A1_POLICY_QUERY = 20013 POLICY_QUERY_PAYLOAD = "{\"policy_type_id\":20000}" + reqId = int64(1) + seqId = int64(1) + funId = int64(1) + actionId = int64(1) + actionType = "report" + subsequestActioType = "continue" + timeToWait = "w10ms" + direction = int64(0) + procedureCode = int64(27) + typeOfMessage = int64(1) + subscriptionId = "" + hPort = int64(8080) + rPort = int64(4560) + clientEndpoint = clientmodel.SubscriptionParamsClientEndpoint{Host: "service-ricxapp-hw-go-http.ricxapp", HTTPPort: &hPort, RMRPort: &rPort} + ) func (e *HWApp) sendPolicyQuery() { @@ -97,11 +114,66 @@ func (e *HWApp) getnbList() ([]*xapp.RNIBNbIdentity) { return nbs } +func (e *HWApp) sendSubscription(meid string) { + + xapp.Logger.Info("sending subscription request for meid : %s", meid) + + subscriptionParams := clientmodel.SubscriptionParams{ + ClientEndpoint: &clientEndpoint, + Meid: &meid, + RANFunctionID: &funId, + SubscriptionDetails: clientmodel.SubscriptionDetailsList{ + &clientmodel.SubscriptionDetail{ + RequestorID: &reqId, + InstanceID: &seqId, + EventTriggers: &clientmodel.EventTriggerDefinition{ + OctetString: "1234", + }, + ActionToBeSetupList: clientmodel.ActionsToBeSetup{ + &clientmodel.ActionToBeSetup{ + ActionDefinition: &clientmodel.ActionDefinition{ + OctetString: "5678", + }, + ActionID: &actionId, + ActionType: &actionType, + SubsequentAction: &clientmodel.SubsequentAction{ + SubsequentActionType: &subsequestActioType, + TimeToWait: &timeToWait, + }, + }, + }, + }, + }, + } + + b, err := json.MarshalIndent(subscriptionParams, "", " ") + + if err != nil { + xapp.Logger.Error("Json marshaling failed : %s", err) + return + } + + xapp.Logger.Info("*****body: %s ", string(b)) + + resp, err := xapp.Subscription.Subscribe(&subscriptionParams) + + if err != nil { + xapp.Logger.Error("subscription failed (%s) with error: %s", meid, err) + return + } + xapp.Logger.Info("Successfully subcription done (%s), subscription id : %s", meid, *resp.SubscriptionID) +} + func (e *HWApp) xAppStartCB(d interface{}) { xapp.Logger.Info("xApp ready call back received") // get the list of all NBs - e.getnbList() + nbList := e.getnbList() + + // send subscription request to each of the NBs + for _, nb := range nbList { + e.sendSubscription(nb.InventoryName) + } } func (e *HWApp) Consume(msg *xapp.RMRParams) (err error) { -- 2.16.6