diff --git a/src/main/java/net/floodlightcontroller/jython/JythonDebugInterface.java b/src/main/java/net/floodlightcontroller/jython/JythonDebugInterface.java index 6f44b3d060a510afab7fc116f93f99e3c17c1893..49f1692d6bf5406643b64b9db3b9574baecf7f1c 100644 --- a/src/main/java/net/floodlightcontroller/jython/JythonDebugInterface.java +++ b/src/main/java/net/floodlightcontroller/jython/JythonDebugInterface.java @@ -23,6 +23,7 @@ import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import net.floodlightcontroller.core.FloodlightProvider; import net.floodlightcontroller.core.module.FloodlightModuleContext; import net.floodlightcontroller.core.module.FloodlightModuleException; import net.floodlightcontroller.core.module.IFloodlightModule; @@ -31,6 +32,7 @@ import net.floodlightcontroller.core.module.IFloodlightService; public class JythonDebugInterface implements IFloodlightModule { protected static Logger log = LoggerFactory.getLogger(JythonDebugInterface.class); protected JythonServer debug_server; + protected String jythonHost = null; protected int jythonPort = 6655; @Override @@ -72,13 +74,22 @@ public class JythonDebugInterface implements IFloodlightModule { // read our config options Map<String, String> configOptions = context.getConfigParams(this); + jythonHost = configOptions.get("host"); + if (jythonHost == null) { + Map<String, String> providerConfigOptions = context.getConfigParams( + FloodlightProvider.class); + jythonHost = providerConfigOptions.get("openflowhost"); + } + if (jythonHost != null) { + log.debug("Jython host set to {}", jythonHost); + } String port = configOptions.get("port"); if (port != null) { jythonPort = Integer.parseInt(port); } log.debug("Jython port set to {}", jythonPort); - JythonServer debug_server = new JythonServer(port, locals); + JythonServer debug_server = new JythonServer(jythonHost, jythonPort, locals); debug_server.start(); } } diff --git a/src/main/java/net/floodlightcontroller/jython/JythonServer.java b/src/main/java/net/floodlightcontroller/jython/JythonServer.java index 98ee956b3fd722b4611e09042567884e974250eb..2eb28e817c44de4e0d7a15b07375252e002c8c03 100644 --- a/src/main/java/net/floodlightcontroller/jython/JythonServer.java +++ b/src/main/java/net/floodlightcontroller/jython/JythonServer.java @@ -34,15 +34,18 @@ import org.slf4j.LoggerFactory; public class JythonServer extends Thread { protected static Logger log = LoggerFactory.getLogger(JythonServer.class); + String host; int port; Map<String, Object> locals; /** + * @param host_ Host to use for jython server * @param port_ Port to use for jython server * @param locals_ Locals to add to the interpreters top level name space */ - public JythonServer(int port_, Map<String, Object> locals_) { - this.port = port_ ; + public JythonServer(String host_, int port_, Map<String, Object> locals_) { + this.host = host_; + this.port = port_; this.locals = locals_; if (this.locals == null) { this.locals = new HashMap<String, Object>(); @@ -73,7 +76,10 @@ public class JythonServer extends Thread { p.exec("import sys"); p.exec("sys.path.append('" + jarPath + "')"); p.exec("from debugserver import run_server"); - p.exec("run_server(" + this.port + ", '0.0.0.0', locals())"); + if (this.host == null) { + p.exec("run_server(port=" + this.port + ", locals=locals())"); + } else { + p.exec("run_server(port=" + this.port + ", host='" + this.host + "', locals=locals())"); + } } - }