Search in sources :

Example 66 with VpnInstanceOpDataEntry

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry 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)61 ArrayList (java.util.ArrayList)28 BigInteger (java.math.BigInteger)26 VrfEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry)23 VpnToDpnList (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList)23 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)21 VrfTablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey)17 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)14 ExecutionException (java.util.concurrent.ExecutionException)14 AdjacenciesOp (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.AdjacenciesOp)14 Adjacency (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency)13 List (java.util.List)12 Prefixes (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes)12 Optional (com.google.common.base.Optional)11 RouteOrigin (org.opendaylight.netvirt.fibmanager.api.RouteOrigin)11 VrfTables (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables)11 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)11 Collections (java.util.Collections)10 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)10 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)10