From: Abukar Mohamed Date: Thu, 18 Jun 2020 10:12:24 +0000 (+0000) Subject: Merge "Add license file" X-Git-Tag: 0.4.5^0 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=c8687a0e843eb98d91f3f669a2d3dcc680def039;hp=53831083d61a5f2b8a64328187de91767659492b;p=ric-plt%2Falarm-go.git Merge "Add license file" --- diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..38b6a85 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,21 @@ +# https://help.github.com/articles/dealing-with-line-endings/ + +# Set the default behavior, in case people don't have core.autocrlf set. +* text=auto + +# Explicitly declare text files you want to always be normalized +# and converted to native line endings on checkout. +*.css text +*.htm text diff=html +*.html text diff=html +*.java text diff=java +*.js text +*.jsp text +*.less text +*.properties text +*.sql text +*.xml text + +# Denote all files that are truly binary and should not be modified. +*.png binary +*.jpg binary diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5cd11dc --- /dev/null +++ b/.gitignore @@ -0,0 +1,56 @@ +# See http://help.github.com/ignore-files/ for more about ignoring files. + +/logs + +# compiled output +/dist +/tmp +/out-tsc + +# dependencies +/node +/node_modules + +/.classpath +/.project +/.settings +/target/ +/.mvn/wrapper/maven-wrapper.jar +/.tox + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +/build/ + +### visual studio ### +.vs +**/.vscode + +# OSx cruft +**/.DS_Store + +# documentation +.tox +docs/_build/* + +# JSON internal data +dashboard/webapp-backend/app-stats.json diff --git a/.readthedocs.yaml b/.readthedocs.yaml new file mode 100644 index 0000000..3797dc8 --- /dev/null +++ b/.readthedocs.yaml @@ -0,0 +1,20 @@ +--- +# .readthedocs.yml +# Read the Docs configuration file +# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details +# Required +version: 2 + +formats: + - htmlzip + +build: + image: latest + +python: + version: 3.7 + install: + - requirements: docs/requirements-docs.txt + +sphinx: + configuration: docs/conf.py diff --git a/README.md b/README.md old mode 100755 new mode 100644 diff --git a/adapter/Dockerfile b/adapter/Dockerfile old mode 100755 new mode 100644 index 87851a5..65d94d0 --- a/adapter/Dockerfile +++ b/adapter/Dockerfile @@ -18,7 +18,7 @@ # platform project (RICP). #================================================================================== -FROM nexus3.o-ran-sc.org:10004/bldr-ubuntu18-c-go:7-u18.04 as ubuntu-alarmadapter +FROM nexus3.o-ran-sc.org:10004/o-ran-sc/bldr-ubuntu18-c-go:8-u18.04 as ubuntu-alarmadapter # Install utilities RUN apt update && apt install -y iputils-ping net-tools curl sudo diff --git a/adapter/build_adapter_ubuntu.sh b/adapter/build_adapter_ubuntu.sh index 8f0aaf4..3bb4703 100755 --- a/adapter/build_adapter_ubuntu.sh +++ b/adapter/build_adapter_ubuntu.sh @@ -22,12 +22,12 @@ set -eux echo "--> build_adapter_ubuntu.sh starts" # Install RMR from deb packages at packagecloud.io -rmr=rmr_3.7.2_amd64.deb -wget --content-disposition https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/$rmr/download.deb +rmr=rmr_4.0.2_amd64.deb +wget --content-disposition https://packagecloud.io/o-ran-sc/release/packages/debian/stretch/$rmr/download.deb sudo dpkg -i $rmr rm $rmr -rmrdev=rmr-dev_3.7.2_amd64.deb -wget --content-disposition https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/$rmrdev/download.deb +rmrdev=rmr-dev_4.0.2_amd64.deb +wget --content-disposition https://packagecloud.io/o-ran-sc/release/packages/debian/stretch/$rmrdev/download.deb sudo dpkg -i $rmrdev rm $rmrdev diff --git a/adapter/cmd/adapter.go b/adapter/cmd/adapter.go index 7fa1f3b..76112f9 100755 --- a/adapter/cmd/adapter.go +++ b/adapter/cmd/adapter.go @@ -126,6 +126,7 @@ func (a *AlarmAdapter) Consume(rp *app.RMRParams) (err error) { 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 @@ -200,11 +201,11 @@ func (a *AlarmAdapter) GenerateAlertLabels(newAlarm alarm.Alarm, status AlertSta "alertname": alarmDef.AlarmText, "severity": string(newAlarm.PerceivedSeverity), "service": fmt.Sprintf("%s:%s", newAlarm.ManagedObjectId, newAlarm.ApplicationId), - "system_name": "RIC", + "system_name": fmt.Sprintf("RIC:%s:%s", newAlarm.ManagedObjectId, newAlarm.ApplicationId), } amAnnotations := models.LabelSet{ - "alarm_id": string(alarmDef.AlarmId), - "description": newAlarm.IdentifyingInfo, + "alarm_id": fmt.Sprintf("%d", alarmDef.AlarmId), + "description": fmt.Sprintf("%d:%s:%s", newAlarm.SpecificProblem, newAlarm.IdentifyingInfo, newAlarm.AdditionalInfo), "additional_info": newAlarm.AdditionalInfo, "summary": alarmDef.EventType, "instructions": alarmDef.OperationInstructions, @@ -228,7 +229,7 @@ func (a *AlarmAdapter) PostAlert(amLabels, amAnnotations models.LabelSet) (*aler } alertParams := alert.NewPostAlertsParams().WithAlerts(models.PostableAlerts{pa}) - app.Logger.Info("Posting alerts: labels: %v, annotations: %v", amLabels, amAnnotations) + app.Logger.Info("Posting alerts: labels: %+v, annotations: %+v", amLabels, amAnnotations) ok, err := a.NewAlertmanagerClient().Alert.PostAlerts(alertParams) if err != nil { app.Logger.Error("Posting alerts to '%s/%s' failed with error: %v", a.amHost, a.amBaseUrl, err) diff --git a/adapter/container-tag.yaml b/adapter/container-tag.yaml index cfdbfb8..a89789a 100644 --- a/adapter/container-tag.yaml +++ b/adapter/container-tag.yaml @@ -2,4 +2,4 @@ # By default this file is in the docker build directory, # but the location can configured in the JJB template. --- -tag: 0.4.4 +tag: 0.4.5 diff --git a/alarm-schema.json b/alarm-schema.json new file mode 100644 index 0000000..5e999ad --- /dev/null +++ b/alarm-schema.json @@ -0,0 +1,94 @@ +{ + "$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 + } + } +} diff --git a/alarm/Dockerfile-Unit-Test b/alarm/Dockerfile-Unit-Test new file mode 100644 index 0000000..a530771 --- /dev/null +++ b/alarm/Dockerfile-Unit-Test @@ -0,0 +1,35 @@ +# 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 diff --git a/alarm/alarm.go b/alarm/alarm.go old mode 100755 new mode 100644 index dddccb1..38e2134 --- a/alarm/alarm.go +++ b/alarm/alarm.go @@ -130,12 +130,14 @@ func (r *RICAlarm) sendAlarmUpdateReq(a AlarmMessage) error { 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") diff --git a/alarm/alarm_test.go b/alarm/alarm_test.go old mode 100755 new mode 100644 diff --git a/alarm/types.go b/alarm/types.go old mode 100755 new mode 100644 diff --git a/alarm/utils.c b/alarm/utils.c old mode 100755 new mode 100644 diff --git a/alarm/utils.h b/alarm/utils.h old mode 100755 new mode 100644 diff --git a/assets/alarm-adapter.png b/assets/alarm-adapter.png old mode 100755 new mode 100644 diff --git a/config/config-file.json b/config/config-file.json old mode 100755 new mode 100644 diff --git a/config/uta_rtg.rt b/config/uta_rtg.rt old mode 100755 new mode 100644 diff --git a/docs/index.rst b/docs/index.rst index 81be866..70333ae 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -16,8 +16,8 @@ .. limitations under the License. .. -Welcome to O-RAN Application Manager Documentation -================================================== +Alarm Go Library +================ .. toctree:: :maxdepth: 2 diff --git a/docs/release-notes.rst b/docs/release-notes.rst index 1e827ce..0f7be8e 100644 --- a/docs/release-notes.rst +++ b/docs/release-notes.rst @@ -17,7 +17,7 @@ .. -Release-Notes +Release Notes =============