2 * ============LICENSE_START=======================================================
3 * ONAP : ccsdk feature sdnr wt
4 * ================================================================================
5 * Copyright (C) 2020 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.onf14.dom.impl;
24 import org.eclipse.jdt.annotation.NonNull;
25 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.dataprovider.InternalDataModelSeverity;
26 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DMDOMUtility;
27 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DevicemanagerQNames;
28 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
29 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor;
30 import org.opendaylight.mdsal.dom.api.DOMNotification;
31 import org.opendaylight.mdsal.dom.api.DOMNotificationListener;
32 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogBuilder;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultlogBuilder;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultlogEntity;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SourceType;
37 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
38 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
39 import org.slf4j.Logger;
40 import org.slf4j.LoggerFactory;
42 public class Onf14DomAirInterfaceNotificationListener implements DOMNotificationListener {
44 private static final Logger log = LoggerFactory.getLogger(Onf14DomAirInterfaceNotificationListener.class);
46 private final NetconfDomAccessor netconfDomAccessor;
47 private final DeviceManagerServiceProvider serviceProvider;
49 public Onf14DomAirInterfaceNotificationListener(NetconfDomAccessor netconfDomAccessor,
50 DeviceManagerServiceProvider serviceProvider) {
51 this.netconfDomAccessor = netconfDomAccessor;
52 this.serviceProvider = serviceProvider;
56 public void onNotification(@NonNull DOMNotification domNotification) {
57 if (domNotification.getType()
58 .equals(Absolute.of(Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_CREATE_NOTIFICATION))) {
59 onObjectCreateNotification(domNotification);
60 } else if (domNotification.getType()
61 .equals(Absolute.of(Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_AVC_NOTIFICATION))) {
62 onObjectAVCNotification(domNotification);
63 } else if (domNotification.getType()
64 .equals(Absolute.of(Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_PROBLEM_NOTIFICATION))) {
65 onObjectProblemNotification(domNotification);
66 } else if (domNotification.getType()
67 .equals(Absolute.of(Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_DELETE_NOTIFICATION))) {
68 onObjectDeletionNotification(domNotification);
72 private void onObjectCreateNotification(@NonNull DOMNotification domNotification) {
74 ContainerNode cn = domNotification.getBody();
76 EventlogBuilder eventlogBuilder = new EventlogBuilder();
77 eventlogBuilder.setNodeId(netconfDomAccessor.getNodeId().getValue())
78 .setAttributeName(Onf14DMDOMUtility.getLeafValue(cn,
79 Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_CREATE_NOTIFICATION_OBJECT_TYPE))
80 .setCounter(Integer.parseInt(Onf14DMDOMUtility.getLeafValue(cn,
81 Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_CREATE_NOTIFICATION_COUNTER)))
82 .setNewValue("created")
83 .setObjectId(Onf14DMDOMUtility.getLeafValue(cn,
84 Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_CREATE_NOTIFICATION_OBJECT_ID_REF))
85 .setSourceType(SourceType.Netconf).setTimestamp(new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn,
86 Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_CREATE_NOTIFICATION_TIMESTAMP)));
88 serviceProvider.getDataProvider().writeEventLog(eventlogBuilder.build());
89 serviceProvider.getWebsocketService().sendNotification(domNotification, netconfDomAccessor.getNodeId(),
90 Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_CREATE_NOTIFICATION,
91 new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn,
92 Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_CREATE_NOTIFICATION_TIMESTAMP)));
93 log.debug("onObjectCreationNotification log entry written");
96 private void onObjectAVCNotification(@NonNull DOMNotification domNotification) {
98 ContainerNode cn = domNotification.getBody();
99 EventlogBuilder eventlogBuilder = new EventlogBuilder();
100 eventlogBuilder.setNodeId(netconfDomAccessor.getNodeId().getValue())
101 .setAttributeName(Onf14DMDOMUtility.getLeafValue(cn,
102 Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_AVC_NOTIFICATION_ATTRIBUTE_NAME))
103 .setCounter(Integer.parseInt(Onf14DMDOMUtility.getLeafValue(cn,
104 Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_AVC_NOTIFICATION_COUNTER)))
105 .setNewValue(Onf14DMDOMUtility.getLeafValue(cn,
106 Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_AVC_NOTIFICATION_NEW_VALUE))
107 .setObjectId(Onf14DMDOMUtility.getLeafValue(cn,
108 Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_AVC_NOTIFICATION_OBJECT_ID_REF))
109 .setSourceType(SourceType.Netconf).setTimestamp(new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn,
110 Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_AVC_NOTIFICATION_TIMESTAMP)));
112 serviceProvider.getDataProvider().writeEventLog(eventlogBuilder.build());
113 serviceProvider.getWebsocketService().sendNotification(domNotification, netconfDomAccessor.getNodeId(),
114 Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_AVC_NOTIFICATION, new DateAndTime(Onf14DMDOMUtility
115 .getLeafValue(cn, Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_AVC_NOTIFICATION_TIMESTAMP)));
116 log.debug("onAttributeValueChangedNotification log entry written");
119 private void onObjectProblemNotification(@NonNull DOMNotification domNotification) {
121 ContainerNode cn = domNotification.getBody();
122 FaultlogEntity faultAlarm =
123 new FaultlogBuilder()
124 .setObjectId(Onf14DMDOMUtility.getLeafValue(cn,
125 Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_OBJECT_ID_REF))
126 .setProblem(Onf14DMDOMUtility.getLeafValue(cn,
127 Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_PROBLEM))
128 .setSourceType(SourceType.Netconf)
129 .setTimestamp(new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn,
130 Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_TIMESTAMP)))
131 .setNodeId(this.netconfDomAccessor.getNodeId().getValue())
132 .setSeverity(InternalDataModelSeverity.mapSeverity(Onf14DMDOMUtility.getLeafValue(cn,
133 Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_SEVERITY)))
134 .setCounter(Integer.parseInt(Onf14DMDOMUtility.getLeafValue(cn,
135 Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_COUNTER)))
138 serviceProvider.getFaultService().faultNotification(faultAlarm);
139 serviceProvider.getWebsocketService().sendNotification(domNotification, netconfDomAccessor.getNodeId(),
140 Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_PROBLEM_NOTIFICATION,
141 new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn,
142 Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_TIMESTAMP)));
145 private void onObjectDeletionNotification(@NonNull DOMNotification domNotification) {
147 ContainerNode cn = domNotification.getBody();
148 EventlogBuilder eventlogBuilder = new EventlogBuilder();
149 eventlogBuilder.setNodeId(netconfDomAccessor.getNodeId().getValue()).setAttributeName("")
150 .setCounter(Integer.parseInt(Onf14DMDOMUtility.getLeafValue(cn,
151 Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_DELETE_NOTIFICATION_COUNTER)))
152 .setNewValue("deleted")
153 .setObjectId(Onf14DMDOMUtility.getLeafValue(cn,
154 Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_DELETE_NOTIFICATION_OBJECT_ID_REF))
156 .setSourceType(SourceType.Netconf).setTimestamp(new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn,
157 Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_DELETE_NOTIFICATION_TIMESTAMP)));
159 serviceProvider.getDataProvider().writeEventLog(eventlogBuilder.build());
160 serviceProvider.getWebsocketService().sendNotification(domNotification, netconfDomAccessor.getNodeId(),
161 Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_DELETE_NOTIFICATION,
162 new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn,
163 Onf14DevicemanagerQNames.AIR_INTERFACE_OBJECT_DELETE_NOTIFICATION_TIMESTAMP)));
165 log.debug("onObjectDeletionNotification log entry written");