Don't use hostIP for controller-ip 60/72860/3
authorVishal Thapar <vthapar@redhat.com>
Tue, 12 Jun 2018 06:08:44 +0000 (11:38 +0530)
committerSam Hague <shague@redhat.com>
Thu, 21 Jun 2018 12:06:05 +0000 (12:06 +0000)
If unable to get controller IP from manager entries of
OvsdbNode, don't assume hostIp to be controller IP.

JIRA: OVSDB-463
Change-Id: Ibfb34eb9d8b95fd676d9a5c6be458da02d5485d8
Signed-off-by: Vishal Thapar <vthapar@redhat.com>
utils/southbound-utils/src/main/java/org/opendaylight/ovsdb/utils/southbound/utils/SouthboundUtils.java

index 1811a24564c4f53cb278b9149cd129393ad9fceb..bd8cf7cde166510add39f476437c61df17374527 100644 (file)
@@ -13,13 +13,10 @@ import java.math.BigInteger;
 import java.net.Inet4Address;
 import java.net.Inet6Address;
 import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.SocketException;
 import java.net.UnknownHostException;
 import java.security.InvalidParameterException;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -912,16 +909,6 @@ public class SouthboundUtils {
             }
         }
 
-        if (controllersStr.isEmpty()) {
-            // Neither user provided ip nor ovsdb node has manager entries. Lets use local machine ip address.
-            LOG.debug("Use local machine ip address as a OpenFlow Controller ip address");
-            controllerIpStr = getLocalControllerHostIpAddress();
-            if (controllerIpStr != null) {
-                controllersStr.add(OPENFLOW_CONNECTION_PROTOCOL
-                        + ":" + controllerIpStr + ":" + OPENFLOW_PORT);
-            }
-        }
-
         if (controllersStr.isEmpty()) {
             LOG.warn("Failed to determine OpenFlow controller ip address");
         } else if (LOG.isDebugEnabled()) {
@@ -932,27 +919,6 @@ public class SouthboundUtils {
         return controllersStr;
     }
 
-    private String getLocalControllerHostIpAddress() {
-        String ipaddress = null;
-        try {
-            for (Enumeration<NetworkInterface> ifaces = NetworkInterface.getNetworkInterfaces();
-                    ifaces.hasMoreElements();) {
-                NetworkInterface iface = ifaces.nextElement();
-
-                for (Enumeration<InetAddress> inetAddrs = iface.getInetAddresses(); inetAddrs.hasMoreElements();) {
-                    InetAddress inetAddr = inetAddrs.nextElement();
-                    if (!inetAddr.isLoopbackAddress() && inetAddr.isSiteLocalAddress()) {
-                        ipaddress = inetAddr.getHostAddress();
-                        break;
-                    }
-                }
-            }
-        } catch (SocketException e) {
-            LOG.warn("Exception while fetching local host ip address ", e);
-        }
-        return ipaddress;
-    }
-
     public long getDataPathId(Node node) {
         long dpid = 0L;
         String datapathId = getDatapathId(node);