X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=test%2Fusecases%2Foruclosedlooprecovery%2Fgoversion%2Finternal%2Fves%2Fmessage.go;fp=test%2Fusecases%2Foruclosedlooprecovery%2Fgoversion%2Finternal%2Fves%2Fmessage.go;h=ca8a3ca8c93051f149be048491d3d2e85a915741;hb=856d55d6413fe66c05b42a3c5e98d0b0f20743e3;hp=0000000000000000000000000000000000000000;hpb=b12ba6d71c0468c505aad9e9879e76526b8fe123;p=nonrtric.git diff --git a/test/usecases/oruclosedlooprecovery/goversion/internal/ves/message.go b/test/usecases/oruclosedlooprecovery/goversion/internal/ves/message.go new file mode 100644 index 00000000..ca8a3ca8 --- /dev/null +++ b/test/usecases/oruclosedlooprecovery/goversion/internal/ves/message.go @@ -0,0 +1,64 @@ +// - +// ========================LICENSE_START================================= +// O-RAN-SC +// %% +// Copyright (C) 2021: Nordix Foundation +// %% +// 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. +// ========================LICENSE_END=================================== +// + +package ves + +type FaultMessage struct { + Event Event `json:"event"` +} + +type Event struct { + CommonEventHeader CommonEventHeader `json:"commonEventHeader"` + FaultFields FaultFields `json:"faultFields"` +} + +type CommonEventHeader struct { + Domain string `json:"domain"` + SourceName string `json:"sourceName"` +} + +type FaultFields struct { + AlarmCondition string `json:"alarmCondition"` + EventSeverity string `json:"eventSeverity"` +} + +func (message FaultMessage) isFault() bool { + return message.Event.CommonEventHeader.Domain == "fault" +} + +func (message FaultMessage) isLinkAlarm() bool { + return message.Event.FaultFields.AlarmCondition == "28" +} + +func (message FaultMessage) isSeverityNormal() bool { + return message.Event.FaultFields.EventSeverity == "NORMAL" +} + +func (message FaultMessage) IsLinkFailure() bool { + return message.isFault() && message.isLinkAlarm() && !message.isSeverityNormal() +} + +func (message FaultMessage) IsClearLinkFailure() bool { + return message.isFault() && message.isLinkAlarm() && message.isSeverityNormal() +} + +func (message FaultMessage) GetORuId() string { + return message.Event.CommonEventHeader.SourceName +}