Sonar clean-up: braces for control statements
[netvirt.git] / openstack / net-virt / src / main / java / org / opendaylight / ovsdb / openstack / netvirt / NeutronCacheUtils.java
index bed81ab6dccc1057c8986dc152810a6df9a01312..e3291fba92a8dc41eee96c9dd124c1a4ac337b1f 100755 (executable)
 
 package org.opendaylight.ovsdb.openstack.netvirt;
 
-import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkCRUD;
-import org.opendaylight.controller.networkconfig.neutron.INeutronPortCRUD;
-import org.opendaylight.controller.networkconfig.neutron.INeutronSubnetCRUD;
-import org.opendaylight.controller.networkconfig.neutron.NeutronNetwork;
-import org.opendaylight.controller.networkconfig.neutron.NeutronPort;
-import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet;
-import org.opendaylight.controller.networkconfig.neutron.Neutron_IPs;
+import org.opendaylight.neutron.spi.INeutronNetworkCRUD;
+import org.opendaylight.neutron.spi.INeutronPortCRUD;
+import org.opendaylight.neutron.spi.INeutronSubnetCRUD;
+import org.opendaylight.neutron.spi.NeutronNetwork;
+import org.opendaylight.neutron.spi.NeutronPort;
+import org.opendaylight.neutron.spi.NeutronSubnet;
+import org.opendaylight.neutron.spi.Neutron_IPs;
 
 import java.util.AbstractMap;
 import java.util.Iterator;
@@ -30,9 +30,10 @@ public class NeutronCacheUtils {
      * @param ipAddr IP address of a member or VM
      * @return MAC address registered with that IP address
      */
-    public static String getMacAddress(INeutronPortCRUD neutronPortsCache, String ipAddr) {
-        if (ipAddr == null)
+    public static String getMacAddress(INeutronPortCRUD neutronPortsCache, String subnetID, String ipAddr) {
+        if (ipAddr == null || subnetID == null) {
             return null;
+        }
 
         List<Neutron_IPs> fixedIPs;
         Iterator<Neutron_IPs> fixedIPIterator;
@@ -47,8 +48,9 @@ public class NeutronCacheUtils {
                 fixedIPIterator = fixedIPs.iterator();
                 while (fixedIPIterator.hasNext()) {
                     ip = fixedIPIterator.next();
-                    if (ip.getIpAddress().equals(ipAddr))
+                    if (ip.getIpAddress().equals(ipAddr) && ip.getSubnetUUID().equals(subnetID)) {
                         return port.getMacAddress();
+                    }
                 }
             }
         }
@@ -58,7 +60,7 @@ public class NeutronCacheUtils {
     /**
      * Look up in the NeutronNetworkCRUD cache and NeutronSubnetCRUD cache for
      * extracting the provider segmentation_type and segmentation_id
-     * @param subnetId Subnet UUID
+     * @param subnetID Subnet UUID
      * @return {Type: ID} pair for that subnet ID
      */
     public static Map.Entry<String,String> getProviderInformation(INeutronNetworkCRUD neutronNetworkCache,
@@ -73,8 +75,9 @@ public class NeutronCacheUtils {
                 break;
             }
         }
-        if (networkID == null)
+        if (networkID == null) {
             return null;
+        }
 
         List<NeutronNetwork> allNetworks = neutronNetworkCache.getAllNetworks();
         for (NeutronNetwork network: allNetworks) {