- if(sessionContext == null && !ownershipChange.hasOwner()) {
- LOG.info("onDeviceOwnershipChanged: {} don't have any owner, explicitly " +
- "clean up the operational data store",entity);
-
- BindingTransactionChain txChain = dataBroker.createTransactionChain(this);
- YangInstanceIdentifier yId = entity.getId();
- ReadWriteTransaction tx = txChain.newReadWriteTransaction();
- NodeIdentifierWithPredicates niWPredicates = (NodeIdentifierWithPredicates)yId.getLastPathArgument();
- Map<QName, Object> keyValMap = niWPredicates.getKeyValues();
- String nodeIdStr = (String)(keyValMap.get(ENTITY_NAME));
- BigInteger dpId = new BigInteger(nodeIdStr.split(":")[1]);
- NodeKey nodeKey = new NodeKey(new NodeId(nodeIdStr));
- InstanceIdentifier<Node> path = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey);
-
- Optional<Node> flowNode = Optional.absent();
-
- try {
- flowNode = tx.read(LogicalDatastoreType.OPERATIONAL, path).get();
- if (flowNode.isPresent()) {
- //final NodeRef ref = flowNode.getNodeRef();
- LOG.info("onDeviceOwnershipChanged: Removing data from operational " +
- "datastore for node: {}", path);
- tx.delete(LogicalDatastoreType.OPERATIONAL, path);
- tx.submit();
- }
- }
- catch (Exception e) {
- LOG.error("onDeviceOwnershipChanged: Operational datastore " +
- "clean up failed for Node {}", entity, e);
- }
- }
-