summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/devicemanager-onap/openroadm
diff options
context:
space:
mode:
Diffstat (limited to 'sdnr/wt/devicemanager-onap/openroadm')
-rw-r--r--sdnr/wt/devicemanager-onap/openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmChangeNotificationListener.java10
-rw-r--r--sdnr/wt/devicemanager-onap/openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmDeviceChangeNotificationListener.java4
-rw-r--r--sdnr/wt/devicemanager-onap/openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmFaultNotificationListener.java97
-rw-r--r--sdnr/wt/devicemanager-onap/openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmNetworkElement.java2
-rw-r--r--sdnr/wt/devicemanager-onap/openroadm/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/test/TestOpenRoadmAlarmNotification.java21
5 files changed, 112 insertions, 22 deletions
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);