use of org.opendaylight.mdsal.binding.api.WriteTransaction in project netvirt by opendaylight.
the class InterVpnLinkLocatorTest method setUp.
@Before
public void setUp() throws Exception {
dataBroker = getDataBroker();
vpnUtil = new VpnUtil(dataBroker, idManager, fibManager, bgpManager, lockManager, neutronVpnService, mdsalManager, jobCoordinator, interfaceManager, ifmRpcService);
// Creating both empty containers: InterVpnLinks and InterVpnLinkStates
WriteTransaction writeTx = dataBroker.newWriteOnlyTransaction();
writeTx.merge(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(InterVpnLinks.class), new InterVpnLinksBuilder().setInterVpnLink(Collections.emptyList()).build());
writeTx.merge(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(InterVpnLinkStates.class), new InterVpnLinkStatesBuilder().setInterVpnLinkState(Collections.emptyList()).build());
writeTx.commit().get();
interVpnLinkCache = new InterVpnLinkCacheImpl(dataBroker);
interVpnLinkCache.initialFeed();
// Prepare
populateL3Vpns(dataBroker, L3VpnTestCatalog.ALL_VPNS);
InterVpnLinkTestCatalog.populateIvpnLinks(dataBroker, ALL_IVPN_LINKS);
for (InterVpnLinkDataComposite ivl : ALL_IVPN_LINKS) {
interVpnLinkCache.addInterVpnLinkToCaches(ivl.getInterVpnLinkConfig());
interVpnLinkCache.addInterVpnLinkStateToCaches(ivl.getInterVpnLinkState());
}
// SUT
sut = new InterVpnLinkLocator(dataBroker, interVpnLinkCache, vpnUtil);
}
use of org.opendaylight.mdsal.binding.api.WriteTransaction in project netvirt by opendaylight.
the class InterVpnLinkLocatorTest method cleanL3Vpns.
public void cleanL3Vpns(DataBroker broker, List<L3VpnComposite> vpns) throws ExecutionException, InterruptedException {
for (L3VpnComposite vpn : vpns) {
WriteTransaction writeTx1 = broker.newWriteOnlyTransaction();
writeTx1.delete(LogicalDatastoreType.OPERATIONAL, VpnUtil.getVpnInstanceOpDataIdentifier(vpn.vpnOpData.getVrfId()));
writeTx1.commit().get();
WriteTransaction writeTx2 = broker.newWriteOnlyTransaction();
writeTx2.delete(LogicalDatastoreType.CONFIGURATION, VpnOperDsUtils.getVpnInstanceToVpnIdIdentifier(vpn.vpnCfgData.getVpnInstanceName()));
writeTx2.commit().get();
}
}
use of org.opendaylight.mdsal.binding.api.WriteTransaction in project netvirt by opendaylight.
the class InterVpnLinkTestCatalog method cleanIvpnLinks.
public static void cleanIvpnLinks(DataBroker broker2, InterVpnLinkDataComposite... ivpnLinks) throws ExecutionException, InterruptedException {
for (InterVpnLinkDataComposite ivpnLink : ivpnLinks) {
WriteTransaction writeTx1 = broker2.newWriteOnlyTransaction();
writeTx1.delete(LogicalDatastoreType.OPERATIONAL, InterVpnLinkUtil.getInterVpnLinkStateIid(ivpnLink.getInterVpnLinkName()));
writeTx1.commit().get();
WriteTransaction writeTx2 = broker2.newWriteOnlyTransaction();
writeTx2.delete(LogicalDatastoreType.CONFIGURATION, InterVpnLinkUtil.getInterVpnLinkPath(ivpnLink.getInterVpnLinkName()));
writeTx2.commit().get();
}
}
use of org.opendaylight.mdsal.binding.api.WriteTransaction in project netvirt by opendaylight.
the class InterVpnLinkLocatorTest method populateL3Vpns.
// ////////////
// Stubbing //
// ////////////
public void populateL3Vpns(DataBroker broker, List<L3VpnComposite> vpns) throws ExecutionException, InterruptedException {
for (L3VpnComposite vpn : vpns) {
VpnInstance vpnInstance = new VpnInstanceBuilder().setVpnId(vpn.vpnOpData.getVpnId()).setVpnInstanceName(vpn.vpnOpData.getVpnInstanceName()).setVrfId(vpn.vpnOpData.getVrfId()).build();
WriteTransaction writeTx1 = broker.newWriteOnlyTransaction();
writeTx1.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, VpnOperDsUtils.getVpnInstanceToVpnIdIdentifier(vpn.vpnCfgData.getVpnInstanceName()), vpnInstance);
writeTx1.commit().get();
WriteTransaction writeTx2 = broker.newWriteOnlyTransaction();
writeTx2.mergeParentStructureMerge(LogicalDatastoreType.OPERATIONAL, VpnUtil.getVpnInstanceOpDataIdentifier(vpn.vpnOpData.getVrfId()), vpn.vpnOpData);
writeTx2.commit().get();
}
}
use of org.opendaylight.mdsal.binding.api.WriteTransaction in project netvirt by opendaylight.
the class InterVpnLinkLocatorTest method stubNwUtilsGetOperativeDpns.
private void stubNwUtilsGetOperativeDpns(int maxNbrOfOperativeDpns) throws Exception {
WriteTransaction writeTx1 = dataBroker.newWriteOnlyTransaction();
for (int i = 1; i <= maxNbrOfOperativeDpns; i++) {
NodeId nodeId = new NodeId("openflow:" + i);
Node node = new NodeBuilder().setId(nodeId).build();
writeTx1.merge(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.builder(Nodes.class).child(Node.class, new NodeKey(nodeId)).build(), node);
}
writeTx1.commit().get();
}
Aggregations