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.YangInstanceIdentifier.NodeIdentifier;
17 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
18 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
22 public class Onf14DomEthernetContainerNotificationListener implements DOMNotificationListener {
24 private static final Logger log = LoggerFactory.getLogger(Onf14DomEthernetContainerNotificationListener.class);
26 private final NetconfDomAccessor netconfDomAccessor;
27 private final DeviceManagerServiceProvider serviceProvider;
29 public Onf14DomEthernetContainerNotificationListener(NetconfDomAccessor netconfDomAccessor,
30 DeviceManagerServiceProvider serviceProvider) {
31 this.netconfDomAccessor = netconfDomAccessor;
32 this.serviceProvider = serviceProvider;
36 public void onNotification(@NonNull DOMNotification domNotification) {
37 log.debug("Got event of type :: {}", domNotification.getType());
38 if (domNotification.getType()
39 .equals(Absolute.of(Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_CREATE_NOTIFICATION))) {
40 onObjectCreationNotification(domNotification);
41 } else if (domNotification.getType()
42 .equals(Absolute.of(Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_AVC_NOTIFICATION))) {
43 onAttributeValueChangedNotification(domNotification);
44 } else if (domNotification.getType()
45 .equals(Absolute.of(Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_PROBLEM_NOTIFICATION))) {
46 onProblemNotification(domNotification);
47 } else if (domNotification.getType()
48 .equals(Absolute.of(Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_DELETE_NOTIFICATION))) {
49 onObjectDeletionNotification(domNotification);
53 public void onObjectDeletionNotification(DOMNotification notification) {
55 ContainerNode cn = notification.getBody();
56 EventlogBuilder eventlogBuilder = new EventlogBuilder();
57 eventlogBuilder.setNodeId(netconfDomAccessor.getNodeId().getValue()).setAttributeName("")
58 .setCounter(Integer.parseInt(Onf14DMDOMUtility.getLeafValue(cn,
59 Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_DELETE_NOTIFICATION_COUNTER)))
60 .setNewValue("deleted")
61 .setObjectId(Onf14DMDOMUtility.getLeafValue(cn,
62 Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_DELETE_NOTIFICATION_OBJECT_ID_REF))
64 .setSourceType(SourceType.Netconf).setTimestamp(new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn,
65 Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_DELETE_NOTIFICATION_TIMESTAMP)));
66 serviceProvider.getDataProvider().writeEventLog(eventlogBuilder.build());
67 serviceProvider.getNotificationService().deletionNotification(netconfDomAccessor.getNodeId(),
68 Integer.parseInt(Onf14DMDOMUtility.getLeafValue(cn,
69 Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_DELETE_NOTIFICATION_COUNTER)),
70 new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn,
71 Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_DELETE_NOTIFICATION_TIMESTAMP)),
72 Onf14DMDOMUtility.getLeafValue(cn,
73 Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_DELETE_NOTIFICATION_OBJECT_ID_REF));
75 log.debug("onObjectDeletionNotification log entry written");
78 public void onProblemNotification(DOMNotification notification) {
80 ContainerNode cn = notification.getBody();
81 FaultlogEntity faultAlarm = new FaultlogBuilder()
82 .setObjectId(Onf14DMDOMUtility.getLeafValue(cn,
83 Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_PROBLEM_NOTIFICATION_OBJECT_ID_REF))
84 .setProblem(Onf14DMDOMUtility.getLeafValue(cn,
85 Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_PROBLEM_NOTIFICATION_PROBLEM))
86 .setTimestamp(new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn,
87 Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_PROBLEM_NOTIFICATION_TIMESTAMP)))
88 .setNodeId(this.netconfDomAccessor.getNodeId().getValue()).setSourceType(SourceType.Netconf)
89 .setSeverity(InternalDataModelSeverity.mapSeverity(Onf14DMDOMUtility.getLeafValue(cn,
90 Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_PROBLEM_NOTIFICATION_SEVERITY)))
91 .setCounter(Integer.parseInt(Onf14DMDOMUtility.getLeafValue(cn,
92 Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_PROBLEM_NOTIFICATION_COUNTER)))
94 serviceProvider.getFaultService().faultNotification(faultAlarm);
95 serviceProvider.getWebsocketService()
96 .sendNotification(notification, netconfDomAccessor.getNodeId(),
97 Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_PROBLEM_NOTIFICATION_OBJECT_ID_REF,
98 new DateAndTime(cn.childByArg(new NodeIdentifier(
99 Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_PROBLEM_NOTIFICATION_TIMESTAMP))
100 .body().toString()));
104 public void onAttributeValueChangedNotification(DOMNotification notification) {
106 ContainerNode cn = notification.getBody();
107 EventlogBuilder eventlogBuilder = new EventlogBuilder();
108 eventlogBuilder.setNodeId(netconfDomAccessor.getNodeId().getValue())
109 .setAttributeName(Onf14DMDOMUtility.getLeafValue(cn,
110 Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_AVC_NOTIFICATION_ATTRIBUTE_NAME))
111 .setCounter(Integer.parseInt(Onf14DMDOMUtility.getLeafValue(cn,
112 Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_PROBLEM_NOTIFICATION_COUNTER)))
113 .setNewValue(Onf14DMDOMUtility.getLeafValue(cn,
114 Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_AVC_NOTIFICATION_NEW_VALUE))
115 .setObjectId(Onf14DMDOMUtility.getLeafValue(cn,
116 Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_AVC_NOTIFICATION_OBJECT_ID_REF))
117 .setSourceType(SourceType.Netconf).setTimestamp(new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn,
118 Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_AVC_NOTIFICATION_TIMESTAMP)));
119 serviceProvider.getDataProvider().writeEventLog(eventlogBuilder.build());
120 serviceProvider.getWebsocketService().sendNotification(notification, netconfDomAccessor.getNodeId(),
121 Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_AVC_NOTIFICATION,
122 new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn,
123 Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_AVC_NOTIFICATION_TIMESTAMP)));
125 log.debug("onAttributeValueChangedNotification log entry written");
128 public void onObjectCreationNotification(DOMNotification notification) {
130 ContainerNode cn = notification.getBody();
131 EventlogBuilder eventlogBuilder = new EventlogBuilder();
132 eventlogBuilder.setNodeId(netconfDomAccessor.getNodeId().getValue())
133 .setAttributeName(Onf14DMDOMUtility.getLeafValue(cn,
134 Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_CREATE_NOTIFICATION_OBJECT_ID_REF))
135 .setCounter(Integer.parseInt(Onf14DMDOMUtility.getLeafValue(cn,
136 Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_CREATE_NOTIFICATION_COUNTER)))
137 .setNewValue("created")
138 .setObjectId(Onf14DMDOMUtility.getLeafValue(cn,
139 Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_CREATE_NOTIFICATION_OBJECT_ID_REF))
141 .setSourceType(SourceType.Netconf).setTimestamp(new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn,
142 Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_CREATE_NOTIFICATION_TIMESTAMP)));
143 serviceProvider.getDataProvider().writeEventLog(eventlogBuilder.build());
144 serviceProvider.getWebsocketService().sendNotification(notification, netconfDomAccessor.getNodeId(),
145 Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_CREATE_NOTIFICATION,
146 new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn,
147 Onf14DevicemanagerQNames.ETHERNET_CONTAINER_OBJECT_CREATE_NOTIFICATION_TIMESTAMP)));
149 log.debug("onObjectCreationNotification log entry written");