Search in sources :

Example 11 with WriteTransaction

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);
}
Also used : WriteTransaction(org.opendaylight.mdsal.binding.api.WriteTransaction) InterVpnLinkStates(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.InterVpnLinkStates) VpnUtil(org.opendaylight.netvirt.vpnmanager.VpnUtil) InterVpnLinks(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.InterVpnLinks) InterVpnLinksBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.InterVpnLinksBuilder) InterVpnLinkStatesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.InterVpnLinkStatesBuilder) InterVpnLinkDataComposite(org.opendaylight.netvirt.vpnmanager.api.intervpnlink.InterVpnLinkDataComposite) Before(org.junit.Before)

Example 12 with WriteTransaction

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();
    }
}
Also used : WriteTransaction(org.opendaylight.mdsal.binding.api.WriteTransaction) L3VpnComposite(org.opendaylight.netvirt.vpnmanager.intervpnlink.L3VpnTestCatalog.L3VpnComposite)

Example 13 with WriteTransaction

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();
    }
}
Also used : WriteTransaction(org.opendaylight.mdsal.binding.api.WriteTransaction) InterVpnLinkDataComposite(org.opendaylight.netvirt.vpnmanager.api.intervpnlink.InterVpnLinkDataComposite)

Example 14 with WriteTransaction

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();
    }
}
Also used : WriteTransaction(org.opendaylight.mdsal.binding.api.WriteTransaction) VpnInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.to.vpn.id.VpnInstance) L3VpnComposite(org.opendaylight.netvirt.vpnmanager.intervpnlink.L3VpnTestCatalog.L3VpnComposite) VpnInstanceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.to.vpn.id.VpnInstanceBuilder)

Example 15 with WriteTransaction

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();
}
Also used : WriteTransaction(org.opendaylight.mdsal.binding.api.WriteTransaction) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) NodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)

Aggregations

WriteTransaction (org.opendaylight.mdsal.binding.api.WriteTransaction)23 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)6 List (java.util.List)5 ArrayList (java.util.ArrayList)4 Optional (java.util.Optional)4 Collectors.toList (java.util.stream.Collectors.toList)4 Inject (javax.inject.Inject)4 Singleton (javax.inject.Singleton)4 NonNull (org.eclipse.jdt.annotation.NonNull)4 Nullable (org.eclipse.jdt.annotation.Nullable)4 DataTreeEventCallbackRegistrar (org.opendaylight.genius.datastoreutils.listeners.DataTreeEventCallbackRegistrar)4 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)4 NwConstants (org.opendaylight.genius.mdsalutil.NwConstants)4 ActionNxLoadInPort (org.opendaylight.genius.mdsalutil.actions.ActionNxLoadInPort)4 ActionSetFieldEthernetDestination (org.opendaylight.genius.mdsalutil.actions.ActionSetFieldEthernetDestination)4 ActionSetFieldTunnelId (org.opendaylight.genius.mdsalutil.actions.ActionSetFieldTunnelId)4 InstructionApplyActions (org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)4 Inet4Address (java.net.Inet4Address)3 InetAddress (java.net.InetAddress)3 UnknownHostException (java.net.UnknownHostException)3