#cd ../alarm && go test . -v -coverprofile cover.out
# And for the Alarm Adapter
-#cd ../adapter && go test -v -p 1 -coverprofile cover.out ./cmd/ -c -o ./adapter_test && ./adapter_test
+cd ../adapter && go test -v -p 1 -coverprofile cover.out ./cmd/ -c -o ./adapter_test && ./adapter_test
echo "--> build_adapter_ubuntu.sh ends"
func (a *AlarmAdapter) HandleAlarms(rp *app.RMRParams) (*alert.PostAlertsOK, error) {
var m alarm.AlarmMessage
+ app.Logger.Info("Received JSON: %s", rp.Payload)
if err := json.Unmarshal(rp.Payload, &m); err != nil {
app.Logger.Error("json.Unmarshal failed: %v", err)
return nil, err
--- /dev/null
+{
+ "$schema": "http://json-schema.org/draft-07/schema",
+ "$id": "https://gerrit.o-ran-sc.org/r/admin/repos/ric-plt/alarm-go.json",
+ "type": "object",
+ "title": "Alarm schema",
+ "description": "Schema for RIC alarm messages.",
+ "default": {},
+ "examples": [
+ {
+ "managedObjectId": "my-pod-lib",
+ "applicationId": "my-app",
+ "specificProblem": 1234,
+ "perceivedSeverity": "MAJOR",
+ "additionalInfo": "Some App data",
+ "identifyingInfo": "eth 0 1",
+ "AlarmAction": "RAISE",
+ "AlarmTime": 1591188407505707
+ }
+ ],
+ "required": [
+ "managedObjectId",
+ "applicationId",
+ "specificProblem",
+ "perceivedSeverity",
+ "identifyingInfo",
+ "AlarmAction",
+ "AlarmTime"
+ ],
+ "additionalProperties": true,
+ "properties": {
+ "managedObjectId": {
+ "type": "string",
+ "title": "The managedObjectId schema",
+ "description": "The name of the managed object that is the cause of the fault.",
+ "default": ""
+ },
+ "applicationId": {
+ "type": "string",
+ "title": "The applicationId schema",
+ "description": "The name of the process that raised the alarm.",
+ "default": ""
+ },
+ "specificProblem": {
+ "type": "integer",
+ "title": "The specificProblem schema",
+ "description": "The problem that is the cause of the alarm.",
+ "default": 0
+ },
+ "perceivedSeverity": {
+ "type": "string",
+ "enum": [
+ "UNSPECIFIED",
+ "CRITICAL",
+ "MAJOR",
+ "MINOR",
+ "WARNING",
+ "CLEARED",
+ "DEFAULT"
+ ],
+ "title": "The perceivedSeverity schema",
+ "description": "The severity of the alarm.",
+ "default": ""
+ },
+ "additionalInfo": {
+ "type": "string",
+ "title": "The additionalInfo schema",
+ "description": "Additional information given by the application (optional).",
+ "default": ""
+ },
+ "identifyingInfo": {
+ "type": "string",
+ "title": "The identifyingInfo schema",
+ "description": "Identifying additional information, which is part of alarm identity.",
+ "default": ""
+ },
+ "AlarmAction": {
+ "type": "string",
+ "enum": [
+ "RAISE",
+ "CLEAR",
+ "CLEARALL"
+ ],
+ "title": "The AlarmAction schema",
+ "description": "Action to perform on the alarm.",
+ "default": ""
+ },
+ "AlarmTime": {
+ "type": "integer",
+ "title": "The AlarmTime schema",
+ "description": "Current system time in milliseconds since the Epoch.",
+ "default": 0
+ }
+ }
+}
--- /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.
+#
+# This source code is part of the near-RT RIC (RAN Intelligent Controller)
+# platform project (RICP).
+#
+# Test the alarm library by issuing this command from the alarm/ subdirectory:
+# docker build -f Dockerfile-Unit-Test .
+
+FROM golang:1.12
+
+# install rmr headers and libraries
+ARG RMRVERSION=4.0.5
+RUN wget -nv --content-disposition https://packagecloud.io/o-ran-sc/release/packages/debian/stretch/rmr_${RMRVERSION}_amd64.deb/download.deb \
+ && dpkg -i rmr_${RMRVERSION}_amd64.deb \
+ && rm -rf rmr_${RMRVERSION}_amd64.deb
+RUN wget -nv --content-disposition https://packagecloud.io/o-ran-sc/release/packages/debian/stretch/rmr-dev_${RMRVERSION}_amd64.deb/download.deb \
+ && dpkg -i rmr-dev_${RMRVERSION}_amd64.deb \
+ && rm -rf rmr-dev_${RMRVERSION}_amd64.deb
+RUN ldconfig
+RUN mkdir -p /tmp/alarm
+COPY . /tmp/alarm
+RUN cd /tmp/alarm && go test . -v
return errors.New("RMR no ready yet!")
}
+ log.Printf("Alarm message: %+v\n", a)
log.Println("Sending alarm: ", r.AlarmString(a))
payload, err := json.Marshal(a)
if err != nil {
return err
}
+ log.Println("JSON payload: ", fmt.Sprintf("%s", payload))
datap := C.CBytes(payload)
defer C.free(datap)
meid := C.CString("ric")