MRI version bumpup for Aluminium
[netvirt.git] / vpnmanager / impl / src / main / java / org / opendaylight / netvirt / vpnmanager / VpnManagerImpl.java
index 150d62405c7863d80182012b2689df5a482aa839..544fe5bc18bd9725bed19bea8a9824dec00596c4 100644 (file)
@@ -8,7 +8,6 @@
 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;
@@ -750,7 +749,8 @@ public class VpnManagerImpl implements IVpnManager {
         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;
                     }
@@ -760,7 +760,8 @@ public class VpnManagerImpl implements IVpnManager {
                          *            (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(),
@@ -769,7 +770,8 @@ public class VpnManagerImpl implements IVpnManager {
                         }
                         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());
@@ -791,7 +793,7 @@ public class VpnManagerImpl implements IVpnManager {
                                         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(),
@@ -825,7 +827,8 @@ public class VpnManagerImpl implements IVpnManager {
                 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 {
@@ -852,8 +855,8 @@ public class VpnManagerImpl implements IVpnManager {
             }
         } 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));
         }
     }
 
@@ -867,7 +870,7 @@ public class VpnManagerImpl implements IVpnManager {
         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)) {