1 package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf14.dom.notifications;
 
   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 = new FaultlogBuilder()
 
  77                 .setObjectId(Onf14DMDOMUtility.getLeafValue(cn,
 
  78                         Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_OBJECT_ID_REF))
 
  79                 .setProblem(Onf14DMDOMUtility.getLeafValue(cn,
 
  80                         Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_PROBLEM))
 
  81                 .setTimestamp(new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn,
 
  82                         Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_TIMESTAMP)))
 
  83                 .setNodeId(this.netconfDomAccessor.getNodeId().getValue()).setSourceType(SourceType.Netconf)
 
  84                 .setSeverity(InternalDataModelSeverity.mapSeverity(Onf14DMDOMUtility.getLeafValue(cn,
 
  85                         Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_SEVERITY)))
 
  86                 .setCounter(Integer.parseInt(Onf14DMDOMUtility.getLeafValue(cn,
 
  87                         Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_COUNTER)))
 
  89         serviceProvider.getFaultService().faultNotification(faultAlarm);
 
  90         serviceProvider.getWebsocketService().sendNotification(notification, netconfDomAccessor.getNodeId(),
 
  91                 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION,
 
  92                 new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn,
 
  93                         Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_TIMESTAMP)));
 
  94         log.debug("onProblemNotification log entry written");
 
  97     public void onAttributeValueChangedNotification(DOMNotification notification) {
 
  99         ContainerNode cn = notification.getBody();
 
 100         EventlogBuilder eventlogBuilder = new EventlogBuilder();
 
 101         eventlogBuilder.setNodeId(netconfDomAccessor.getNodeId().getValue())
 
 102                 .setAttributeName(Onf14DMDOMUtility.getLeafValue(cn,
 
 103                         Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_AVC_NOTIFICATION_ATTRIBUTE_NAME))
 
 104                 .setCounter(Integer.parseInt(Onf14DMDOMUtility.getLeafValue(cn,
 
 105                         Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_COUNTER)))
 
 106                 .setNewValue(Onf14DMDOMUtility.getLeafValue(cn,
 
 107                         Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_AVC_NOTIFICATION_NEW_VALUE))
 
 108                 .setObjectId(Onf14DMDOMUtility.getLeafValue(cn,
 
 109                         Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_OBJECT_ID_REF))
 
 110                 .setSourceType(SourceType.Netconf).setTimestamp(new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn,
 
 111                         Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_TIMESTAMP)));
 
 112         serviceProvider.getDataProvider().writeEventLog(eventlogBuilder.build());
 
 113         serviceProvider.getWebsocketService().sendNotification(notification, netconfDomAccessor.getNodeId(),
 
 114                 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_AVC_NOTIFICATION,
 
 115                 new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn,
 
 116                         Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_TIMESTAMP)));
 
 118         log.debug("onAttributeValueChangedNotification log entry written");
 
 121     public void onObjectCreationNotification(DOMNotification notification) {
 
 123         ContainerNode cn = notification.getBody();
 
 124         EventlogBuilder eventlogBuilder = new EventlogBuilder();
 
 125         eventlogBuilder.setNodeId(netconfDomAccessor.getNodeId().getValue())
 
 126                 .setAttributeName(Onf14DMDOMUtility.getLeafValue(cn,
 
 127                         Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_CREATE_NOTIFICATION_OBJECT_TYPE))
 
 128                 .setCounter(Integer.parseInt(Onf14DMDOMUtility.getLeafValue(cn,
 
 129                         Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_COUNTER)))
 
 130                 .setNewValue("created")
 
 131                 .setObjectId(Onf14DMDOMUtility.getLeafValue(cn,
 
 132                         Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_OBJECT_ID_REF))
 
 134                 .setSourceType(SourceType.Netconf).setTimestamp(new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn,
 
 135                         Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_TIMESTAMP)));
 
 136         serviceProvider.getDataProvider().writeEventLog(eventlogBuilder.build());
 
 137         serviceProvider.getWebsocketService().sendNotification(notification, netconfDomAccessor.getNodeId(),
 
 138                 Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_CREATE_NOTIFICATION,
 
 139                 new DateAndTime(Onf14DMDOMUtility.getLeafValue(cn,
 
 140                         Onf14DevicemanagerQNames.WIRE_INTERFACE_OBJECT_PROBLEM_NOTIFICATION_TIMESTAMP)));
 
 142         log.debug("onObjectCreationNotification log entry written");