Release image version 1.1.2
[ric-app/hw-go.git] / hwApp.go
index b368db9..74f2df4 100755 (executable)
--- a/hwApp.go
+++ b/hwApp.go
@@ -14,8 +14,6 @@
    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).
 ==================================================================================
 */
 package main
@@ -23,6 +21,7 @@ package main
 import (
        "encoding/json"
 
+       "gerrit.o-ran-sc.org/r/ric-plt/alarm-go.git/alarm"
        "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/clientmodel"
        "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
 )
@@ -43,11 +42,12 @@ var (
        timeToWait           = "w10ms"
        direction            = int64(0)
        procedureCode        = int64(27)
+       xappEventInstanceID  = int64(1234)
        typeOfMessage        = int64(1)
        subscriptionId       = ""
        hPort                = int64(8080)
        rPort                = int64(4560)
-       clientEndpoint       = clientmodel.SubscriptionParamsClientEndpoint{Host: "service-ricxapp-hw-go-http.ricxapp", HTTPPort: &hPort, RMRPort: &rPort}
+       clientEndpoint       = clientmodel.SubscriptionParamsClientEndpoint{Host: "service-ricxapp-hw-go-rmr.ricxapp", HTTPPort: &hPort, RMRPort: &rPort}
 )
 
 func (e *HWApp) sendPolicyQuery() {
@@ -123,28 +123,23 @@ func (e *HWApp) sendSubscription(meid string) {
                ClientEndpoint: &clientEndpoint,
                Meid:           &meid,
                RANFunctionID:  &funId,
-               SubscriptionDetails: clientmodel.SubscriptionDetailsList{
-                       &clientmodel.SubscriptionDetail{
-                               RequestorID: &reqId,
-                               InstanceID:  &seqId,
-                               EventTriggers: &clientmodel.EventTriggerDefinition{
-                                       OctetString: "1234",
-                               },
+               SubscriptionDetails: clientmodel.SubscriptionDetailsList([]*clientmodel.SubscriptionDetail{
+                       {
                                ActionToBeSetupList: clientmodel.ActionsToBeSetup{
                                        &clientmodel.ActionToBeSetup{
-                                               ActionDefinition: &clientmodel.ActionDefinition{
-                                                       OctetString: "5678",
-                                               },
-                                               ActionID:   &actionId,
-                                               ActionType: &actionType,
+                                               ActionDefinition: clientmodel.ActionDefinition([]int64{1, 2, 3, 4}),
+                                               ActionID:         &actionId,
+                                               ActionType:       &actionType,
                                                SubsequentAction: &clientmodel.SubsequentAction{
                                                        SubsequentActionType: &subsequestActioType,
                                                        TimeToWait:           &timeToWait,
                                                },
                                        },
                                },
+                               EventTriggers:       clientmodel.EventTriggerDefinition([]int64{1, 2, 3, 4}),
+                               XappEventInstanceID: &xappEventInstanceID,
                        },
-               },
+               }),
        }
 
        b, err := json.MarshalIndent(subscriptionParams, "", "  ")
@@ -160,6 +155,13 @@ func (e *HWApp) sendSubscription(meid string) {
 
        if err != nil {
                xapp.Logger.Error("subscription failed (%s) with error: %s", meid, err)
+
+               // subscription failed, raise alarm
+               err := xapp.Alarm.Raise(8086, alarm.SeverityCritical, meid, "subscriptionFailed")
+               if err != nil {
+                       xapp.Logger.Error("Raising alarm failed with error %v", err)
+               }
+
                return
        }
        xapp.Logger.Info("Successfully subcription done (%s), subscription id : %s", meid, *resp.SubscriptionID)
@@ -241,7 +243,7 @@ func main() {
        }
 
        hw := HWApp{
-               stats: xapp.Metric.RegisterCounterGroup(metrics, "hw-go"), // register counter
+               stats: xapp.Metric.RegisterCounterGroup(metrics, "hw_go"), // register counter
        }
        hw.Run()
 }