- FM performance test tool first version for review
[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         PERFORMANCE_TEST_ALARM_1           int = 1001
93         PERFORMANCE_TEST_ALARM_2           int = 1002
94         PERFORMANCE_TEST_ALARM_3           int = 1003
95         PERFORMANCE_TEST_ALARM_4           int = 1004
96         PERFORMANCE_TEST_ALARM_5           int = 1005
97         PERFORMANCE_TEST_ALARM_6           int = 1006
98         PERFORMANCE_TEST_ALARM_7           int = 1007
99         PERFORMANCE_TEST_ALARM_8           int = 1008
100         PERFORMANCE_TEST_ALARM_9           int = 1009
101         PERFORMANCE_TEST_ALARM_10          int = 1010
102         PERFORMANCE_TEST_ALARM_11          int = 1011
103         PERFORMANCE_TEST_ALARM_12          int = 1012
104         PERFORMANCE_TEST_ALARM_13          int = 1013
105         PERFORMANCE_TEST_ALARM_14          int = 1014
106         PERFORMANCE_TEST_ALARM_15          int = 1015
107         PERFORMANCE_TEST_ALARM_16          int = 1016
108         PERFORMANCE_TEST_ALARM_17          int = 1017
109         PERFORMANCE_TEST_ALARM_18          int = 1018
110         PERFORMANCE_TEST_ALARM_19          int = 1019
111         PERFORMANCE_TEST_ALARM_20          int = 1020
112         PERFORMANCE_TEST_ALARM_21          int = 1021
113         PERFORMANCE_TEST_ALARM_22          int = 1022
114         PERFORMANCE_TEST_ALARM_23          int = 1023
115         PERFORMANCE_TEST_ALARM_24          int = 1024
116         PERFORMANCE_TEST_ALARM_25          int = 1025
117         PERFORMANCE_TEST_ALARM_26          int = 1026
118         PERFORMANCE_TEST_ALARM_27          int = 1027
119         PERFORMANCE_TEST_ALARM_28          int = 1028
120         PERFORMANCE_TEST_ALARM_29          int = 1029
121         PERFORMANCE_TEST_ALARM_30          int = 1030
122         PERFORMANCE_TEST_ALARM_31          int = 1031
123         PERFORMANCE_TEST_ALARM_32          int = 1032
124         PERFORMANCE_TEST_ALARM_33          int = 1033
125         PERFORMANCE_TEST_ALARM_34          int = 1034
126         PERFORMANCE_TEST_ALARM_35          int = 1035
127         PERFORMANCE_TEST_ALARM_36          int = 1036
128         PERFORMANCE_TEST_ALARM_37          int = 1037
129         PERFORMANCE_TEST_ALARM_38          int = 1038
130         PERFORMANCE_TEST_ALARM_39          int = 1039
131         PERFORMANCE_TEST_ALARM_40          int = 1040
132         PERFORMANCE_TEST_ALARM_41          int = 1041
133         PERFORMANCE_TEST_ALARM_42          int = 1042
134         PERFORMANCE_TEST_ALARM_43          int = 1043
135         PERFORMANCE_TEST_ALARM_44          int = 1044
136         PERFORMANCE_TEST_ALARM_45          int = 1045
137         PERFORMANCE_TEST_ALARM_46          int = 1046
138         PERFORMANCE_TEST_ALARM_47          int = 1047
139         PERFORMANCE_TEST_ALARM_48          int = 1048
140         PERFORMANCE_TEST_ALARM_49          int = 1049
141         PERFORMANCE_TEST_ALARM_50          int = 1050
142         RIC_RT_DISTRIBUTION_FAILED         int = 8004
143         TCP_CONNECTIVITY_LOST_TO_DBAAS     int = 8005
144         E2_CONNECTIVITY_LOST_TO_GNODEB     int = 8006
145         E2_CONNECTIVITY_LOST_TO_ENODEB     int = 8007
146         ACTIVE_ALARM_EXCEED_MAX_THRESHOLD  int = 8008
147         ALARM_HISTORY_EXCEED_MAX_THRESHOLD int = 8009
148 )
149
150 type AlarmDefinition struct {
151         AlarmId               int    `json:"alarmid"`
152         AlarmText             string `json:"alarmtext"`
153         EventType             string `json:"eventtype"`
154         OperationInstructions string `json:"operationinstructions"`
155 }
156
157 var RICAlarmDefinitions map[int]*AlarmDefinition
158 var RICPerfAlarmObjects map[int]*Alarm
159
160 const (
161         ALARM_MANAGER_HTTP_URL string = "http://service-ricplt-alarmmanager-http.ricplt:8080"
162         ALARM_MANAGER_RMR_URL  string = "service-ricplt-alarmmanager-rmr.ricplt:4560"
163 )