Search in sources :

Example 46 with WriteTransaction

use of org.opendaylight.controller.md.sal.binding.api.WriteTransaction in project netvirt by opendaylight.

the class InterVpnLinkLocatorTest method cleanL3Vpns.

public void cleanL3Vpns(DataBroker broker, List<L3VpnComposite> vpns) throws TransactionCommitFailedException {
    for (L3VpnComposite vpn : vpns) {
        WriteTransaction writeTx1 = broker.newWriteOnlyTransaction();
        writeTx1.delete(LogicalDatastoreType.OPERATIONAL, VpnUtil.getVpnInstanceOpDataIdentifier(vpn.vpnOpData.getVrfId()));
        writeTx1.submit().checkedGet();
        WriteTransaction writeTx2 = broker.newWriteOnlyTransaction();
        writeTx2.delete(LogicalDatastoreType.CONFIGURATION, VpnOperDsUtils.getVpnInstanceToVpnIdIdentifier(vpn.vpnCfgData.getVpnInstanceName()));
        writeTx2.submit().checkedGet();
    }
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) L3VpnComposite(org.opendaylight.netvirt.vpnmanager.intervpnlink.L3VpnTestCatalog.L3VpnComposite)

Example 47 with WriteTransaction

use of org.opendaylight.controller.md.sal.binding.api.WriteTransaction in project netvirt by opendaylight.

the class InterVpnLinkTestCatalog method cleanIvpnLinks.

public static void cleanIvpnLinks(DataBroker broker2, InterVpnLinkDataComposite... ivpnLinks) throws TransactionCommitFailedException {
    for (InterVpnLinkDataComposite ivpnLink : ivpnLinks) {
        WriteTransaction writeTx1 = broker2.newWriteOnlyTransaction();
        writeTx1.delete(LogicalDatastoreType.OPERATIONAL, InterVpnLinkUtil.getInterVpnLinkStateIid(ivpnLink.getInterVpnLinkName()));
        writeTx1.submit().checkedGet();
        WriteTransaction writeTx2 = broker2.newWriteOnlyTransaction();
        writeTx2.delete(LogicalDatastoreType.CONFIGURATION, InterVpnLinkUtil.getInterVpnLinkPath(ivpnLink.getInterVpnLinkName()));
        writeTx2.submit().checkedGet();
    }
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) InterVpnLinkDataComposite(org.opendaylight.netvirt.vpnmanager.api.intervpnlink.InterVpnLinkDataComposite)

Example 48 with WriteTransaction

use of org.opendaylight.controller.md.sal.binding.api.WriteTransaction in project netvirt by opendaylight.

the class VpnNodeListener method processNodeAdd.

private void processNodeAdd(BigInteger dpId) {
    jobCoordinator.enqueueJob("VPNNODE-" + dpId.toString(), () -> {
        WriteTransaction writeFlowTx = broker.newWriteOnlyTransaction();
        LOG.debug("Received notification to install TableMiss entries for dpn {} ", dpId);
        makeTableMissFlow(writeFlowTx, dpId, NwConstants.ADD_FLOW);
        makeL3IntfTblMissFlow(writeFlowTx, dpId, NwConstants.ADD_FLOW);
        makeSubnetRouteTableMissFlow(writeFlowTx, dpId, NwConstants.ADD_FLOW);
        createTableMissForVpnGwFlow(writeFlowTx, dpId);
        createL3GwMacArpFlows(writeFlowTx, dpId);
        programTableMissForVpnVniDemuxTable(writeFlowTx, dpId, NwConstants.ADD_FLOW);
        return Collections.singletonList(writeFlowTx.submit());
    }, 3);
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction)

Example 49 with WriteTransaction

use of org.opendaylight.controller.md.sal.binding.api.WriteTransaction in project netvirt by opendaylight.

the class InterVpnLinkCreatorTask method call.

@Override
public List<ListenableFuture<Void>> call() {
    LOG.debug("Persisting InterVpnLink {} with 1stEndpoint=[ vpn={}, ipAddr={} ] and 2ndEndpoint=[ vpn={}, ipAddr={} ]", interVpnLinkToPersist.getName(), interVpnLinkToPersist.getFirstEndpoint().getVpnUuid(), interVpnLinkToPersist.getFirstEndpoint().getIpAddress(), interVpnLinkToPersist.getSecondEndpoint().getVpnUuid(), interVpnLinkToPersist.getSecondEndpoint().getIpAddress());
    List<ListenableFuture<Void>> result = new ArrayList<>();
    WriteTransaction writeTx = dataBroker.newWriteOnlyTransaction();
    writeTx.merge(LogicalDatastoreType.CONFIGURATION, InterVpnLinkUtil.getInterVpnLinkPath(interVpnLinkToPersist.getName()), interVpnLinkToPersist, true);
    result.add(writeTx.submit());
    return result;
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) ArrayList(java.util.ArrayList) ListenableFuture(com.google.common.util.concurrent.ListenableFuture)

Example 50 with WriteTransaction

use of org.opendaylight.controller.md.sal.binding.api.WriteTransaction in project netvirt by opendaylight.

the class NeutronvpnUtils method updateVpnInstanceOpWithType.

public void updateVpnInstanceOpWithType(VpnInstanceOpDataEntry.BgpvpnType choice, @Nonnull Uuid vpn) {
    String primaryRd = getVpnRd(vpn.getValue());
    if (primaryRd == null) {
        LOG.debug("updateVpnInstanceOpWithType: Update BgpvpnType {} for {}." + "Primary RD not found", choice, vpn.getValue());
        return;
    }
    InstanceIdentifier<VpnInstanceOpDataEntry> id = InstanceIdentifier.builder(VpnInstanceOpData.class).child(VpnInstanceOpDataEntry.class, new VpnInstanceOpDataEntryKey(primaryRd)).build();
    Optional<VpnInstanceOpDataEntry> vpnInstanceOpDataEntryOptional = read(LogicalDatastoreType.OPERATIONAL, id);
    if (!vpnInstanceOpDataEntryOptional.isPresent()) {
        LOG.debug("updateVpnInstanceOpWithType: Update BgpvpnType {} for {}." + "VpnInstanceOpDataEntry not found", choice, vpn.getValue());
        return;
    }
    VpnInstanceOpDataEntry vpnInstanceOpDataEntry = vpnInstanceOpDataEntryOptional.get();
    if (vpnInstanceOpDataEntry.getBgpvpnType().equals(choice)) {
        LOG.debug("updateVpnInstanceOpWithType: Update BgpvpnType {} for {}." + "VpnInstanceOpDataEntry already set", choice, vpn.getValue());
        return;
    }
    VpnInstanceOpDataEntryBuilder builder = new VpnInstanceOpDataEntryBuilder(vpnInstanceOpDataEntry);
    builder.setBgpvpnType(choice);
    WriteTransaction writeTxn = dataBroker.newWriteOnlyTransaction();
    writeTxn.merge(LogicalDatastoreType.OPERATIONAL, id, builder.build(), false);
    LOG.debug("updateVpnInstanceOpWithType: sent merge to operDS BgpvpnType {} for {}", choice, vpn.getValue());
    try {
        writeTxn.submit().get();
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("updateVpnInstanceOpWithType: on merge execution, error:  {}", e);
    }
    return;
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) VpnInstanceOpDataEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntryBuilder) VpnInstanceOpDataEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntryKey) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)320 ArrayList (java.util.ArrayList)74 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)60 BigInteger (java.math.BigInteger)43 Test (org.junit.Test)38 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)37 ExecutionException (java.util.concurrent.ExecutionException)33 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)28 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)25 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)23 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)23 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)22 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)19 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)17 List (java.util.List)16 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)16 VpnInstanceOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry)16 DataObject (org.opendaylight.yangtools.yang.binding.DataObject)15 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)14 VpnToDpnList (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList)14