import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
-
import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
-
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
import org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType;
LOG.info("Registering notification listener on {} for node: {}", AlarmNotification.QNAME, nodeId);
// Register notification listener
-
final OrgOpenroadmDeOperationsListener deOperationsListener;
deOperationsListener = new DeOperationsListener();
LOG.info("Registering notification listener on OrgOpenroadmDeOperationsListener for node: {}", nodeId);
// Register notification listener
-
final OrgOpenroadmDeviceListener deviceListener;
deviceListener = new DeviceListener();
LOG.info("Registering notification listener on OrgOpenroadmDeviceListener for node: {}", nodeId);
// Register notification listener
-
final OrgOpenroadmLldpListener lldpListener;
lldpListener = new LldpListener();
LOG.info("Registering notification listener on OrgOpenroadmLldpListener for node: {}", nodeId);
// Register notification listener
-
final OrgOpenroadmTcaListener tcaListener;
tcaListener = new TcaListener();
LOG.info("Registering notification listener on OrgOpenroadmTcaListener for node: {}", nodeId);
// Register notification listener
-
// Listening to NETCONF datastream
final String streamName = "NETCONF";
final Optional<RpcConsumerRegistry> service = mountPoint.getService(RpcConsumerRegistry.class);
"Node not connected via Netconf protocol");
nodeId = rootNode.getDataAfter().getKey().getNodeId().getValue();
}
+
+ if (rootNode.getModificationType() == ModificationType.DELETE) {
+ String nodeid = rootNode.getDataBefore().getKey().getNodeId().getValue();
+ LOG.info("Node " + nodeid + " removed...");
+ currentMountedDevice.remove(nodeid);
+ new PortMapping(dataBroker, mountService, nodeid).deleteMappingData();
+ }
+
if (nnode != null) {
if (nodeId.equals("controller-config")) {
// We shouldn't process controller-config as an OpenROAM device
.stream().map(cp -> cp.getCapability()).collect(Collectors.toList());
LOG.info("Capabilities: {}", capabilities);
/*
- * TODO: check for required
- * capabilities to listen for notifications
+ * TODO: check for required capabilities to listen
+ * for notifications
*/
- registerNotificationListener(rootNode.getDataAfter(). getNodeId());
+ registerNotificationListener(rootNode.getDataAfter().getNodeId());
currentMountedDevice.add(nodeId);
new PortMapping(dataBroker, mountService, nodeId).createMappingData();
break;
default:
LOG.warn("Unexpected connection status " + csts.getName());
}
- } else if (rootNode.getModificationType() == ModificationType.DELETE) {
- LOG.info("Node removed " + nodeId);
- currentMountedDevice.remove(nodeId);
}
}
}
+ LOG.info("Netconf devices currently mounted are : " + currentMountedDevice.toString());
}
}
import com.google.common.base.Optional;
import com.google.common.util.concurrent.CheckedFuture;
-
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
-
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.MountPoint;
import org.opendaylight.controller.md.sal.binding.api.MountPointService;
return postPortMapping(deviceInfo, portMapList, nodeType);
}
+ /**
+ * This method removes mapping data from the datastore after disconnecting
+ * ODL from a Netconf device.
+ */
+ public void deleteMappingData() {
+ LOG.info("Deleting Mapping Data corresponding at node " + nodeId);
+ WriteTransaction rw = db.newWriteOnlyTransaction();
+ InstanceIdentifier<Nodes> nodesIID = InstanceIdentifier.create(Network.class)
+ .child(Nodes.class, new NodesKey(nodeId));
+ rw.delete(LogicalDatastoreType.CONFIGURATION, nodesIID);
+ try {
+ rw.submit().get(1, TimeUnit.SECONDS);
+ LOG.info("Port mapping removal for node " + nodeId);
+ } catch (InterruptedException | ExecutionException | TimeoutException e) {
+ LOG.error("Error for removing port mapping infos for node " + nodeId);
+ }
+ }
+
/**
* This private method gets the list of external ports on a degree. For each
* port in the degree, it does a get on port subtree with
}
} catch (InterruptedException | ExecutionException ex) {
LOG.warn("Read failed for Logical Connection Point value missing for " + circuitPackName + " "
- + portName,ex);
+ + portName, ex);
return false;
}
}
}
} catch (InterruptedException | ExecutionException ex) {
- LOG.warn("Read failed for " + circuitPackName,ex);
+ LOG.warn("Read failed for " + circuitPackName, ex);
return false;
}
}
}
} catch (InterruptedException | ExecutionException ex) {
- LOG.warn("Read failed for CircuitPacks of " + nodeId,ex);
+ LOG.warn("Read failed for CircuitPacks of " + nodeId, ex);
return false;
}
return true;
break;
}
} catch (InterruptedException | ExecutionException ex) {
- LOG.error("Failed to read degree " + degreeCounter,ex);
+ LOG.error("Failed to read degree " + degreeCounter, ex);
break;
}
break;
}
} catch (InterruptedException | ExecutionException ex) {
- LOG.warn("Failed to read Srg " + srgCounter,ex);
+ LOG.warn("Failed to read Srg " + srgCounter, ex);
break;
}
srgCounter++;
}
} catch (InterruptedException | ExecutionException ex) {
LOG.error("Unable to read mapping for logical connection point : " + logicalConnPoint + " for nodeId "
- + nodeId,ex);
+ + nodeId, ex);
}
return null;
}