LN0739_FM_FR8: relaxing the active alarm and alarm history restrictions
[ric-plt/alarm-go.git] / alarm / types.go
1 /*
2  *  Copyright (c) 2020 AT&T Intellectual Property.
3  *  Copyright (c) 2020 Nokia.
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  * This source code is part of the near-RT RIC (RAN Intelligent Controller)
18  * platform project (RICP).
19  */
20
21 package alarm
22
23 import (
24         "sync"
25         "unsafe"
26 )
27
28 import "C"
29
30 // Severity for alarms
31 type Severity string
32
33 // Possible values for Severity
34 const (
35         SeverityUnspecified Severity = "UNSPECIFIED"
36         SeverityCritical    Severity = "CRITICAL"
37         SeverityMajor       Severity = "MAJOR"
38         SeverityMinor       Severity = "MINOR"
39         SeverityWarning     Severity = "WARNING"
40         SeverityCleared     Severity = "CLEARED"
41         SeverityDefault     Severity = "DEFAULT"
42 )
43
44 // Alarm object - see README for more information
45 type Alarm struct {
46         ManagedObjectId   string   `json:"managedObjectId"`
47         ApplicationId     string   `json:"applicationId"`
48         SpecificProblem   int      `json:"specificProblem"`
49         PerceivedSeverity Severity `json:"perceivedSeverity"`
50         AdditionalInfo    string   `json:"additionalInfo"`
51         IdentifyingInfo   string   `json:"identifyingInfo"`
52 }
53
54 // Alarm actions
55 type AlarmAction string
56
57 // Possible values for alarm actions
58 const (
59         AlarmActionRaise    AlarmAction = "RAISE"
60         AlarmActionClear    AlarmAction = "CLEAR"
61         AlarmActionClearAll AlarmAction = "CLEARALL"
62 )
63
64 type AlarmMessage struct {
65         Alarm
66         AlarmAction
67         AlarmTime int64
68 }
69
70 type AlarmConfigParams struct {
71         MaxActiveAlarms int `json:"maxactivealarms"`
72         MaxAlarmHistory int `json:"maxalarmhistory"`
73 }
74
75 // RICAlarm is an alarm instance
76 type RICAlarm struct {
77         moId       string
78         appId      string
79         managerUrl string
80         rmrCtx     unsafe.Pointer
81         rmrReady   bool
82         mutex      sync.Mutex
83 }
84
85 const (
86         RIC_ALARM_UPDATE = 13111
87         RIC_ALARM_QUERY  = 13112
88 )
89
90 // Temp alarm constants & definitions
91 const (
92         RIC_RT_DISTRIBUTION_FAILED     int = 8004
93         TCP_CONNECTIVITY_LOST_TO_DBAAS int = 8005
94         E2_CONNECTIVITY_LOST_TO_GNODEB int = 8006
95         E2_CONNECTIVITY_LOST_TO_ENODEB int = 8007
96         ACTIVE_ALARM_EXCEED_MAX_THRESHOLD int = 8008
97         ALARM_HISTORY_EXCEED_MAX_THRESHOLD int = 8009
98 )
99
100 type AlarmDefinition struct {
101         AlarmId               int
102         AlarmText             string
103         EventType             string
104         OperationInstructions string
105 }
106
107 var RICAlarmDefinitions = map[int]AlarmDefinition{
108         RIC_RT_DISTRIBUTION_FAILED: {
109                 AlarmId:               RIC_RT_DISTRIBUTION_FAILED,
110                 AlarmText:             "RIC ROUTING TABLE DISTRIBUTION FAILED",
111                 EventType:             "Processing error",
112                 OperationInstructions: "Not defined",
113         },
114         TCP_CONNECTIVITY_LOST_TO_DBAAS: {
115                 AlarmId:               TCP_CONNECTIVITY_LOST_TO_DBAAS,
116                 AlarmText:             "TCP CONNECTIVITY LOST TO DBAAS",
117                 EventType:             "Communication error",
118                 OperationInstructions: "Not defined",
119         },
120         E2_CONNECTIVITY_LOST_TO_GNODEB: {
121                 AlarmId:               E2_CONNECTIVITY_LOST_TO_GNODEB,
122                 AlarmText:             "E2 CONNECTIVITY LOST TO G-NODEB",
123                 EventType:             "Communication error",
124                 OperationInstructions: "Not defined",
125         },
126         E2_CONNECTIVITY_LOST_TO_ENODEB: {
127                 AlarmId:               E2_CONNECTIVITY_LOST_TO_ENODEB,
128                 AlarmText:             "E2 CONNECTIVITY LOST TO E-NODEB",
129                 EventType:             "Communication error",
130                 OperationInstructions: "Not defined",
131         },
132         ACTIVE_ALARM_EXCEED_MAX_THRESHOLD: {
133                 AlarmId:               ACTIVE_ALARM_EXCEED_MAX_THRESHOLD,
134                 AlarmText:             "ACTIVE ALARM EXCEED MAX THRESHOLD",
135                 EventType:             "Warning",
136                 OperationInstructions: "Not defined",
137         },
138         ALARM_HISTORY_EXCEED_MAX_THRESHOLD: {
139                 AlarmId:               ALARM_HISTORY_EXCEED_MAX_THRESHOLD,
140                 AlarmText:             "ALARM HISTORY EXCEED MAX THRESHOLD",
141                 EventType:             "Warning",
142                 OperationInstructions: "Not defined",
143         },
144 }
145
146 const (
147         ALARM_MANAGER_HTTP_URL string = "http://service-ricplt-alarmmanager-http.ricplt:8080"
148         ALARM_MANAGER_RMR_URL  string = "service-ricplt-alarmmanager-rmr.ricplt:4560"
149 )