From 71550bc5db3a338558fdab5f027ac2fbd35f4c29 Mon Sep 17 00:00:00 2001 From: Anil Vishnoi Date: Thu, 7 May 2015 04:30:24 +0530 Subject: [PATCH] Quick and Dirty fix for bridge controller ip address Rather the using the hardcoded value, using the local host ip address. This is dirty fix, we should remove it once we get the valid fix using the connectionInfo local ip address. I think local ip address issues is now fixed for conncetion-info, so we can probably use that. We need to merge the master to netvirtsb branch, that will bring that fix. With this fix, netvirt create br-int and install all the pipeline flow successfully. Change-Id: If9d4e1289e0bb8c2a2888801f3c219f01f9a962d Signed-off-by: Anil Vishnoi --- .../impl/BridgeConfigurationManagerImpl.java | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/BridgeConfigurationManagerImpl.java b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/BridgeConfigurationManagerImpl.java index b922cdb84..738fbaa63 100644 --- a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/BridgeConfigurationManagerImpl.java +++ b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/BridgeConfigurationManagerImpl.java @@ -10,7 +10,9 @@ package org.opendaylight.ovsdb.openstack.netvirt.impl; import java.net.InetAddress; +import java.net.NetworkInterface; import java.net.UnknownHostException; + import org.opendaylight.neutron.spi.NeutronNetwork; import org.opendaylight.ovsdb.lib.notation.Row; import org.opendaylight.ovsdb.lib.notation.UUID; @@ -27,10 +29,12 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology. import com.google.common.base.Preconditions; import com.google.common.collect.Lists; import com.google.common.collect.Maps; + import org.apache.commons.lang3.tuple.ImmutablePair; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Enumeration; import java.util.List; import java.util.Map; import java.util.Set; @@ -409,7 +413,25 @@ public class BridgeConfigurationManagerImpl implements BridgeConfigurationManage * hardcoding value, need to find better way to get local ip */ //String target = "tcp:" + getControllerIPAddress() + ":" + getControllerOFPort(); - String target = "tcp:192.168.120.1:6633"; - return target; + //TODO: dirty fix, need to remove it once we have proper solution + String ipaddress = null; + try{ + for (Enumeration ifaces = NetworkInterface.getNetworkInterfaces();ifaces.hasMoreElements();){ + NetworkInterface iface = (NetworkInterface) ifaces.nextElement(); + + for (Enumeration inetAddrs = iface.getInetAddresses(); inetAddrs.hasMoreElements();) { + InetAddress inetAddr = (InetAddress) inetAddrs.nextElement(); + if (!inetAddr.isLoopbackAddress()) { + if (inetAddr.isSiteLocalAddress()) { + ipaddress = inetAddr.getHostAddress(); + break; + } + } + } + } + }catch (Exception e){ + LOGGER.warn("ROYALLY SCREWED : Exception while fetching local host ip address ",e); + } + return "tcp:"+ipaddress+":6633"; } } -- 2.36.6