2 * ============LICENSE_START=======================================================
3 * ONAP : ccsdk features
4 * ================================================================================
5 * Copyright (C) 2023 highstreet technologies GmbH Intellectual Property.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.vesmapper;
24 import com.fasterxml.jackson.annotation.JsonProperty;
25 import java.time.Instant;
26 import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.util.ORanDMDOMUtility;
27 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService;
28 import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESCommonEventHeaderPOJO;
29 import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESStndDefinedFieldsPOJO;
30 import org.opendaylight.mdsal.dom.api.DOMNotification;
31 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
36 "stndDefinedFields": {
37 "schemaReference": "https://gerrit.o-ran-sc.org/r/gitweb?p=scp/oam/modeling.git;a=blob_plain;f=data-model/yang/published/o-ran/ru-fh/o-ran-supervision.yang#components/schemas/ofhm-event-stream",
38 "stndDefinedFieldsVersion": "1.0",
40 "ietf:notification": {
41 "eventTime": "2023-06-28T07:28:55.098Z",
42 "o-ran-supervision:supervision-notification": {
48 "commonEventHeader": {
49 "domain": "stndDefined",
50 "eventType": "o-ran-supervision:supervision-notification",
51 "eventId": "pnf2_o-ran-supervision:supervision-notification_fed2ab31f6e1da56",
52 "eventName": "stndDefined_o-ran-supervision:supervision-notification",
53 "sequence": 1687937335098,
55 "reportingEntityId": "c2b7d6e9-ee35-459a-ab8e-717a6fc1fde6",
56 "reportingEntityName": "flows",
57 "sourceId": "378e9904-6d39-40ea-9994-0596fe2235a3",
58 "sourceName": "O-RAN-SC-OAM-Test-Component-01",
59 "startEpochMicrosec": 1687937335098000,
60 "lastEpochMicrosec": 1687937335098000,
61 "nfNamingCode": "pnf2",
62 "nfVendorName": "O-RAN-SC-OAM-Project",
63 "timeZoneOffset": "+00:00",
64 "stndDefinedNamespace": "o-ran-supervision:supervision-notification",
66 "vesEventListenerVersion": "7.2.1"
71 public class ORanDOMSupervisionNotifToVESMapper {
73 private static final String VES_EVENT_DOMAIN = "stndDefined";
74 private static final String VES_EVENTTYPE = "o-ran-supervision:supervision-notification";
75 private static final String VES_EVENT_PRIORITY = "Low";
76 private static final String O_RU_SUPERVISION_SCHEMA_REFERENCE =
77 "https://gerrit.o-ran-sc.org/r/gitweb?p=scp/oam/modeling.git;a=blob_plain;f=data-model/yang/published/o-ran/ru-fh/o-ran-supervision.yang#components/schemas/ofhm-event-stream";
78 private final VESCollectorService vesProvider;
79 private final String notifName;
80 private final String nodeIdString;
81 //Initialized during registration
82 private String mfgName;
84 private String modelName;
86 public ORanDOMSupervisionNotifToVESMapper(NodeId nodeId, VESCollectorService vesCollectorService,
88 this.nodeIdString = nodeId.getValue();
89 this.vesProvider = vesCollectorService;
90 this.notifName = notifName;
93 public void setMfgName(String mfgName) {
94 this.mfgName = mfgName;
97 public void setUuid(String uuid) {
101 public void setModelName(String modelName) {
102 this.modelName = modelName;
105 public VESCommonEventHeaderPOJO mapCommonEventHeader(DOMNotification notification, Instant eventTime,
107 VESCommonEventHeaderPOJO vesCEH = new VESCommonEventHeaderPOJO();
108 vesCEH.setDomain(VES_EVENT_DOMAIN);
109 vesCEH.setEventName(VES_EVENT_DOMAIN + "_" + VES_EVENTTYPE);
110 vesCEH.setEventType(VES_EVENTTYPE);
111 vesCEH.setPriority(VES_EVENT_PRIORITY);
113 String eventId = notifName + "-" + Long.toUnsignedString(sequenceNo);
115 vesCEH.setEventId(eventId);
116 vesCEH.setStartEpochMicrosec(eventTime.toEpochMilli() * 1000);
117 vesCEH.setLastEpochMicrosec(eventTime.toEpochMilli() * 1000);
118 vesCEH.setNfVendorName(mfgName);
119 vesCEH.setReportingEntityName(vesProvider.getConfig().getReportingEntityName());
120 vesCEH.setSequence(sequenceNo);
121 vesCEH.setSourceId(uuid);
122 vesCEH.setSourceName(nodeIdString);
127 public VESStndDefinedFieldsPOJO mapStndDefinedFields(Instant eventTimeInstant) {
128 VESStndDefinedFieldsPOJO vesStndDefFields = new VESStndDefinedFieldsPOJO();
129 vesStndDefFields.setSchemaReference(O_RU_SUPERVISION_SCHEMA_REFERENCE);
130 vesStndDefFields.setData(getSupervisionData(eventTimeInstant));
132 return vesStndDefFields;
135 private DataObject getSupervisionData(Instant eventTimeInstant) {
136 ORanSupervisionNotification oruSuperNotif = new ORanSupervisionNotification();
137 oruSuperNotif.setSessionId(999999); // Hardcoded due to limitation in NTS Simulator. Ideally should be NETCONF Session ID
139 IetfNotification ietfNotif = new IetfNotification();
140 ietfNotif.setOranSupervisionNotif(oruSuperNotif);
141 ietfNotif.setEventTime(ORanDMDOMUtility.getDateAndTimeOfInstant(eventTimeInstant).getValue());
143 DataObject data = new DataObject();
144 data.setIetfNotification(ietfNotif);
150 /* Classes for serialization of stndDefinedFields "data" object */
152 @JsonProperty("ietf:notification")
153 IetfNotification ietfNotification;
155 public DataObject() {}
157 public IetfNotification getIetfNotification() {
158 return ietfNotification;
161 public void setIetfNotification(IetfNotification ietfNotification) {
162 this.ietfNotification = ietfNotification;
167 class IetfNotification {
169 @JsonProperty("o-ran-supervision:supervision-notification")
170 ORanSupervisionNotification oranSupervisionNotif;
172 public IetfNotification() {}
174 public String getEventTime() {
178 public void setEventTime(String eventTime) {
179 this.eventTime = eventTime;
182 public ORanSupervisionNotification getOranSupervisionNotif() {
183 return oranSupervisionNotif;
186 public void setOranSupervisionNotif(ORanSupervisionNotification oranSupervisionNotif) {
187 this.oranSupervisionNotif = oranSupervisionNotif;
193 class ORanSupervisionNotification {
194 @JsonProperty("session-id")
197 public ORanSupervisionNotification() {}
199 public int getSessionId() {
203 public void setSessionId(int sessionId) {
204 this.sessionId = sessionId;