diff options
author | Ravi Pendurty <ravi.pendurty@highstreet-technologies.com> | 2021-05-25 18:57:29 +0530 |
---|---|---|
committer | Ravi Pendurty <ravi.pendurty@highstreet-technologies.com> | 2021-06-14 10:22:54 +0530 |
commit | 17614362f2550c29dcd746ee2c1bc01d0df5de65 (patch) | |
tree | 97930a14a08c610efceb4aebb4f457e0cf42b2f8 /sdnr/wt/devicemanager-onap | |
parent | db9f267b3930a28054e967c75db228e27663aedc (diff) |
Improve Websocket notification interface
Improve websocket notification interface
Issue-ID: CCSDK-3315
Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com>
Change-Id: I0ded865adddb546ade98df4760e0a32ec964295a
Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/devicemanager-onap')
11 files changed, 141 insertions, 39 deletions
diff --git a/sdnr/wt/devicemanager-onap/onf12/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev170324.java b/sdnr/wt/devicemanager-onap/onf12/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev170324.java index 6b32180d1..9ed027658 100644 --- a/sdnr/wt/devicemanager-onap/onf12/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev170324.java +++ b/sdnr/wt/devicemanager-onap/onf12/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev170324.java @@ -206,9 +206,11 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw public void onObjectCreationNotification(ObjectCreationNotification notification) { LOG.debug("Got event of type :: {}", ObjectCreationNotification.class.getSimpleName()); if (notification != null) { + // Send devicemanager specific notification for database and ODLUX microwaveModelListener.creationNotification(acessor.getNodeId(), notification.getCounter(), notification.getTimeStamp(), Helper.nnGetUniversalId(notification.getObjectIdRef()).getValue()); - notificationService.sendNotification(notification, acessor.getNodeId().getValue(), + // Send model specific notification to WebSocketManager + notificationService.sendNotification(notification, acessor.getNodeId(), ObjectCreationNotification.QNAME, notification.getTimeStamp()); } } @@ -217,9 +219,11 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw public void onObjectDeletionNotification(ObjectDeletionNotification notification) { LOG.debug("Got event of type :: {}", ObjectDeletionNotification.class.getSimpleName()); if (notification != null) { + // Send devicemanager specific notification for database and ODLUX microwaveModelListener.deletionNotification(acessor.getNodeId(), notification.getCounter(), notification.getTimeStamp(), Helper.nnGetUniversalId(notification.getObjectIdRef()).getValue()); - notificationService.sendNotification(notification, acessor.getNodeId().getValue(), + // Send model specific notification to WebSocketManager + notificationService.sendNotification(notification, acessor.getNodeId(), ObjectDeletionNotification.QNAME, notification.getTimeStamp()); } } @@ -231,8 +235,10 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw .setCounter(notification.getCounter()).setTimestamp(notification.getTimeStamp()) .setObjectId(Helper.nnGetUniversalId(notification.getObjectIdRef()).getValue()) .setAttributeName(notification.getAttributeName()).setNewValue(notification.getNewValue()).build(); + // Send devicemanager specific notification for database and ODLUX microwaveModelListener.eventNotification(beventlogEntity); - notificationService.sendNotification(notification, acessor.getNodeId().getValue(), + // Send model specific notification to WebSocketManager + notificationService.sendNotification(notification, acessor.getNodeId(), AttributeValueChangedNotification.QNAME, notification.getTimeStamp()); if (notificationQueue.isPresent()) { notificationQueue.get().put(beventlogEntity); @@ -249,8 +255,10 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw .setNodeId(this.acessor.getNodeId().getValue()) .setSeverity(mapSeverity(notification.getSeverity())).setCounter(notification.getCounter()) .build(); + // Send devicemanager specific notification for database and ODLUX faultService.faultNotification(faultAlarm); - notificationService.sendNotification(notification, acessor.getNodeId().getValue(), ProblemNotification.QNAME, + // Send model specific notification to WebSocketManager + notificationService.sendNotification(notification, acessor.getNodeId(), ProblemNotification.QNAME, notification.getTimeStamp()); } diff --git a/sdnr/wt/devicemanager-onap/onf12/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev180907.java b/sdnr/wt/devicemanager-onap/onf12/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev180907.java index 04d72e1fa..e564881c4 100644 --- a/sdnr/wt/devicemanager-onap/onf12/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev180907.java +++ b/sdnr/wt/devicemanager-onap/onf12/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev180907.java @@ -265,8 +265,10 @@ public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, Microw .setNodeId(this.acessor.getNodeId().getValue()) .setSeverity(mapSeverity(notification.getSeverity())).setCounter(notification.getCounter()) .build(); + // Send devicemanager specific notification for database and ODLUX faultService.faultNotification(faultAlarm); - notificationService.sendNotification(notification, acessor.getNodeId().getValue(), ProblemNotification.QNAME, + // Send model specific notification to WebSocketManager + notificationService.sendNotification(notification, acessor.getNodeId(), ProblemNotification.QNAME, notification.getTimeStamp()); } diff --git a/sdnr/wt/devicemanager-onap/onf12/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev181010.java b/sdnr/wt/devicemanager-onap/onf12/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev181010.java index 623fa6220..33349ef72 100644 --- a/sdnr/wt/devicemanager-onap/onf12/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev181010.java +++ b/sdnr/wt/devicemanager-onap/onf12/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev181010.java @@ -260,8 +260,10 @@ public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, Microw .setNodeId(this.acessor.getNodeId().getValue()) .setSeverity(mapSeverity(notification.getSeverity())).setCounter(notification.getCounter()) .build(); + // Send devicemanager specific notification for database and ODLUX faultService.faultNotification(faultAlarm); - notificationService.sendNotification(notification, acessor.getNodeId().getValue(), ProblemNotification.QNAME, + // Send model specific notification to WebSocketManager + notificationService.sendNotification(notification, acessor.getNodeId(), ProblemNotification.QNAME, notification.getTimeStamp()); } diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14AirInterfaceNotificationListener.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14AirInterfaceNotificationListener.java index e1ca58055..1f3f30927 100644 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14AirInterfaceNotificationListener.java +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14AirInterfaceNotificationListener.java @@ -83,7 +83,7 @@ public class Onf14AirInterfaceNotificationListener implements AirInterface20List .setObjectId(notification.getObjectIdRef().getValue()).setSourceType(SourceType.Netconf) .setTimestamp(notification.getTimestamp()); serviceProvider.getDataProvider().writeEventLog(eventlogBuilder.build()); - serviceProvider.getWebsocketService().sendNotification(notification, netconfAccessor.getNodeId().getValue(), + serviceProvider.getWebsocketService().sendNotification(notification, netconfAccessor.getNodeId(), ObjectDeletionNotification.QNAME, notification.getTimestamp()); log.debug("onObjectDeletionNotification log entry written"); @@ -99,7 +99,7 @@ public class Onf14AirInterfaceNotificationListener implements AirInterface20List .setSeverity(mapSeverity(notification.getSeverity())).setCounter(notification.getCounter()) .build(); serviceProvider.getFaultService().faultNotification(faultAlarm); - serviceProvider.getWebsocketService().sendNotification(notification, netconfAccessor.getNodeId().getValue(), + serviceProvider.getWebsocketService().sendNotification(notification, netconfAccessor.getNodeId(), ProblemNotification.QNAME, notification.getTimestamp()); } @@ -118,7 +118,7 @@ public class Onf14AirInterfaceNotificationListener implements AirInterface20List .setNewValue(notification.getNewValue()).setObjectId(notification.getObjectIdRef().getValue()) .setSourceType(SourceType.Netconf).setTimestamp(notification.getTimestamp()); serviceProvider.getDataProvider().writeEventLog(eventlogBuilder.build()); - serviceProvider.getWebsocketService().sendNotification(notification, netconfAccessor.getNodeId().getValue(), + serviceProvider.getWebsocketService().sendNotification(notification, netconfAccessor.getNodeId(), AttributeValueChangedNotification.QNAME, notification.getTimestamp()); log.debug("onAttributeValueChangedNotification log entry written"); } @@ -133,7 +133,7 @@ public class Onf14AirInterfaceNotificationListener implements AirInterface20List .setObjectId(notification.getObjectIdRef().getValue()).setSourceType(SourceType.Netconf) .setTimestamp(notification.getTimestamp()); serviceProvider.getDataProvider().writeEventLog(eventlogBuilder.build()); - serviceProvider.getWebsocketService().sendNotification(notification, netconfAccessor.getNodeId().getValue(), + serviceProvider.getWebsocketService().sendNotification(notification, netconfAccessor.getNodeId(), ObjectCreationNotification.QNAME, notification.getTimestamp()); log.debug("onObjectCreationNotification log entry written"); } diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14EthernetContainerNotificationListener.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14EthernetContainerNotificationListener.java index fb67a24ab..b76572ba5 100644 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14EthernetContainerNotificationListener.java +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14EthernetContainerNotificationListener.java @@ -96,7 +96,7 @@ public class Onf14EthernetContainerNotificationListener implements EthernetConta .setSeverity(mapSeverity(notification.getSeverity())).setCounter(notification.getCounter().intValue()) .build(); serviceProvider.getFaultService().faultNotification(faultAlarm); - serviceProvider.getWebsocketService().sendNotification(notification, netconfAccessor.getNodeId().getValue(), + serviceProvider.getWebsocketService().sendNotification(notification, netconfAccessor.getNodeId(), ProblemNotification.QNAME, notification.getTimestamp()); } @@ -115,7 +115,7 @@ public class Onf14EthernetContainerNotificationListener implements EthernetConta .setNewValue(notification.getNewValue()).setObjectId(notification.getObjectIdRef().getValue()) .setSourceType(SourceType.Netconf).setTimestamp(notification.getTimestamp()); serviceProvider.getDataProvider().writeEventLog(eventlogBuilder.build()); - serviceProvider.getWebsocketService().sendNotification(notification, netconfAccessor.getNodeId().getValue(), + serviceProvider.getWebsocketService().sendNotification(notification, netconfAccessor.getNodeId(), AttributeValueChangedNotification.QNAME, notification.getTimestamp()); log.debug("onAttributeValueChangedNotification log entry written"); @@ -131,7 +131,7 @@ public class Onf14EthernetContainerNotificationListener implements EthernetConta .setObjectId(notification.getObjectIdRef().getValue()).setSourceType(SourceType.Netconf) .setTimestamp(notification.getTimestamp()); serviceProvider.getDataProvider().writeEventLog(eventlogBuilder.build()); - serviceProvider.getWebsocketService().sendNotification(notification, netconfAccessor.getNodeId().getValue(), + serviceProvider.getWebsocketService().sendNotification(notification, netconfAccessor.getNodeId(), ObjectCreationNotification.QNAME, notification.getTimestamp()); log.debug("onObjectCreationNotification log entry written"); diff --git a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14WireInterfaceNotificationListener.java b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14WireInterfaceNotificationListener.java index 8a1d42fa4..840f2c328 100644 --- a/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14WireInterfaceNotificationListener.java +++ b/sdnr/wt/devicemanager-onap/onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/interfaces/Onf14WireInterfaceNotificationListener.java @@ -83,7 +83,7 @@ public class Onf14WireInterfaceNotificationListener implements WireInterface20Li .setSourceType(SourceType.Netconf) .setTimestamp(notification.getTimestamp()); serviceProvider.getDataProvider().writeEventLog(eventlogBuilder.build()); - serviceProvider.getWebsocketService().sendNotification(notification, netconfAccessor.getNodeId().getValue(), + serviceProvider.getWebsocketService().sendNotification(notification, netconfAccessor.getNodeId(), ObjectDeletionNotification.QNAME, notification.getTimestamp()); log.debug("onObjectDeletionNotification log entry written"); @@ -98,7 +98,7 @@ public class Onf14WireInterfaceNotificationListener implements WireInterface20Li .setSeverity(mapSeverity(notification.getSeverity())).setCounter(notification.getCounter().intValue()) .build(); serviceProvider.getFaultService().faultNotification(faultAlarm); - serviceProvider.getWebsocketService().sendNotification( notification, netconfAccessor.getNodeId().getValue(), + serviceProvider.getWebsocketService().sendNotification( notification, netconfAccessor.getNodeId(), ProblemNotification.QNAME, notification.getTimestamp()); } @@ -120,7 +120,7 @@ public class Onf14WireInterfaceNotificationListener implements WireInterface20Li .setSourceType(SourceType.Netconf) .setTimestamp(notification.getTimestamp()); serviceProvider.getDataProvider().writeEventLog(eventlogBuilder.build()); - serviceProvider.getWebsocketService().sendNotification(notification, netconfAccessor.getNodeId().getValue(), + serviceProvider.getWebsocketService().sendNotification(notification, netconfAccessor.getNodeId(), AttributeValueChangedNotification.QNAME, notification.getTimestamp()); @@ -140,7 +140,7 @@ public class Onf14WireInterfaceNotificationListener implements WireInterface20Li .setSourceType(SourceType.Netconf) .setTimestamp(notification.getTimestamp()); serviceProvider.getDataProvider().writeEventLog(eventlogBuilder.build()); - serviceProvider.getWebsocketService().sendNotification(notification, netconfAccessor.getNodeId().getValue(), + serviceProvider.getWebsocketService().sendNotification(notification, netconfAccessor.getNodeId(), ObjectCreationNotification.QNAME, notification.getTimestamp()); log.debug("onObjectCreationNotification log entry written"); diff --git a/sdnr/wt/devicemanager-onap/openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmChangeNotificationListener.java b/sdnr/wt/devicemanager-onap/openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmChangeNotificationListener.java index 3af6d7aca..3b7f8b044 100644 --- a/sdnr/wt/devicemanager-onap/openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmChangeNotificationListener.java +++ b/sdnr/wt/devicemanager-onap/openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmChangeNotificationListener.java @@ -68,14 +68,14 @@ public class OpenroadmChangeNotificationListener implements IetfNetconfNotificat @Override public void onNetconfConfirmedCommit(NetconfConfirmedCommit notification) { log.info("onNetconfConfirmedCommit {} ", notification); - this.notificationServiceService.sendNotification(notification, this.netconfAccessor.getNodeId().getValue(), + this.notificationServiceService.sendNotification(notification, this.netconfAccessor.getNodeId(), NetconfConfirmedCommit.QNAME, NetconfTimeStampImpl.getConverter().getTimeStamp()); } @Override public void onNetconfSessionStart(NetconfSessionStart notification) { log.info("onNetconfSessionStart {} ", notification); - this.notificationServiceService.sendNotification(notification, this.netconfAccessor.getNodeId().getValue(), + this.notificationServiceService.sendNotification(notification, this.netconfAccessor.getNodeId(), NetconfSessionStart.QNAME, NetconfTimeStampImpl.getConverter().getTimeStamp()); } @@ -83,14 +83,14 @@ public class OpenroadmChangeNotificationListener implements IetfNetconfNotificat @Override public void onNetconfSessionEnd(NetconfSessionEnd notification) { log.info("onNetconfSessionEnd {}", notification); - this.notificationServiceService.sendNotification(notification, this.netconfAccessor.getNodeId().getValue(), + this.notificationServiceService.sendNotification(notification, this.netconfAccessor.getNodeId(), NetconfSessionEnd.QNAME, NetconfTimeStampImpl.getConverter().getTimeStamp()); } @Override public void onNetconfCapabilityChange(NetconfCapabilityChange notification) { log.info("onNetconfCapabilityChange {}", notification); - this.notificationServiceService.sendNotification(notification, this.netconfAccessor.getNodeId().getValue(), + this.notificationServiceService.sendNotification(notification, this.netconfAccessor.getNodeId(), NetconfCapabilityChange.QNAME, NetconfTimeStampImpl.getConverter().getTimeStamp()); } @@ -120,7 +120,7 @@ public class OpenroadmChangeNotificationListener implements IetfNetconfNotificat databaseService.writeEventLog(eventlogBuilder.build()); } log.info("onNetconfConfigChange (2) {}", sb); - this.notificationServiceService.sendNotification(notification, this.netconfAccessor.getNodeId().getValue(), + this.notificationServiceService.sendNotification(notification, this.netconfAccessor.getNodeId(), NetconfConfigChange.QNAME, NetconfTimeStampImpl.getConverter().getTimeStamp()); } diff --git a/sdnr/wt/devicemanager-onap/openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmDeviceChangeNotificationListener.java b/sdnr/wt/devicemanager-onap/openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmDeviceChangeNotificationListener.java index daea1adb3..a39e62ce1 100644 --- a/sdnr/wt/devicemanager-onap/openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmDeviceChangeNotificationListener.java +++ b/sdnr/wt/devicemanager-onap/openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmDeviceChangeNotificationListener.java @@ -104,7 +104,7 @@ public class OpenroadmDeviceChangeNotificationListener implements OrgOpenroadmDe log.info("onDeviceConfigChange (2) {}", sb); counter++; } - this.notificationServiceService.sendNotification(notification, this.netconfAccessor.getNodeId().getValue(), + this.notificationServiceService.sendNotification(notification, this.netconfAccessor.getNodeId(), ChangeNotification.QNAME, notification.getChangeTime()); } @@ -119,7 +119,7 @@ public class OpenroadmDeviceChangeNotificationListener implements OrgOpenroadmDe .setCounter(counter).setNewValue(notification.getStatus().getName()).setSourceType(SourceType.Netconf) .setTimestamp(now); databaseProvider.writeEventLog(eventlogBuilder.build()); - this.notificationServiceService.sendNotification(notification, this.netconfAccessor.getNodeId().getValue(), + this.notificationServiceService.sendNotification(notification, this.netconfAccessor.getNodeId(), CreateTechInfoNotification.QNAME, now); log.info("Create-techInfo Notification written "); counter++; diff --git a/sdnr/wt/devicemanager-onap/openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmFaultNotificationListener.java b/sdnr/wt/devicemanager-onap/openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmFaultNotificationListener.java index 10d0a5640..23bb24cd9 100644 --- a/sdnr/wt/devicemanager-onap/openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmFaultNotificationListener.java +++ b/sdnr/wt/devicemanager-onap/openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmFaultNotificationListener.java @@ -25,12 +25,34 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm.impl; import org.eclipse.jdt.annotation.NonNull; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor; import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.WebsocketManagerService; import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev191129.AlarmNotification; import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev191129.OrgOpenroadmAlarmListener; +import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev191129.alarm.ProbableCause; +import org.opendaylight.yang.gen.v1.http.org.openroadm.probablecause.rev191129.ProbableCauseEnum; +import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev191129.resource.resource.Resource; +import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev191129.resource.resource.resource.CircuitPack; +import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev191129.resource.resource.resource.Connection; +import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev191129.resource.resource.resource.Degree; +import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev191129.resource.resource.resource.Device; +import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev191129.resource.resource.resource.Interface; +import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev191129.resource.resource.resource.InternalLink; +import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev191129.resource.resource.resource.LineAmplifier; +import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev191129.resource.resource.resource.OduSncpPg; +import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev191129.resource.resource.resource.Other; +import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev191129.resource.resource.resource.PhysicalLink; +import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev191129.resource.resource.resource.Port; +import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev191129.resource.resource.resource.Service; +import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev191129.resource.resource.resource.Shelf; +import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev191129.resource.resource.resource.Srg; +import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev191129.resource.resource.resource.TempService; +import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev191129.resource.resource.resource.VersionedService; +import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev191129.resource.resource.resource.Xponder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultlogBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultlogEntity; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SourceType; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -46,8 +68,11 @@ public class OpenroadmFaultNotificationListener implements OrgOpenroadmAlarmList private @NonNull WebsocketManagerService notificationService; private Integer count = 1; + private NetconfBindingAccessor netconfAccessor; - public OpenroadmFaultNotificationListener(DeviceManagerServiceProvider serviceProvider) { + + public OpenroadmFaultNotificationListener(NetconfBindingAccessor accessor, DeviceManagerServiceProvider serviceProvider) { + this.netconfAccessor = accessor; this.faultEventListener = serviceProvider.getFaultService(); this.notificationService = serviceProvider.getWebsocketService(); @@ -55,24 +80,80 @@ public class OpenroadmFaultNotificationListener implements OrgOpenroadmAlarmList @Override public void onAlarmNotification(AlarmNotification notification) { + log.info("AlarmNotification is {} \t {}", notification.getId(), notification.getAdditionalDetail()); + String affectedResourceName = getAffectedResourceName(notification.getResource().getResource().getResource()); + String probableCauseName = getProbableCauseName(notification.getProbableCause()); - - log.info("AlarmNotification {} \t {}", notification.getId(), notification.getAdditionalDetail()); - final String nodeId = notification.getResource().getDevice().getNodeId().getValue(); - FaultlogEntity faultAlarm = new FaultlogBuilder().setObjectId(notification.getCircuitId()) - .setProblem(notification.getProbableCause().getCause().getName()).setSourceType(SourceType.Netconf) - .setTimestamp(notification.getRaiseTime()).setId(notification.getId()).setNodeId(nodeId) + if (notification.getId() == null) { + log.warn("Alarm ID is null. Not logging alarm information to the DB. Alarm ID should not be null. Please fix the same in the Device"); + return; + } + FaultlogEntity faultAlarm = new FaultlogBuilder().setObjectId(affectedResourceName) + .setProblem(probableCauseName).setSourceType(SourceType.Netconf) + .setTimestamp(notification.getRaiseTime()).setId(notification.getId()).setNodeId(netconfAccessor.getNodeId().getValue()) .setSeverity(InitialDeviceAlarmReader.checkSeverityValue(notification.getSeverity())).setCounter(count) .build(); this.faultEventListener.faultNotification(faultAlarm); - this.notificationService.sendNotification(notification, nodeId, AlarmNotification.QNAME, + this.notificationService.sendNotification(notification,new NodeId(netconfAccessor.getNodeId().getValue()), AlarmNotification.QNAME, notification.getRaiseTime()); count++; log.info("Notification is written into the database {}", faultAlarm.getObjectId()); } + public String getAffectedResourceName(Resource affectedResource) { + if (affectedResource instanceof CircuitPack) { + return ((CircuitPack)affectedResource).getCircuitPackName(); + } else if (affectedResource instanceof Port) { + return ((Port)affectedResource).getPort().getPortName(); + } else if (affectedResource instanceof Connection) { + return ((Connection)affectedResource).getConnectionName(); + } else if (affectedResource instanceof PhysicalLink) { + return ((PhysicalLink)affectedResource).getPhysicalLinkName(); + } else if (affectedResource instanceof InternalLink) { + return ((InternalLink)affectedResource).getInternalLinkName(); + } else if (affectedResource instanceof Shelf) { + return ((Shelf)affectedResource).getShelfName(); + } else if (affectedResource instanceof Srg) { + return "SRG #- " + ((Srg)affectedResource).getSrgNumber().toString(); + } else if (affectedResource instanceof Degree) { + return "Degree - " + ((Degree)affectedResource).getDegreeNumber().toString(); + } else if (affectedResource instanceof Service) { + return ((Service)affectedResource).getServiceName(); + } else if (affectedResource instanceof Interface) { + return ((Interface)affectedResource).getInterfaceName(); + } else if (affectedResource instanceof OduSncpPg) { + return ((OduSncpPg)affectedResource).getOduSncpPgName(); + } else if (affectedResource instanceof Device) { + return ((Device)affectedResource).getNodeId().getValue(); + } else if (affectedResource instanceof LineAmplifier) { + return "LineAmplifier # - " + ((LineAmplifier)affectedResource).getAmpNumber().toString(); + } else if (affectedResource instanceof Xponder) { + return "Xponder # - "+ ((Xponder)affectedResource).getXpdrNumber().toString(); + } else if (affectedResource instanceof Other) { + return ((Other)affectedResource).getOtherResourceId(); + } else if (affectedResource instanceof VersionedService) { + return ((VersionedService)affectedResource).getVersionedServiceName(); + } else if (affectedResource instanceof TempService) { + return ((TempService)affectedResource).getCommonId(); + } + log.warn("Unknown Resource {} received from Notification", affectedResource.getClass().getSimpleName()); + return "Unknown Resource"; + } + + public String getProbableCauseName(ProbableCause probableCause) { + if (probableCause != null) { + ProbableCauseEnum pce = probableCause.getCause(); + if (pce != null) { + return pce.getName(); + } + log.warn("ProbableCauseEnum is NULL"); + return "Unknown Cause"; + } + log.warn("ProbableCause is NULL"); + return "Unknown Cause"; + } } diff --git a/sdnr/wt/devicemanager-onap/openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmNetworkElement.java b/sdnr/wt/devicemanager-onap/openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmNetworkElement.java index 02f8547ae..cc406d843 100644 --- a/sdnr/wt/devicemanager-onap/openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmNetworkElement.java +++ b/sdnr/wt/devicemanager-onap/openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmNetworkElement.java @@ -90,7 +90,7 @@ public class OpenroadmNetworkElement extends OpenroadmNetworkElementBase { this.openRdmListener = new OpenroadmChangeNotificationListener(netconfAccessor, databaseService, serviceProvider.getWebsocketService()); this.opnRdmFaultListenerRegistrationResult = null; - this.opnRdmFaultListener = new OpenroadmFaultNotificationListener(serviceProvider); + this.opnRdmFaultListener = new OpenroadmFaultNotificationListener(netconfAccessor, serviceProvider); this.opnRdmDeviceListenerRegistrationResult = null; this.opnRdmDeviceListener = new OpenroadmDeviceChangeNotificationListener(netconfAccessor, databaseService, serviceProvider.getWebsocketService()); diff --git a/sdnr/wt/devicemanager-onap/openroadm/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmAlarmNotification.java b/sdnr/wt/devicemanager-onap/openroadm/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmAlarmNotification.java index ff0ddb43c..cd54b6c20 100644 --- a/sdnr/wt/devicemanager-onap/openroadm/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmAlarmNotification.java +++ b/sdnr/wt/devicemanager-onap/openroadm/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmAlarmNotification.java @@ -31,7 +31,7 @@ import org.junit.Test; import org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm.impl.OpenroadmFaultNotificationListener; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor; import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.WebsocketManagerService; import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev191129.AlarmNotification; import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev191129.Severity; @@ -44,6 +44,7 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.probablecause.rev191129.P import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev191129.resource.Device; import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev191129.resource.DeviceBuilder; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; public class TestOpenRoadmAlarmNotification { private static final String myCircuitId = "Test_Id"; @@ -52,18 +53,25 @@ public class TestOpenRoadmAlarmNotification { ProbableCause myProbableCause = new ProbableCauseBuilder().setCause(ProbableCauseEnum.AutomaticLaserShutdown).build(); Device device = new DeviceBuilder().setNodeId(NodeIdType.getDefaultInstance("zNhe2i5")).build(); - Resource myResource = new ResourceBuilder().setDevice(device).build(); + org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev191129.resource.resource.resource.CircuitPack resVal = + new org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev191129.resource.resource.resource.CircuitPackBuilder() + .setCircuitPackName("Slot-0-Port-A").build(); + org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev191129.resource.Resource affectedResource = + new org.opendaylight.yang.gen.v1.http.org.openroadm.resource.rev191129.resource.ResourceBuilder().setResource(resVal).build(); + Resource myResource = new ResourceBuilder().setResource(affectedResource).setDevice(device).build(); + + static DeviceManagerServiceProvider serviceProvider; static @NonNull FaultService faultService; static AlarmNotification notification; Severity severity; - static NetconfAccessor accessor; + static NetconfBindingAccessor accessor; static WebsocketManagerService notificationService; - + static NodeId nNodeId = new NodeId("nSky"); @BeforeClass public static void init() throws InterruptedException, IOException { - accessor = mock(NetconfAccessor.class); + accessor = mock(NetconfBindingAccessor.class); serviceProvider = mock(DeviceManagerServiceProvider.class); faultService = mock(FaultService.class); notificationService = mock(WebsocketManagerService.class); @@ -74,10 +82,11 @@ public class TestOpenRoadmAlarmNotification { @Test public void testNotification() { severity = Severity.Critical; + when(accessor.getNodeId()).thenReturn(nNodeId); when(serviceProvider.getFaultService()).thenReturn(faultService); when(serviceProvider.getWebsocketService()).thenReturn(notificationService); OpenroadmFaultNotificationListener alarmListener = - new OpenroadmFaultNotificationListener(serviceProvider); + new OpenroadmFaultNotificationListener(accessor, serviceProvider); notification = mock(AlarmNotification.class); when(notification.getId()).thenReturn(myId); |