use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey in project openflowplugin by opendaylight.
the class DeviceMastershipManagerTest method testOnDeviceConnectedAndDisconnected.
@Test
public void testOnDeviceConnectedAndDisconnected() throws Exception {
// no context
Assert.assertNull(deviceMastershipManager.getDeviceMasterships().get(NODE_ID));
NodeUpdatedBuilder nodeUpdatedBuilder = new NodeUpdatedBuilder();
nodeUpdatedBuilder.setId(NODE_ID);
deviceMastershipManager.onNodeUpdated(nodeUpdatedBuilder.build());
DeviceMastership serviceInstance = deviceMastershipManager.getDeviceMasterships().get(NODE_ID);
Assert.assertNotNull(serviceInstance);
// destroy context - unregister
Assert.assertNotNull(deviceMastershipManager.getDeviceMasterships().get(NODE_ID));
NodeRemovedBuilder nodeRemovedBuilder = new NodeRemovedBuilder();
InstanceIdentifier<Node> nodeIId = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(NODE_ID));
nodeRemovedBuilder.setNodeRef(new NodeRef(nodeIId));
deviceMastershipManager.onNodeRemoved(nodeRemovedBuilder.build());
Assert.assertNull(deviceMastershipManager.getDeviceMasterships().get(NODE_ID));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey in project openflowplugin by opendaylight.
the class SimplifiedOperationalListener method reconciliation.
/**
* If node is present in config DS diff between wanted configuration (in config DS) and actual device
* configuration (coming from operational) should be calculated and sent to device.
* @param modification from DS
* @return optional syncup future
*/
private Optional<ListenableFuture<Boolean>> reconciliation(final DataTreeModification<Node> modification) {
final NodeId nodeId = ModificationUtil.nodeId(modification);
final Optional<FlowCapableNode> nodeConfiguration = configDao.loadByNodeId(nodeId);
if (nodeConfiguration.isPresent()) {
LOG.debug("Reconciliation {}: {}", dsType(), nodeId.getValue());
final InstanceIdentifier<FlowCapableNode> nodePath = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(ModificationUtil.nodeId(modification))).augmentation(FlowCapableNode.class);
final FlowCapableNode fcOperationalNode = ModificationUtil.flowCapableNodeAfter(modification);
final SyncupEntry syncupEntry = new SyncupEntry(nodeConfiguration.get(), LogicalDatastoreType.CONFIGURATION, fcOperationalNode, dsType());
return Optional.of(reactor.syncup(nodePath, syncupEntry));
} else {
LOG.debug("Config not present for reconciliation: {}", nodeId.getValue());
reconciliationRegistry.unregisterIfRegistered(nodeId);
return skipModification(modification);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey in project openflowplugin by opendaylight.
the class FRMTest method addFlowCapableNode.
public void addFlowCapableNode(NodeKey nodeKey) {
Nodes nodes = new NodesBuilder().setNode(Collections.<Node>emptyList()).build();
FlowCapableNodeBuilder fcnBuilder = new FlowCapableNodeBuilder();
NodeBuilder nodeBuilder = new NodeBuilder();
nodeBuilder.setKey(nodeKey);
nodeBuilder.addAugmentation(FlowCapableNode.class, fcnBuilder.build());
WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Nodes.class), nodes);
InstanceIdentifier<Node> flowNodeIdentifier = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey);
writeTx.put(LogicalDatastoreType.OPERATIONAL, flowNodeIdentifier, nodeBuilder.build());
writeTx.put(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(Nodes.class), nodes);
writeTx.put(LogicalDatastoreType.CONFIGURATION, flowNodeIdentifier, nodeBuilder.build());
assertCommit(writeTx.submit());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey in project openflowplugin by opendaylight.
the class FRMTest method addTable.
public void addTable(final TableKey tableKey, final NodeKey nodeKey) {
addFlowCapableNode(nodeKey);
final Table table = new TableBuilder().setKey(tableKey).setFlow(Collections.<Flow>emptyList()).build();
WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
InstanceIdentifier<Table> tableII = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey).augmentation(FlowCapableNode.class).child(Table.class, tableKey);
writeTx.put(LogicalDatastoreType.CONFIGURATION, tableII, table);
assertCommit(writeTx.submit());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey in project openflowplugin by opendaylight.
the class FRMTest method removeNode.
public void removeNode(NodeKey nodeKey) throws ExecutionException, InterruptedException {
WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.delete(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey));
writeTx.submit().get();
}
Aggregations