Fixing Bug 1900 and 1908
[ovsdb.git] / openstack / net-virt / src / main / java / org / opendaylight / ovsdb / openstack / netvirt / NeutronCacheUtils.java
index 3b893d9a385679df74aa75ac38ff94338645aad5..9f0984a94992ed51f34f773aafefc5e8087d31ab 100755 (executable)
@@ -24,24 +24,27 @@ public class NeutronCacheUtils {
      * @return MAC address registered with that IP address
      */
     public static String getMacAddress(INeutronPortCRUD neutronPortsCache, String ipAddr) {
-            List<Neutron_IPs> fixedIPs;
-            Iterator<Neutron_IPs> fixedIPIterator;
-            Neutron_IPs ip;
+        if (ipAddr == null)
+            return null;
 
-            List<NeutronPort> allPorts = neutronPortsCache.getAllPorts();
-         Iterator<NeutronPort> i = allPorts.iterator();
-         while (i.hasNext()) {
-             NeutronPort port = i.next();
-             fixedIPs = port.getFixedIPs();
-             if (fixedIPs != null && fixedIPs.size() > 0) {
-                 fixedIPIterator = fixedIPs.iterator();
-                 while (fixedIPIterator.hasNext()) {
-                     ip = fixedIPIterator.next();
-                     if (ip.getIpAddress().equals(ipAddr))
-                         return port.getMacAddress();
-                 }
-             }
-         }
+        List<Neutron_IPs> fixedIPs;
+        Iterator<Neutron_IPs> fixedIPIterator;
+        Neutron_IPs ip;
+
+        List<NeutronPort> allPorts = neutronPortsCache.getAllPorts();
+        Iterator<NeutronPort> i = allPorts.iterator();
+        while (i.hasNext()) {
+            NeutronPort port = i.next();
+            fixedIPs = port.getFixedIPs();
+            if (fixedIPs != null && fixedIPs.size() > 0) {
+                fixedIPIterator = fixedIPs.iterator();
+                while (fixedIPIterator.hasNext()) {
+                    ip = fixedIPIterator.next();
+                    if (ip.getIpAddress().equals(ipAddr))
+                        return port.getMacAddress();
+                }
+            }
+        }
         return null;
     }
 }