From: Abukar Mohamed Date: Fri, 22 Oct 2021 11:32:25 +0000 (+0000) Subject: Merge "Special version for alarm manager" into alarm_wa X-Git-Tag: v0.9.2-1^0 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=refs%2Fheads%2Falarm_wa;hp=8083bb18456d777190a9ebed44a90c91b0bb29fe;p=ric-plt%2Fxapp-frame.git Merge "Special version for alarm manager" into alarm_wa --- diff --git a/go.mod b/go.mod index 18fa7cc..9e51428 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,11 @@ module gerrit.o-ran-sc.org/r/ric-plt/xapp-frame -go 1.12 +go 1.17 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/alarm-go.git/alarm v0.5.0 gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.2.1 gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.2.1 gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/reader v1.2.1 @@ -27,6 +28,40 @@ require ( k8s.io/utils v0.0.0-20201110183641-67b214c5f920 // indirect ) +require ( + github.com/PuerkitoBio/purell v1.1.1 // indirect + github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect + github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a // indirect + github.com/beorn7/perks v1.0.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/docker/go-units v0.4.0 // indirect + github.com/go-openapi/analysis v0.19.5 // indirect + github.com/go-openapi/jsonpointer v0.19.3 // indirect + github.com/go-openapi/jsonreference v0.19.3 // indirect + github.com/go-redis/redis v6.15.9+incompatible // indirect + github.com/go-stack/stack v1.8.0 // indirect + github.com/hashicorp/hcl v1.0.0 // indirect + github.com/magiconair/properties v1.8.0 // indirect + github.com/mailru/easyjson v0.7.0 // indirect + github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect + github.com/mitchellh/mapstructure v1.1.2 // indirect + github.com/pelletier/go-toml v1.2.0 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90 // indirect + github.com/prometheus/common v0.4.0 // indirect + github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084 // indirect + github.com/spf13/afero v1.2.2 // indirect + github.com/spf13/cast v1.3.0 // indirect + github.com/spf13/jwalterweatherman v1.0.0 // indirect + github.com/spf13/pflag v1.0.3 // indirect + github.com/stretchr/objx v0.2.0 // indirect + go.mongodb.org/mongo-driver v1.1.2 // indirect + golang.org/x/sys v0.0.0-20200519105757-fe76b779f299 // indirect + golang.org/x/text v0.3.2 // indirect + google.golang.org/protobuf v1.23.0 // indirect + gopkg.in/yaml.v2 v2.3.0 // indirect +) + replace gerrit.o-ran-sc.org/r/ric-plt/sdlgo => gerrit.o-ran-sc.org/r/ric-plt/sdlgo.git v0.7.0 replace gerrit.o-ran-sc.org/r/com/golog => gerrit.o-ran-sc.org/r/com/golog.git v0.0.2 @@ -37,4 +72,4 @@ replace gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities => gerrit.o-ran-sc 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.2.1 -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 +//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 diff --git a/go.sum b/go.sum index 1caf2ec..2ba5fe4 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,4 @@ 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.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.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.2.1 h1:3FFbXx55BODThXfyWAiz6cPXVELXFICDQUmJi13EoxM= gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.2.1/go.mod h1:QJ1uPPZosGbhxUWpUpeM5fLqFHdnWTrVnvW2DgyOCes= gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities v1.2.1 h1:8Z60JRsPgcS1Ona4fEh6d0/03nLq1WHoZcNnBsni5+g= diff --git a/pkg/xapp/alarm.go b/pkg/xapp/alarm.go deleted file mode 100755 index 0e6f637..0000000 --- a/pkg/xapp/alarm.go +++ /dev/null @@ -1,70 +0,0 @@ -/* -================================================================================== - 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() -} diff --git a/pkg/xapp/alarm_test.go b/pkg/xapp/alarm_test.go deleted file mode 100755 index f8de8bd..0000000 --- a/pkg/xapp/alarm_test.go +++ /dev/null @@ -1,70 +0,0 @@ -/* -================================================================================== - 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() -} diff --git a/pkg/xapp/xapp.go b/pkg/xapp/xapp.go index e832436..a38efbc 100755 --- a/pkg/xapp/xapp.go +++ b/pkg/xapp/xapp.go @@ -57,7 +57,7 @@ var ( Logger *Log Config Configurator Subscription *Subscriber - Alarm *AlarmClient + //Alarm *AlarmClient Util *Utils readyCb ReadyCB readyCbParams interface{} @@ -76,7 +76,7 @@ func SetReadyCB(cb ReadyCB, params interface{}) { } func XappReadyCb(params interface{}) { - Alarm = NewAlarmClient(viper.GetString("moId"), viper.GetString("name")) + //Alarm = NewAlarmClient(viper.GetString("moId"), viper.GetString("name")) if readyCb != nil { readyCb(readyCbParams) }