use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder in project openflowplugin by opendaylight.
the class TransactionChainManagerTest method testSubmitTransaction1.
/**
* test of {@link TransactionChainManager#submitTransaction()}: no submit, never enabled.
*/
@Test
public void testSubmitTransaction1() throws Exception {
final Node data = new NodeBuilder().setId(nodeId).build();
txChainManager.writeToTransaction(LogicalDatastoreType.CONFIGURATION, path, data, false);
txChainManager.submitTransaction();
Mockito.verify(txChain).newReadWriteTransaction();
Mockito.verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data, false);
Mockito.verify(writeTx, Mockito.never()).submit();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder in project openflowplugin by opendaylight.
the class TransactionChainManagerTest method testEnableCounter1.
/**
* Test of {@link TransactionChainManager#enableSubmit()}: no submit - counter is not active.
*/
@Test
public void testEnableCounter1() throws Exception {
final Node data = new NodeBuilder().setId(nodeId).build();
txChainManager.writeToTransaction(LogicalDatastoreType.CONFIGURATION, path, data, false);
txChainManager.writeToTransaction(LogicalDatastoreType.CONFIGURATION, path, data, false);
Mockito.verify(txChain).newReadWriteTransaction();
Mockito.verify(writeTx, Mockito.times(2)).put(LogicalDatastoreType.CONFIGURATION, path, data, false);
Mockito.verify(writeTx, Mockito.never()).submit();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder in project openflowplugin by opendaylight.
the class NodeChangeListenerImpl method prepareTopologyNode.
private static org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node prepareTopologyNode(final NodeId nodeIdInTopology, final InstanceIdentifier<FlowCapableNode> iiToNodeInInventory) {
final InventoryNode inventoryNode = new InventoryNodeBuilder().setInventoryNodeRef(new NodeRef(iiToNodeInInventory.firstIdentifierOf(Node.class))).build();
final NodeBuilder topologyNodeBuilder = new NodeBuilder();
topologyNodeBuilder.setNodeId(nodeIdInTopology);
topologyNodeBuilder.addAugmentation(InventoryNode.class, inventoryNode);
return topologyNodeBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder in project openflowplugin by opendaylight.
the class TerminationPointChangeListenerImplTest method testOnNodeConnectorRemoved.
@SuppressWarnings("rawtypes")
@Test
public void testOnNodeConnectorRemoved() {
NodeKey topoNodeKey = new NodeKey(new NodeId("node1"));
TerminationPointKey terminationPointKey = new TerminationPointKey(new TpId("tp1"));
final InstanceIdentifier<Node> topoNodeII = topologyIID.child(Node.class, topoNodeKey);
Node topoNode = new NodeBuilder().setKey(topoNodeKey).build();
org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey nodeKey = newInvNodeKey(topoNodeKey.getNodeId().getValue());
org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey ncKey = newInvNodeConnKey(terminationPointKey.getTpId().getValue());
final InstanceIdentifier<?> invNodeConnID = newNodeConnID(nodeKey, ncKey);
List<Link> linkList = Arrays.asList(newLink("link1", newSourceTp("tp1"), newDestTp("dest")), newLink("link2", newSourceTp("source"), newDestTp("tp1")), newLink("link3", newSourceTp("source2"), newDestTp("dest2")));
final Topology topology = new TopologyBuilder().setLink(linkList).build();
final InstanceIdentifier[] expDeletedIIDs = { topologyIID.child(Link.class, linkList.get(0).getKey()), topologyIID.child(Link.class, linkList.get(1).getKey()), topologyIID.child(Node.class, new NodeKey(new NodeId("node1"))).child(TerminationPoint.class, new TerminationPointKey(new TpId("tp1"))) };
final SettableFuture<Optional<Topology>> readFuture = SettableFuture.create();
readFuture.set(Optional.of(topology));
ReadWriteTransaction mockTx1 = mock(ReadWriteTransaction.class);
doReturn(Futures.makeChecked(readFuture, ReadFailedException.MAPPER)).when(mockTx1).read(LogicalDatastoreType.OPERATIONAL, topologyIID);
SettableFuture<Optional<Node>> readFutureNode = SettableFuture.create();
readFutureNode.set(Optional.of(topoNode));
doReturn(Futures.makeChecked(readFutureNode, ReadFailedException.MAPPER)).when(mockTx1).read(LogicalDatastoreType.OPERATIONAL, topoNodeII);
final CountDownLatch submitLatch1 = setupStubbedSubmit(mockTx1);
int expDeleteCalls = expDeletedIIDs.length;
CountDownLatch deleteLatch = new CountDownLatch(expDeleteCalls);
ArgumentCaptor<InstanceIdentifier> deletedLinkIDs = ArgumentCaptor.forClass(InstanceIdentifier.class);
setupStubbedDeletes(mockTx1, deletedLinkIDs, deleteLatch);
doReturn(mockTx1).when(mockTxChain).newReadWriteTransaction();
DataTreeModification dataTreeModification = setupDataTreeChange(DELETE, invNodeConnID);
terminationPointListener.onDataTreeChanged(Collections.singleton(dataTreeModification));
waitForSubmit(submitLatch1);
setReadFutureAsync(topology, readFuture);
waitForDeletes(expDeleteCalls, deleteLatch);
assertDeletedIDs(expDeletedIIDs, deletedLinkIDs);
verifyMockTx(mockTx1);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder in project genius by opendaylight.
the class OvsdbTestUtil method createNode.
public static CheckedFuture<Void, TransactionCommitFailedException> createNode(ConnectionInfo connectionInfo, String tepIp, String tzName, DataBroker dataBroker) throws Exception {
final InstanceIdentifier<Node> iid = SouthboundUtils.createInstanceIdentifier(connectionInfo);
// build Node using its builder class
NodeBuilder nodeBuilder = new NodeBuilder();
NodeId ovsdbNodeId = SouthboundUtils.createNodeId(connectionInfo.getRemoteIp(), connectionInfo.getRemotePort());
nodeBuilder.setNodeId(ovsdbNodeId);
// build OvsdbNodeAugmentation for Node
OvsdbNodeAugmentationBuilder ovsdbNodeAugBuilder = new OvsdbNodeAugmentationBuilder();
ovsdbNodeAugBuilder.setConnectionInfo(connectionInfo);
// create map of key-val pairs
Map<String, String> externalIds = new HashMap<>();
Map<String, String> otherConfigs = new HashMap<>();
if (tepIp != null && !tepIp.isEmpty()) {
otherConfigs.put(ItmTestConstants.OTHER_CFG_TEP_IP_KEY, tepIp);
}
if (tzName != null) {
externalIds.put(ItmTestConstants.EXTERNAL_ID_TZNAME_KEY, tzName);
}
// get map-keys into set.
Set<String> externalIdKeys = externalIds.keySet();
Set<String> otherConfigKeys = otherConfigs.keySet();
List<OpenvswitchExternalIds> externalIdsList = new ArrayList<>();
String externalIdValue = null;
for (String externalIdKey : externalIdKeys) {
externalIdValue = externalIds.get(externalIdKey);
if (externalIdKey != null && externalIdValue != null) {
externalIdsList.add(new OpenvswitchExternalIdsBuilder().setExternalIdKey(externalIdKey).setExternalIdValue(externalIdValue).build());
}
}
List<OpenvswitchOtherConfigs> otherConfigsList = new ArrayList<>();
String otherConfigValue = null;
for (String otherConfigKey : otherConfigKeys) {
otherConfigValue = otherConfigs.get(otherConfigKey);
if (otherConfigKey != null && otherConfigValue != null) {
otherConfigsList.add(new OpenvswitchOtherConfigsBuilder().setOtherConfigKey(otherConfigKey).setOtherConfigValue(otherConfigValue).build());
}
}
// set ExternalIds list into Node
ovsdbNodeAugBuilder.setOpenvswitchExternalIds(externalIdsList);
// set OtherConfig list into Node
ovsdbNodeAugBuilder.setOpenvswitchOtherConfigs(otherConfigsList);
// add OvsdbNodeAugmentation into Node
nodeBuilder.addAugmentation(OvsdbNodeAugmentation.class, ovsdbNodeAugBuilder.build());
Node ovsdbNode = nodeBuilder.build();
WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
transaction.put(LogicalDatastoreType.OPERATIONAL, iid, ovsdbNode, true);
return transaction.submit();
}
Aggregations