Skip to content
Snippets Groups Projects
Commit 3ec16fba authored by Gregor Maier's avatar Gregor Maier
Browse files

Merge remote-tracking branch 'floodlight/master'

parents 7df21a91 71d58a1a
No related branches found
No related tags found
No related merge requests found
......@@ -7,3 +7,4 @@
.DS_Store
target
thrift
logback.xml
#!/usr/bin/python
import sys
import argparse
import json
import httplib
import urllib2
class RestApi(object):
def __init__(self, server,port):
self.server = server
self.port = port
def get(self, path):
#ret = self.rest_call(path, {}, 'GET')
#return ret[2]
f = urllib2.urlopen('http://'+self.server+':'+str(self.port)+path)
ret = f.read()
return json.loads(ret)
def set(self, path, data):
ret = self.rest_call(path, data, 'POST')
return ret[0] == 200
def remove(self, objtype, data):
#ret = self.rest_call(data, 'DELETE')
return ret[0] == 200
def rest_call(self, path, data, action):
headers = {
'Content-type': 'application/json',
'Accept': 'application/json',
}
body = json.dumps(data)
conn = httplib.HTTPConnection(self.server, self.port)
conn.request(action, path, body, headers)
response = conn.getresponse()
ret = (response.status, response.reason, response.read())
conn.close()
print str(ret[2])
return ret
usage_desc = """
Command descriptions:
host <MAC>
link
memory
switch
switch_stats [port, queue, flow, aggregate, desc, table, features, host]
per_switch_stats [DPID] [port, queue, flow, aggregate, desc, table, features, host]
"""
def lookupPath(cmd):
path = ''
numargs = len(args.otherargs)
if args.cmd == 'switch_stats' and numargs == 1:
path = '/wm/core/switch/all/'+args.otherargs[0]+'/json'
elif args.cmd == 'per_switch_stats' and numargs == 2:
path = '/wm/core/switch/'+args.ortherargs[0]+'/'+args.otherargs[1]+'/json'
elif args.cmd == 'switch':
path = '/wm/core/controller/switches/json'
elif args.cmd == 'counter' and numargs == 1:
path = '/wm/core/counter/'+args.otherargs[0]+'/json'
elif args.cmd == 'switch_counter' and numargs == 2:
path = '/wm/core/counter/'+args.otherargs[0]+'/'+otherargs[1]+'/json'
elif args.cmd == 'memory':
path = '/wm/core/memory/json'
elif args.cmd == 'link':
path = '/wm/topology/links/json'
elif args.cmd == 'switchclusters':
path = '/wm/topology/switchclusters/json'
elif args.cmd == 'host':
if len(args.otherargs) == 0:
args.otherargs.append("all")
path = '/wm/devicemanager/device/'+args.otherargs[0]+'/json'
else:
print usage_desc
path = ''
exit(0)
return path
parser = argparse.ArgumentParser(description='process args', usage=usage_desc, epilog='foo bar help')
parser.add_argument('--ip', default='localhost')
parser.add_argument('--port', default=8080)
parser.add_argument('cmd')
parser.add_argument('otherargs', nargs='*')
args = parser.parse_args()
#print args
rest = RestApi(args.ip, args.port)
path = lookupPath(args.cmd)
out = rest.get(path)
print json.dumps(out,sort_keys=True, indent=4)
print "Number of items: " + str(len(out))
......@@ -26,10 +26,8 @@ JVM_OPTS="$JVM_OPTS -XX:CompileThreshold=1500 -XX:PreBlockSpin=8"
</root>
<logger name="org" level="WARN"/>
<logger name="LogService" level="WARN"/> <!-- Restlet access logging -->
<logger name="net.floodlightcontroller" level="ERROR"/>
<logger name="net.floodlightcontroller" level="INFO"/>
<logger name="net.floodlightcontroller.logging" level="ERROR"/>
<logger name="net.beaconcontroller" level="ERROR" />
<logger name="net.beaconcontroller.logging" level="ERROR" />
</configuration>
EOF_LOGBACK
......
......@@ -1690,7 +1690,7 @@ public class Controller implements IFloodlightProviderService {
if (threads != null) {
this.workerThreads = Integer.parseInt(threads);
}
log.info("Number of worker threads port set to {}", this.workerThreads);
log.info("Number of worker threads set to {}", this.workerThreads);
String controllerId = configParams.get("controllerid");
if (controllerId != null) {
this.controllerId = controllerId;
......
......@@ -14,7 +14,8 @@ import net.floodlightcontroller.core.module.IFloodlightService;
public class JythonDebugInterface implements IFloodlightModule {
protected static Logger log = LoggerFactory.getLogger(JythonDebugInterface.class);
JythonServer debug_server;
protected JythonServer debug_server;
protected static int JYTHON_PORT = 6655;
@Override
public Collection<Class<? extends IFloodlightService>> getModuleServices() {
......@@ -44,8 +45,7 @@ public class JythonDebugInterface implements IFloodlightModule {
@Override
public void startUp(FloodlightModuleContext context) {
Map<String, Object> locals = new HashMap<String, Object>();
Map<String, Object> locals = new HashMap<String, Object>();
// add all existing module references to the debug server
for (Class<? extends IFloodlightService> s : context.getAllServices()) {
// Put only the last part of the name
......@@ -54,7 +54,15 @@ public class JythonDebugInterface implements IFloodlightModule {
locals.put(name, context.getServiceImpl(s));
}
JythonServer debug_server = new JythonServer(6655, locals);
// read our config options
Map<String, String> configOptions = context.getConfigParams(this);
int port = JYTHON_PORT;
String portNum = configOptions.get("port");
if (portNum != null) {
port = Integer.parseInt(portNum);
}
JythonServer debug_server = new JythonServer(port, locals);
debug_server.start();
}
}
......@@ -7,3 +7,4 @@ net.floodlightcontroller.perfmon.PktInProcessingTime,\
net.floodlightcontroller.ui.web.StaticWebRoutable
net.floodlightcontroller.restserver.RestApiServer.port = 8080
net.floodlightcontroller.core.FloodlightProvider.openflowport = 6633
net.floodlightcontroller.jython.JythonDebugInterface.port = 6655
\ No newline at end of file
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