1 package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl;
3 import org.eclipse.jdt.annotation.NonNull;
4 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.dataprovider.InternalDataModelSeverity;
5 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DMDOMUtility;
6 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.impl.util.Onf14DevicemanagerQNames;
7 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
8 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor;
9 import org.opendaylight.mdsal.dom.api.DOMNotification;
10 import org.opendaylight.mdsal.dom.api.DOMNotificationListener;
11 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogBuilder;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultlogBuilder;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultlogEntity;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SourceType;
16 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
17 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
21 public class Onf14DomWireInterfaceNotificationListener implements DOMNotificationListener {
23 private static final Logger log = LoggerFactory.getLogger(Onf14DomWireInterfaceNotificationListener.class);
25 private final NetconfDomAccessor netconfDomAccessor;
26 private final DeviceManagerServiceProvider serviceProvider;
28 public Onf14DomWireInterfaceNotificationListener(NetconfDomAccessor netconfDomAccessor,
29 DeviceManagerServiceProvider serviceProvider) {
30 this.netconfDomAccessor = netconfDomAccessor;
31 this.serviceProvider = serviceProvider;
35 public void onNotification(@NonNull DOMNotification domNotification) {
36 log.debug("Got event of type :: {}", domNotification.getType());
37 if (domNotification.getType()
38 .equals(Absolute.of(Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_CREATE_NOTIFICATION))) {
39 onObjectCreationNotification(domNotification);
40 } else if (domNotification.getType()
41 .equals(Absolute.of(Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_AVC_NOTIFICATION))) {
42 onAttributeValueChangedNotification(domNotification);
43 } else if (domNotification.getType()
44 .equals(Absolute.of(Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION))) {
45 onProblemNotification(domNotification);
46 } else if (domNotification.getType()
47 .equals(Absolute.of(Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_DELETE_NOTIFICATION))) {
48 onObjectDeletionNotification(domNotification);
52 public void onObjectDeletionNotification(DOMNotification notification) {
54 ContainerNode cn = notification.getBody();
55 EventlogBuilder eventlogBuilder = new EventlogBuilder();
56 eventlogBuilder.setNodeId(netconfDomAccessor.getNodeId().getValue()).setAttributeName("")
57 .setCounter(Integer.parseInt(Onf14DMDOMUtility.getLeafValue(cn,
58 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_DELETE_NOTIFICATION_COUNTER)))
59 .setNewValue("deleted")
60 .setObjectId(Onf14DMDOMUtility.getLeafValue(cn,
61 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_DELETE_NOTIFICATION_OBJECT_ID_REF))
62 .setSourceType(SourceType.Netconf).setTimestamp(new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn,
63 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_DELETE_NOTIFICATION_TIMESTAMP)));
64 serviceProvider.getDataProvider().writeEventLog(eventlogBuilder.build());
65 serviceProvider.getWebsocketService().sendNotification(notification, netconfDomAccessor.getNodeId(),
66 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_DELETE_NOTIFICATION,
67 new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn,
68 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_DELETE_NOTIFICATION_TIMESTAMP)));
70 log.debug("onObjectDeletionNotification log entry written");
73 public void onProblemNotification(DOMNotification notification) {
75 ContainerNode cn = notification.getBody();
76 FaultlogEntity faultAlarm =
78 .setObjectId(Onf14DMDOMUtility.getLeafValue(cn,
79 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_OBJECT_ID_REF))
80 .setProblem(Onf14DMDOMUtility.getLeafValue(cn,
81 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_PROBLEM))
82 .setTimestamp(new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn,
83 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_TIMESTAMP)))
84 .setNodeId(this.netconfDomAccessor.getNodeId().getValue()).setSourceType(SourceType.Netconf)
85 .setSeverity(InternalDataModelSeverity.mapSeverity(Onf14DMDOMUtility.getLeafValue(cn,
86 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_SEVERITY)))
87 .setCounter(Integer.parseInt(Onf14DMDOMUtility.getLeafValue(cn,
88 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_COUNTER)))
90 serviceProvider.getFaultService().faultNotification(faultAlarm);
91 serviceProvider.getWebsocketService().sendNotification(notification, netconfDomAccessor.getNodeId(),
92 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION,
93 new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn,
94 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_TIMESTAMP)));
98 public void onAttributeValueChangedNotification(DOMNotification notification) {
100 ContainerNode cn = notification.getBody();
101 EventlogBuilder eventlogBuilder = new EventlogBuilder();
102 eventlogBuilder.setNodeId(netconfDomAccessor.getNodeId().getValue())
103 .setAttributeName(Onf14DMDOMUtility.getLeafValue(cn,
104 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_AVC_NOTIFICATION_ATTRIBUTE_NAME))
105 .setCounter(Integer.parseInt(Onf14DMDOMUtility.getLeafValue(cn,
106 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_COUNTER)))
107 .setNewValue(Onf14DMDOMUtility.getLeafValue(cn,
108 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_AVC_NOTIFICATION_NEW_VALUE))
109 .setObjectId(Onf14DMDOMUtility.getLeafValue(cn,
110 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_OBJECT_ID_REF))
111 .setSourceType(SourceType.Netconf).setTimestamp(new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn,
112 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_TIMESTAMP)));
113 serviceProvider.getDataProvider().writeEventLog(eventlogBuilder.build());
114 serviceProvider.getWebsocketService().sendNotification(notification, netconfDomAccessor.getNodeId(),
115 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_AVC_NOTIFICATION,
116 new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn,
117 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_TIMESTAMP)));
119 log.debug("onAttributeValueChangedNotification log entry written");
122 public void onObjectCreationNotification(DOMNotification notification) {
124 ContainerNode cn = notification.getBody();
125 EventlogBuilder eventlogBuilder = new EventlogBuilder();
126 eventlogBuilder.setNodeId(netconfDomAccessor.getNodeId().getValue())
127 .setAttributeName(Onf14DMDOMUtility.getLeafValue(cn,
128 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_CREATE_NOTIFICATION_OBJECT_TYPE))
129 .setCounter(Integer.parseInt(Onf14DMDOMUtility.getLeafValue(cn,
130 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_COUNTER)))
131 .setNewValue("created")
132 .setObjectId(Onf14DMDOMUtility.getLeafValue(cn,
133 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_OBJECT_ID_REF))
135 .setSourceType(SourceType.Netconf).setTimestamp(new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn,
136 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_TIMESTAMP)));
137 serviceProvider.getDataProvider().writeEventLog(eventlogBuilder.build());
138 serviceProvider.getWebsocketService().sendNotification(notification, netconfDomAccessor.getNodeId(),
139 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_CREATE_NOTIFICATION,
140 new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn,
141 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_TIMESTAMP)));
143 log.debug("onObjectCreationNotification log entry written");