TopologyTypesVbridgeAugment.class,
new TopologyTypesVbridgeAugmentBuilder().setVbridgeTopology(new VbridgeTopologyBuilder().build()).build())
.build();
- @VisibleForTesting
- static long WAIT_FOR_TOPOLOGY_CREATION = 10; // seconds
private final DataBroker dataProvder;
private static final class ListenableFutureSetter<T extends DataObject>
@Override
public ListenableFuture<Void> apply(Optional<Topology> optTopology) throws Exception {
- SettableFuture<Void> topoFuture = SettableFuture.create();
+ WriteTransaction wTx = dataProvder.newWriteOnlyTransaction();
if (!optTopology.isPresent()) {
- WriteTransaction wTx = dataProvder.newWriteOnlyTransaction();
Topology topology = new TopologyBuilder().setKey(topologyKey)
.setTopologyTypes(VBRIDGE_TOPOLOGY_TYPE)
.addAugmentation(TopologyVbridgeAugment.class, vBridgeAug)
.build();
wTx.put(LogicalDatastoreType.CONFIGURATION, topologyIid,
topology, true);
- Futures.addCallback(wTx.submit(), new FutureCallback<Void>() {
-
- @Override
- public void onSuccess(Void result) {
- DataTreeIdentifier<Topology> topoIdentifier =
- new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, topologyIid);
- new ListenableFutureSetter<>(dataProvder, topoFuture, topoIdentifier,
- ModificationType.WRITE);
- }
-
- @Override
- public void onFailure(Throwable t) {
- LOG.warn("Request create topology for VBD was not stored to CONF DS. {}", topologyIid, t);
- topoFuture.setException(new Exception("Cannot send request to VBD."));
- }});
- } else {
- topoFuture.set(null);
}
- topoFuture.get(WAIT_FOR_TOPOLOGY_CREATION, TimeUnit.SECONDS);
- WriteTransaction wTx = dataProvder.newWriteOnlyTransaction();
InstanceIdentifier<Node> nodeIid = VppIidFactory.getNodeIid(topologyKey, vppNode.getKey());
wTx.put(LogicalDatastoreType.CONFIGURATION, nodeIid, vppNode);
SettableFuture<Void> future = SettableFuture.create();
ImmutableSet<RendererEndpointKey> rendEpsBefore = policyCtxBefore.getPolicyTable().rowKeySet();
ImmutableSet<RendererEndpointKey> rendEpsAfter = policyCtxAfter.getPolicyTable().rowKeySet();
SetMultimap<String, NodeId> vppNodesByL2FdBefore = resolveVppNodesByL2Fd(rendEpsBefore, policyCtxBefore);
- SetMultimap<String, NodeId> vppNodesByL2FdAfter = resolveVppNodesByL2Fd(rendEpsAfter, policyCtxBefore);
+ SetMultimap<String, NodeId> vppNodesByL2FdAfter = resolveVppNodesByL2Fd(rendEpsAfter, policyCtxAfter);
return Maps.difference(vppNodesByL2FdBefore.asMap(), vppNodesByL2FdAfter.asMap());
}
public void init() {
dataBroker = getDataBroker();
bridgeDomainManager = new BridgeDomainManagerImpl(dataBroker);
- BridgeDomainManagerImpl.WAIT_FOR_TOPOLOGY_CREATION = 2;
}
@Test
public void testCreateVxlanBridgeDomainOnVppNode() throws Exception {
- WriteTransaction wTx = dataBroker.newWriteOnlyTransaction();
- wTx.put(LogicalDatastoreType.OPERATIONAL, VppIidFactory.getTopologyIid(BASE_TOPOLOGY.getKey()),
- new TopologyBuilder().setKey(BASE_TOPOLOGY.getKey()).build());
- wTx.submit().get();
bridgeDomainManager.createVxlanBridgeDomainOnVppNode(BRIDGE_DOMAIN_ID, BRIDGE_DOMAIN_VNI, VPP_NODE_ID);
Optional<Topology> topologyOptional = DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION,