package org.opendaylight.netvirt.vpnmanager;
import static org.opendaylight.genius.infra.Datastore.OPERATIONAL;
-import static org.opendaylight.mdsal.binding.api.WriteTransaction.CREATE_MISSING_PARENTS;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.ArrayList;
for (RouteTarget routerTarget : routeTargetSet) {
if (routerTarget.getAssociatedSubnet() != null) {
for (int i = 0; i < routerTarget.getAssociatedSubnet().size(); i++) {
- AssociatedSubnet associatedSubnet = routerTarget.getAssociatedSubnet().get(i);
+ AssociatedSubnet associatedSubnet =
+ new ArrayList<AssociatedSubnet>(routerTarget.getAssociatedSubnet().values()).get(i);
if (VpnUtil.areSubnetsOverlapping(associatedSubnet.getCidr(), subnetCidr)) {
return true;
}
* (2) iRT=A eRT=B subnet-range=S1; OK
* (3) iRT=B eRT=A subnet-range=S2; NOK
* Check if (1) and (2) are importing the same subnet-range routes to (3) */
- List<AssociatedVpn> multipleAssociatedVpn = associatedSubnet.getAssociatedVpn();
+ List<AssociatedVpn> multipleAssociatedVpn
+ = new ArrayList<AssociatedVpn>(associatedSubnet.getAssociatedVpn().values());
if (multipleAssociatedVpn != null && multipleAssociatedVpn.size() > 1) {
LOG.error("doesExistingVpnsHaveConflictingSubnet: There is an indirect complete overlap"
+ " for subnet CIDR {} for rt {} rtType {}", subnetCidr, routerTarget.getRt(),
}
for (int j = i + 1; j < routerTarget.getAssociatedSubnet().size(); j++) {
if (VpnUtil.areSubnetsOverlapping(associatedSubnet.getCidr(),
- routerTarget.getAssociatedSubnet().get(j).getCidr())) {
+ new ArrayList<AssociatedSubnet>(routerTarget.getAssociatedSubnet()
+ .values()).get(j).getCidr())) {
LOG.error("doesExistingVpnsHaveConflictingSubnet: There is an indirect paartial"
+ " overlap for subnet CIDR {} for rt {} rtType {}", subnetCidr,
routerTarget.getRt(), routerTarget.getRtType());
routerTarget.getRt(), RouteTarget.RtType.ERT));
if (indirectRts.isPresent() && indirectRts.get().getAssociatedSubnet() != null
&& routerTarget.getAssociatedSubnet() != null) {
- for (AssociatedSubnet associatedSubnet : indirectRts.get().getAssociatedSubnet()) {
+ for (AssociatedSubnet associatedSubnet : indirectRts.get().getAssociatedSubnet().values()) {
if (VpnUtil.areSubnetsOverlapping(associatedSubnet.getCidr(), subnetCidr)) {
LOG.error("doesExistingVpnsHaveConflictingSubnet: There is an indirect overlap for"
+ " subnet CIDR {} for rt {} rtType {}", subnetCidr, routerTarget.getRt(),
tx.read(VpnUtil.getAssociatedSubnetIdentifier(rt, rtType, cidr)).get();
boolean deleteParent = false;
if (associatedSubnet.isPresent()) {
- List<AssociatedVpn> associatedVpns = new ArrayList<>(associatedSubnet.get().nonnullAssociatedVpn());
+ List<AssociatedVpn> associatedVpns
+ = new ArrayList<>(associatedSubnet.get().nonnullAssociatedVpn().values());
if (associatedVpns == null || associatedVpns.isEmpty()) {
deleteParent = true;
} else {
}
} else {
//Add RT-Subnet-Vpn Association
- tx.put(VpnUtil.getAssociatedSubnetAndVpnIdentifier(rt, rtType, cidr, vpnName),
- VpnUtil.buildAssociatedSubnetAndVpn(vpnName), CREATE_MISSING_PARENTS);
+ tx.mergeParentStructurePut(VpnUtil.getAssociatedSubnetAndVpnIdentifier(rt, rtType, cidr, vpnName),
+ VpnUtil.buildAssociatedSubnetAndVpn(vpnName));
}
}
Optional<RouteTarget> rtToSubnetsAssociation = tx.read(rtIdentifier).get();
if (rtToSubnetsAssociation.isPresent()) {
List<AssociatedSubnet> associatedSubnets = new ArrayList<>(rtToSubnetsAssociation.get()
- .nonnullAssociatedSubnet());
+ .nonnullAssociatedSubnet().values());
if (associatedSubnets != null && !associatedSubnets.isEmpty()) {
for (Iterator<AssociatedSubnet> iterator = associatedSubnets.iterator(); iterator.hasNext(); ) {
if (Objects.equals(iterator.next().getCidr(), cidr)) {