use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef in project openflowplugin by opendaylight.
the class NodeConnectorRefToPortTranslator method toNodeConnectorRef.
/**
* Converts {@link PacketIn} to {@link NodeConnectorRef}.
* @param packetIn Packet input
* @param dataPathId Data path id
* @return packet input converted to node connector reference
*/
@Nullable
public static NodeConnectorRef toNodeConnectorRef(@Nonnull PacketIn packetIn, BigInteger dataPathId) {
Preconditions.checkNotNull(packetIn);
NodeConnectorRef ref = null;
Long port = getPortNoFromPacketIn(packetIn);
if (port != null) {
OpenflowVersion version = OpenflowVersion.get(packetIn.getVersion());
ref = InventoryDataServiceUtil.nodeConnectorRefFromDatapathIdPortno(dataPathId, port, version);
}
return ref;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef in project openflowplugin by opendaylight.
the class TerminationPointChangeListenerImpl method prepareTopologyTerminationPoint.
private static TerminationPoint prepareTopologyTerminationPoint(final TpId terminationPointIdInTopology, final InstanceIdentifier<FlowCapableNodeConnector> iiToNodeInInventory) {
final InventoryNodeConnector inventoryNodeConnector = new InventoryNodeConnectorBuilder().setInventoryNodeConnectorRef(new NodeConnectorRef(iiToNodeInInventory.firstIdentifierOf(NodeConnector.class))).build();
final TerminationPointBuilder terminationPointBuilder = new TerminationPointBuilder();
terminationPointBuilder.setTpId(terminationPointIdInTopology);
terminationPointBuilder.addAugmentation(InventoryNodeConnector.class, inventoryNodeConnector);
return terminationPointBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef in project openflowplugin by opendaylight.
the class FlowCapableTopologyExporterTest method testOnLinkRemovedLinkDoesNotExist.
@Test
public void testOnLinkRemovedLinkDoesNotExist() {
org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey sourceNodeKey = newInvNodeKey("sourceNode");
org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey sourceNodeConnKey = newInvNodeConnKey("sourceTP");
InstanceIdentifier<?> sourceConnID = newNodeConnID(sourceNodeKey, sourceNodeConnKey);
org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey destNodeKey = newInvNodeKey("destNode");
org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey destNodeConnKey = newInvNodeConnKey("destTP");
InstanceIdentifier<?> destConnID = newNodeConnID(destNodeKey, destNodeConnKey);
ReadWriteTransaction mockTx = mock(ReadWriteTransaction.class);
final CountDownLatch submitLatch = setupStubbedSubmit(mockTx);
doReturn(mockTx).when(mockTxChain).newReadWriteTransaction();
doReturn(Futures.immediateCheckedFuture(Optional.<Link>absent())).when(mockTx).read(LogicalDatastoreType.OPERATIONAL, topologyIID.child(Link.class, new LinkKey(new LinkId(sourceNodeConnKey.getId()))));
exporter.onLinkRemoved(new LinkRemovedBuilder().setSource(new NodeConnectorRef(sourceConnID)).setDestination(new NodeConnectorRef(destConnID)).build());
waitForSubmit(submitLatch);
verify(mockTx, never()).delete(LogicalDatastoreType.OPERATIONAL, topologyIID.child(Link.class, new LinkKey(new LinkId(sourceNodeConnKey.getId()))));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef in project openflowplugin by opendaylight.
the class FlowCapableTopologyExporterTest method testOnLinkRemoved.
@Test
public void testOnLinkRemoved() {
org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey sourceNodeKey = newInvNodeKey("sourceNode");
org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey sourceNodeConnKey = newInvNodeConnKey("sourceTP");
InstanceIdentifier<?> sourceConnID = newNodeConnID(sourceNodeKey, sourceNodeConnKey);
org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey destNodeKey = newInvNodeKey("destNode");
org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey destNodeConnKey = newInvNodeConnKey("destTP");
InstanceIdentifier<?> destConnID = newNodeConnID(destNodeKey, destNodeConnKey);
Link link = newLink(sourceNodeConnKey.getId().getValue(), newSourceTp(sourceNodeConnKey.getId().getValue()), newDestTp(destNodeConnKey.getId().getValue()));
ReadWriteTransaction mockTx = mock(ReadWriteTransaction.class);
final CountDownLatch submitLatch = setupStubbedSubmit(mockTx);
doReturn(mockTx).when(mockTxChain).newReadWriteTransaction();
doReturn(Futures.immediateCheckedFuture(Optional.of(link))).when(mockTx).read(LogicalDatastoreType.OPERATIONAL, topologyIID.child(Link.class, new LinkKey(new LinkId(sourceNodeConnKey.getId()))));
exporter.onLinkRemoved(new LinkRemovedBuilder().setSource(new NodeConnectorRef(sourceConnID)).setDestination(new NodeConnectorRef(destConnID)).build());
waitForSubmit(submitLatch);
verify(mockTx).delete(LogicalDatastoreType.OPERATIONAL, topologyIID.child(Link.class, new LinkKey(new LinkId(sourceNodeConnKey.getId()))));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef in project openflowplugin by opendaylight.
the class TerminationPointChangeListenerImplTest method testOnNodeConnectorUpdated.
@Test
public void testOnNodeConnectorUpdated() {
org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey nodeKey = newInvNodeKey("node1");
org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey ncKey = newInvNodeConnKey("tp1");
InstanceIdentifier<?> invNodeConnID = newNodeConnID(nodeKey, ncKey);
ReadWriteTransaction mockTx = mock(ReadWriteTransaction.class);
CountDownLatch submitLatch = setupStubbedSubmit(mockTx);
doReturn(mockTx).when(mockTxChain).newReadWriteTransaction();
DataTreeModification dataTreeModification = setupDataTreeChange(WRITE, invNodeConnID);
terminationPointListener.onDataTreeChanged(Collections.singleton(dataTreeModification));
waitForSubmit(submitLatch);
ArgumentCaptor<TerminationPoint> mergedNode = ArgumentCaptor.forClass(TerminationPoint.class);
NodeId expNodeId = new NodeId("node1");
TpId expTpId = new TpId("tp1");
InstanceIdentifier<TerminationPoint> expTpPath = topologyIID.child(Node.class, new NodeKey(expNodeId)).child(TerminationPoint.class, new TerminationPointKey(expTpId));
verify(mockTx).merge(eq(LogicalDatastoreType.OPERATIONAL), eq(expTpPath), mergedNode.capture(), eq(true));
assertEquals("getTpId", expTpId, mergedNode.getValue().getTpId());
InventoryNodeConnector augmentation = mergedNode.getValue().getAugmentation(InventoryNodeConnector.class);
assertNotNull("Missing augmentation", augmentation);
assertEquals("getInventoryNodeConnectorRef", new NodeConnectorRef(invNodeConnID), augmentation.getInventoryNodeConnectorRef());
}
Aggregations