Search in sources :

Example 6 with VpnInstanceOpDataEntryKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntryKey in project netvirt by opendaylight.

the class NeutronvpnUtils method updateVpnInstanceWithIpFamily.

public void updateVpnInstanceWithIpFamily(String vpnName, IpVersionChoice ipVersion, boolean add) {
    VpnInstanceOpDataEntry vpnInstanceOpDataEntry = getVpnInstanceOpDataEntryFromVpnId(vpnName);
    if (vpnInstanceOpDataEntry == null) {
        return;
    }
    if (vpnInstanceOpDataEntry.getType() == VpnInstanceOpDataEntry.Type.L2) {
        LOG.debug("updateVpnInstanceWithIpFamily: Update VpnInstance {} with ipFamily {}." + "VpnInstanceOpDataEntry is L2 instance. Do nothing.", vpnName, ipVersion.toString());
        return;
    }
    final boolean isFinalVpnInstanceIpv6Changed = ipVersion.isIpVersionChosen(IpVersionChoice.IPV6) ? true : false;
    final boolean isFinalVpnInstanceIpv4Changed = ipVersion.isIpVersionChosen(IpVersionChoice.IPV4) ? true : false;
    final boolean finalIsIpv4Configured = ipVersion.isIpVersionChosen(IpVersionChoice.IPV4) ? add : false;
    final boolean finalIsIpv6Configured = ipVersion.isIpVersionChosen(IpVersionChoice.IPV6) ? add : false;
    jobCoordinator.enqueueJob("VPN-" + vpnName, () -> {
        VpnInstanceOpDataEntryBuilder builder = new VpnInstanceOpDataEntryBuilder(vpnInstanceOpDataEntry);
        if (isFinalVpnInstanceIpv4Changed) {
            builder.setIpv4Configured(finalIsIpv4Configured);
        }
        if (isFinalVpnInstanceIpv6Changed) {
            builder.setIpv6Configured(finalIsIpv6Configured);
        }
        WriteTransaction writeTxn = dataBroker.newWriteOnlyTransaction();
        InstanceIdentifier<VpnInstanceOpDataEntry> id = InstanceIdentifier.builder(VpnInstanceOpData.class).child(VpnInstanceOpDataEntry.class, new VpnInstanceOpDataEntryKey(vpnInstanceOpDataEntry.getVrfId())).build();
        writeTxn.merge(LogicalDatastoreType.OPERATIONAL, id, builder.build(), false);
        LOG.info("updateVpnInstanceWithIpFamily: Successfully {} {} to Vpn {}", add ? "added" : "removed", ipVersion.toString(), vpnName);
        return Collections.singletonList(writeTxn.submit());
    });
    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)

Aggregations

VpnInstanceOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry)6 VpnInstanceOpDataEntryKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntryKey)6 VpnInstanceOpData (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.VpnInstanceOpData)3 Optional (com.google.common.base.Optional)2 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)2 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)2 VpnInstanceOpDataEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntryBuilder)2 CheckedFuture (com.google.common.util.concurrent.CheckedFuture)1 BigInteger (java.math.BigInteger)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 List (java.util.List)1 ExecutionException (java.util.concurrent.ExecutionException)1 Collectors (java.util.stream.Collectors)1 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)1 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)1 SingleTransactionDataBroker (org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker)1 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)1 FlowEntity (org.opendaylight.genius.mdsalutil.FlowEntity)1 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)1