require (
gerrit.o-ran-sc.org/r/com/golog v0.0.2
- gerrit.o-ran-sc.org/r/ric-plt/alarm-go.git/alarm v0.5.0
gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.0.35
gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.0.35
gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader v1.0.35
replace gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities => gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.0.35
replace gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader => gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader v1.0.35
-
-replace gerrit.o-ran-sc.org/r/ric-plt/alarm-go.git/alarm => gerrit.o-ran-sc.org/r/ric-plt/alarm-go.git/alarm v0.5.0
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
-gerrit.o-ran-sc.org/r/com/golog.git v0.0.0-20190604083303-aaffc8ebe3f1 h1:WAB8G/FFaUjRkpLuUhIo0EfbeBOY7xjkcFAFkpe3Xns=
-gerrit.o-ran-sc.org/r/com/golog.git v0.0.0-20190604083303-aaffc8ebe3f1/go.mod h1:b8YB31U8/4iRpABioeSzGi/YMzOQ/Zq7hrJmmXKqlJk=
gerrit.o-ran-sc.org/r/com/golog.git v0.0.2 h1:Ix6SgFuzd6yW6Ur6+qDlGhDO65UYs8PiIkeAL1VaQ2o=
gerrit.o-ran-sc.org/r/com/golog.git v0.0.2/go.mod h1:A7hUL52YQSO4dFIZNcj76XQ09C9PftAe3LyL7kqBnok=
-gerrit.o-ran-sc.org/r/ric-plt/alarm-go.git/alarm v0.4.2 h1:XNfkp3PwZ7pfkPszX7NaX6DzToCGjcWTLbIHYqCFNu0=
-gerrit.o-ran-sc.org/r/ric-plt/alarm-go.git/alarm v0.4.2/go.mod h1:AdEWKtERGvOQy9ybLhyhrb9w9LLVn8i9xzTwoR5n4BY=
-gerrit.o-ran-sc.org/r/ric-plt/alarm-go.git/alarm v0.5.0 h1:OKDsIDlttbaoHwleyjflIWVZPgPvYbDhim6gWF0zf5E=
-gerrit.o-ran-sc.org/r/ric-plt/alarm-go.git/alarm v0.5.0/go.mod h1:AdEWKtERGvOQy9ybLhyhrb9w9LLVn8i9xzTwoR5n4BY=
gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.0.35 h1:TGXHb4DNY8on+ej4S9VUnk2HibIC/5chDy64OE+bQBQ=
gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.0.35/go.mod h1:QJ1uPPZosGbhxUWpUpeM5fLqFHdnWTrVnvW2DgyOCes=
gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.0.35 h1:tkM3yE8UzmuH4nf9TqAmiNBSuIZ2CtcMRH2eBIYIzpQ=
+++ /dev/null
-/*
-==================================================================================
- Copyright (c) 2020 AT&T Intellectual Property.
- Copyright (c) 2020 Nokia
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- 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.
-==================================================================================
-*/
-
-package xapp
-
-import (
- "gerrit.o-ran-sc.org/r/ric-plt/alarm-go.git/alarm"
- "os"
-)
-
-type AlarmClient struct {
- alarmer *alarm.RICAlarm
-}
-
-// NewAlarmClient returns a new AlarmClient.
-func NewAlarmClient(moId, appId string) *AlarmClient {
- if moId == "" {
- moId = "RIC"
- if hostname, err := os.Hostname(); err == nil {
- moId = hostname
- }
- }
-
- if appId == "" {
- appId = os.Args[0]
- }
-
- alarmInstance, err := alarm.InitAlarm(moId, appId)
- if err == nil {
- return &AlarmClient{
- alarmer: alarmInstance,
- }
- }
- return nil
-}
-
-func (c *AlarmClient) Raise(sp int, severity alarm.Severity, identifyingInfo, additionalInfo string) error {
- alarmData := c.alarmer.NewAlarm(sp, severity, identifyingInfo, additionalInfo)
- return c.alarmer.Raise(alarmData)
-}
-
-func (c *AlarmClient) Clear(sp int, severity alarm.Severity, identifyingInfo, additionalInfo string) error {
- alarmData := c.alarmer.NewAlarm(sp, severity, identifyingInfo, additionalInfo)
- return c.alarmer.Clear(alarmData)
-}
-
-func (c *AlarmClient) Reraise(sp int, severity alarm.Severity, identifyingInfo, additionalInfo string) error {
- alarmData := c.alarmer.NewAlarm(sp, severity, identifyingInfo, additionalInfo)
- return c.alarmer.Reraise(alarmData)
-}
-
-func (c *AlarmClient) ClearAll() error {
- return c.alarmer.ClearAll()
-}
+++ /dev/null
-/*
-==================================================================================
- Copyright (c) 2019 AT&T Intellectual Property.
- Copyright (c) 2019 Nokia
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- 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.
-==================================================================================
-*/
-
-package xapp
-
-import (
- "github.com/stretchr/testify/assert"
- "testing"
-
- "gerrit.o-ran-sc.org/r/ric-plt/alarm-go.git/alarm"
-)
-
-func TestNewAlarmClient(t *testing.T) {
- Logger.Info("TestNewAlarmClient")
-
- a := NewAlarmClient("", "")
- assert.NotNil(t, a, "NewAlarmClient failed")
-}
-
-func TestAlarmRaise(t *testing.T) {
- Logger.Info("TestAlarmRaise")
-
- a := NewAlarmClient("", "")
- assert.NotNil(t, a, "NewAlarmClient failed")
-
- a.Raise(1234, alarm.SeverityCritical, "Some App data", "eth 0 1")
-}
-
-func TestAlarmClear(t *testing.T) {
- Logger.Info("TestAlarmClear")
-
- a := NewAlarmClient("", "")
- assert.NotNil(t, a, "NewAlarmClient failed")
-
- a.Clear(1234, alarm.SeverityCritical, "Some App data", "eth 0 1")
-}
-
-func TestAlarmReraise(t *testing.T) {
- Logger.Info("TestAlarmReraise")
-
- a := NewAlarmClient("", "")
- assert.NotNil(t, a, "NewAlarmClient failed")
-
- a.Reraise(1234, alarm.SeverityCritical, "Some App data", "eth 0 1")
-}
-
-func TestAlarmClearall(t *testing.T) {
- Logger.Info("TestAlarmClearall")
-
- a := NewAlarmClient("", "")
- assert.NotNil(t, a, "NewAlarmClient failed")
-
- a.ClearAll()
-}
"bytes"
"encoding/json"
"fmt"
- "github.com/spf13/viper"
"net/http"
"os"
"os/signal"
"sync/atomic"
"syscall"
"time"
+
+ "github.com/spf13/viper"
)
type ReadyCB func(interface{})
Logger *Log
Config Configurator
Subscription *Subscriber
- Alarm *AlarmClient
Util *Utils
readyCb ReadyCB
readyCbParams interface{}
}
func XappReadyCb(params interface{}) {
- Alarm = NewAlarmClient(viper.GetString("moId"), viper.GetString("name"))
if readyCb != nil {
readyCb(readyCbParams)
}