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;
}
Aggregations