Controller IP-Address filtered using the "of.address" controller configuration from... 79/2579/1
authorMadhu Venugopal <mavenugo@gmail.com>
Sun, 10 Nov 2013 11:59:03 +0000 (03:59 -0800)
committerMadhu Venugopal <mavenugo@gmail.com>
Sun, 10 Nov 2013 11:59:03 +0000 (03:59 -0800)
As per the current implementation, when a new bridge is added, the Configuration Service automatically sets up the OF Controller field
of the bridge to point back at the OpenDaylight Openflow plugin. This is done by scanning all the open interfaces with valid IP-Addresses
and sets it in the Bridge table's controller column.
This can be better handled by filtering it further by using just the Admin prefered ip-address of the controller.
This configuration item is called "of.address" in configuration/config.ini.

Change-Id: Icdfeb0dfc4e68e61e926f09b49461fe0c1dd3060
Signed-off-by: Madhu Venugopal <mavenugo@gmail.com>
ovsdb/src/main/java/org/opendaylight/ovsdb/plugin/ConfigurationService.java

index 34da1cc3ff140627fdefcca3b2451756975f5c39..72b4b125e87b7e2c7e96c9626328da885ace3a62 100755 (executable)
@@ -4,10 +4,26 @@ import java.math.BigInteger;
 import java.net.InetAddress;
 import java.net.NetworkInterface;
 import java.net.SocketException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
 
 import org.eclipse.osgi.framework.console.CommandInterpreter;
 import org.eclipse.osgi.framework.console.CommandProvider;
+import org.opendaylight.controller.clustering.services.IClusterGlobalServices;
+import org.opendaylight.controller.sal.connection.ConnectionConstants;
+import org.opendaylight.controller.sal.core.Node;
+import org.opendaylight.controller.sal.core.NodeConnector;
+import org.opendaylight.controller.sal.networkconfig.bridgedomain.ConfigConstants;
+import org.opendaylight.controller.sal.networkconfig.bridgedomain.IPluginInBridgeDomainConfigService;
+import org.opendaylight.controller.sal.utils.NetUtils;
+import org.opendaylight.controller.sal.utils.Status;
+import org.opendaylight.controller.sal.utils.StatusCode;
 import org.opendaylight.ovsdb.lib.database.OVSInstance;
 import org.opendaylight.ovsdb.lib.database.OvsdbType;
 import org.opendaylight.ovsdb.lib.message.TransactBuilder;
@@ -28,15 +44,6 @@ import org.opendaylight.ovsdb.lib.table.Interface;
 import org.opendaylight.ovsdb.lib.table.Open_vSwitch;
 import org.opendaylight.ovsdb.lib.table.Port;
 import org.opendaylight.ovsdb.lib.table.internal.Table;
-import org.opendaylight.controller.clustering.services.IClusterGlobalServices;
-import org.opendaylight.controller.sal.connection.ConnectionConstants;
-import org.opendaylight.controller.sal.core.Node;
-import org.opendaylight.controller.sal.core.NodeConnector;
-import org.opendaylight.controller.sal.networkconfig.bridgedomain.ConfigConstants;
-import org.opendaylight.controller.sal.networkconfig.bridgedomain.IPluginInBridgeDomainConfigService;
-import org.opendaylight.controller.sal.utils.NetUtils;
-import org.opendaylight.controller.sal.utils.Status;
-import org.opendaylight.controller.sal.utils.StatusCode;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.FrameworkUtil;
 import org.slf4j.Logger;
@@ -687,7 +694,20 @@ public class ConfigurationService implements IPluginInBridgeDomainConfigService,
         }
 
         controllers = new ArrayList<InetAddress>();
-        InetAddress controllerIP;
+        String addressString = System.getProperty("of.address");
+        if (addressString != null) {
+            InetAddress controllerIP = null;
+            try {
+                controllerIP = InetAddress.getByName(addressString);
+                if (controllerIP != null) {
+                    controllers.add(controllerIP);
+                    return controllers;
+                }
+            } catch (Exception e) {
+                logger.debug("Invalid IP: {}, use wildcard *", addressString);
+            }
+        }
+
         Enumeration<NetworkInterface> nets;
         try {
             nets = NetworkInterface.getNetworkInterfaces();