*/
boolean updatePortMappingWithOduSwitchingPools(String nodeId, InstanceIdentifier<OduSwitchingPools> ospIID,
Map<Uint16, List<InstanceIdentifier<PortList>>> nbliidMap);
+
+ /**
+ * This method check the presence or not of a given node inside the PortMapping
+ * datastore.
+ *
+ * @param nodeId
+ * Unique Identifier for the node of interest.
+ *
+ * @return Result true/false based on existance or not of a given node.
+ */
+ boolean isNodeExist(String nodeId);
+
}
return false;
}
}
+
+ @Override
+ public boolean isNodeExist(String nodeId) {
+ return this.getNode(nodeId) != null;
+ }
}
NetconfNode netconfNodeBefore = rootNode.getDataBefore().augmentation(NetconfNode.class);
switch (rootNode.getModificationType()) {
case DELETE:
- this.networkModelService.deleteOpenRoadmnode(nodeId);
- onDeviceDisConnected(nodeId);
- LOG.info("Device {} correctly disconnected from controller", nodeId);
+ if (this.networkModelService.deleteOpenRoadmnode(nodeId)) {
+ onDeviceDisConnected(nodeId);
+ LOG.info("Device {} correctly disconnected from controller", nodeId);
+ }
break;
case WRITE:
NetconfNode netconfNodeAfter = rootNode.getDataAfter().augmentation(NetconfNode.class);
void createOpenRoadmNode(String nodeId, String nodeVersion);
/**
- * Delete OpenROADM node mapping and topologies.
+ * Delete OpenROADM node from portmapping and topologies.
*
* @param nodeId
* unique node ID of OpenROADM node.
*
+ * @return result of node deletion from portmapping and topologies
*/
- void deleteOpenRoadmnode(String nodeId);
+ boolean deleteOpenRoadmnode(String nodeId);
/**
* Update termination point, and if need, be associated links, of
*/
@Override
- public void deleteOpenRoadmnode(String nodeId) {
+ public boolean deleteOpenRoadmnode(String nodeId) {
try {
+ if (!this.portMapping.isNodeExist(nodeId)) {
+ return false;
+ }
NodeKey nodeIdKey = new NodeKey(new NodeId(nodeId));
LOG.info("deleting node in {}", NetworkUtils.UNDERLAY_NETWORK_ID);
LOG.info("all nodes and links deleted ! ");
} catch (InterruptedException | ExecutionException | TimeoutException e) {
LOG.error("Error when trying to delete node : {}", nodeId, e);
+ return false;
}
+ return true;
}
@Override
OPENROADM_DEVICE_VERSION_2_2_1);
when(node.getModificationType()).thenReturn(DataObjectModification.ModificationType.DELETE);
when(node.getDataBefore()).thenReturn(netconfNode);
- when(registrations.remove(anyString())).thenReturn(nodeRegistration);
NetConfTopologyListener listener = new NetConfTopologyListener(networkModelService, dataBroker,
deviceTransactionManager, portMapping, registrations);
verify(node, times(1)).getModificationType();
verify(node, times(3)).getDataBefore();
verify(networkModelService, times(1)).deleteOpenRoadmnode(anyString());
- verify(nodeRegistration, times(1)).unregisterListeners();
+ verify(nodeRegistration, times(0)).unregisterListeners();
}
@Test