Skip to content
Snippets Groups Projects
Commit f63f3a26 authored by Volkan Yazıcı's avatar Volkan Yazıcı
Browse files

Add 'host' parameter to JythonServer and JythonDebugInterface.

parent d9b12036
No related branches found
No related tags found
No related merge requests found
......@@ -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();
}
}
......@@ -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())");
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment