use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint 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.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint in project openflowplugin by opendaylight.
the class TerminationPointChangeListenerImplTest method testOnNodeConnectorUpdatedWithPortDown.
@SuppressWarnings("rawtypes")
@Test
public void testOnNodeConnectorUpdatedWithPortDown() {
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");
final InstanceIdentifier<?> invNodeConnID = newNodeConnID(nodeKey, ncKey);
List<Link> linkList = Arrays.asList(newLink("link1", newSourceTp("tp1"), newDestTp("dest")));
Topology topology = new TopologyBuilder().setLink(linkList).build();
ReadWriteTransaction mockTx = mock(ReadWriteTransaction.class);
doReturn(Futures.immediateCheckedFuture(Optional.of(topology))).when(mockTx).read(LogicalDatastoreType.OPERATIONAL, topologyIID);
setupStubbedSubmit(mockTx);
CountDownLatch deleteLatch = new CountDownLatch(1);
ArgumentCaptor<InstanceIdentifier> deletedLinkIDs = ArgumentCaptor.forClass(InstanceIdentifier.class);
setupStubbedDeletes(mockTx, deletedLinkIDs, deleteLatch);
doReturn(mockTx).when(mockTxChain).newReadWriteTransaction();
DataTreeModification dataTreeModification = setupDataTreeChange(WRITE, invNodeConnID);
when(dataTreeModification.getRootNode().getDataAfter()).thenReturn(provideFlowCapableNodeConnector(false, true));
terminationPointListener.onDataTreeChanged(Collections.singleton(dataTreeModification));
waitForDeletes(1, deleteLatch);
InstanceIdentifier<TerminationPoint> expTpPath = topologyIID.child(Node.class, new NodeKey(new NodeId("node1"))).child(TerminationPoint.class, new TerminationPointKey(new TpId("tp1")));
verify(mockTx).merge(eq(LogicalDatastoreType.OPERATIONAL), eq(expTpPath), any(TerminationPoint.class), eq(true));
assertDeletedIDs(new InstanceIdentifier[] { topologyIID.child(Link.class, linkList.get(0).getKey()) }, deletedLinkIDs);
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint 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());
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint in project genius by opendaylight.
the class InterfaceManagerConfigurationTest method rebuildTerminationPoint.
private TerminationPoint rebuildTerminationPoint(TerminationPoint tp) {
// The problem we're fixing here is that, in MD-SAL binding v1, YANG lists are represented
// as Java lists but they don't preserve order (unless they specify “ordered-by user”).
// YANG keyed lists in particular are backed by maps, so you can store such a list in the
// MD-SAL and get it back in a different order.
// When comparing beans involving such lists, we need to sort the lists before comparing
// them. Retrieving the augmentation gives a modifiable list, so it's tempting to just
// sort that — but the list is re-created every time the augmentation is retrieved, so
// the sort is lost.
// To avoid all this, we rebuild instances of TerminationPoint, and sort the affected lists
// in the augmentations, with full augmentation rebuilds too (since the lists in a built
// augmentation might be unmodifiable).
TerminationPointBuilder newTpBuilder = new TerminationPointBuilder(tp);
OvsdbTerminationPointAugmentation ovsdbTpAugmentation = tp.getAugmentation(OvsdbTerminationPointAugmentation.class);
if (ovsdbTpAugmentation != null) {
OvsdbTerminationPointAugmentationBuilder newOvsdbTpAugmentationBuilder = new OvsdbTerminationPointAugmentationBuilder(ovsdbTpAugmentation);
if (ovsdbTpAugmentation.getOptions() != null) {
List<Options> options = new ArrayList<>(ovsdbTpAugmentation.getOptions());
options.sort(Comparator.comparing(o -> o.getKey().toString()));
newOvsdbTpAugmentationBuilder.setOptions(options);
}
if (ovsdbTpAugmentation.getInterfaceBfd() != null) {
List<InterfaceBfd> interfaceBfd = new ArrayList<>(ovsdbTpAugmentation.getInterfaceBfd());
interfaceBfd.sort(Comparator.comparing(o -> o.getKey().toString()));
newOvsdbTpAugmentationBuilder.setInterfaceBfd(interfaceBfd);
}
newTpBuilder.addAugmentation(OvsdbTerminationPointAugmentation.class, newOvsdbTpAugmentationBuilder.build());
}
return newTpBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint in project genius by opendaylight.
the class InterfacemgrProvider method getPortsOnBridgeByType.
/**
* Get all termination points by type on a given DPN.
*
* @param dpnId
* Datapath Node Identifier
*
* @return If the data at the supplied path exists, returns a Map where key is interfaceType
* and value is list of termination points of given type
*/
@Override
public Map<Class<? extends InterfaceTypeBase>, List<OvsdbTerminationPointAugmentation>> getPortsOnBridgeByType(BigInteger dpnId) {
Map<Class<? extends InterfaceTypeBase>, List<OvsdbTerminationPointAugmentation>> portMap;
portMap = new ConcurrentHashMap<>();
List<TerminationPoint> ovsPorts = interfaceMetaUtils.getTerminationPointsOnBridge(dpnId);
if (ovsPorts != null) {
for (TerminationPoint ovsPort : ovsPorts) {
OvsdbTerminationPointAugmentation portAug = ovsPort.getAugmentation(OvsdbTerminationPointAugmentation.class);
if (portAug != null && portAug.getInterfaceType() != null) {
portMap.computeIfAbsent(portAug.getInterfaceType(), k -> new ArrayList<>()).add(portAug);
}
}
}
return portMap;
}
Aggregations