Skip to content
Snippets Groups Projects
Commit ec6fc333 authored by hwchiu's avatar hwchiu
Browse files

Try to fix the WEBUI

1.	Serialize the return value of /wm/core/controller/switches/json
2.	Serialize the OFDescStatReply
3.  Serialize THE OFAggregateStatREply
4.  Modify the webui to make it fit the current restapi format
parent 2ccdc1bf
No related branches found
No related tags found
No related merge requests found
......@@ -18,25 +18,59 @@
package net.floodlightcontroller.core.web;
import java.util.Set;
import java.util.HashSet;
import net.floodlightcontroller.core.internal.IOFSwitchService;
import net.floodlightcontroller.core.IOFSwitch;
import org.projectfloodlight.openflow.types.DatapathId;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;
import net.floodlightcontroller.core.web.serializers.DPIDSerializer;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
/**
* Get a list of switches connected to the controller
* @author readams
*/
public class ControllerSwitchesResource extends ServerResource {
public static final String DPID_ERROR = "Invalid switch DPID string. Must be a 64-bit value in the form 00:11:22:33:44:55:66:77.";
public static final String DPID_ERROR = "Invalid switch DPID string. Must be a 64-bit value in the form 00:11:22:33:44:55:66:77.";
public static class DatapathIDJsonSerializerWrapper {
private final DatapathId dpid;
private final String inetAddress;
private final long connectedSince;
public DatapathIDJsonSerializerWrapper(DatapathId dpid, String inetAddress, long connectedSince) {
this.dpid = dpid;
this.inetAddress = inetAddress;
this.connectedSince = connectedSince;
}
@JsonSerialize(using=DPIDSerializer.class)
public DatapathId getSwitchDPID() {
return dpid;
}
public String getInetAddress() {
return inetAddress;
}
public long getConnectedSince() {
return connectedSince;
}
}
@Get("json")
public Set<DatapathId> retrieve(){
public Set<DatapathIDJsonSerializerWrapper> retrieve(){
IOFSwitchService switchService =
(IOFSwitchService) getContext().getAttributes().
get(IOFSwitchService.class.getCanonicalName());
return switchService.getAllSwitchDpids();
Set<DatapathIDJsonSerializerWrapper> dpidSets = new HashSet<DatapathIDJsonSerializerWrapper>();
for(IOFSwitch sw: switchService.getAllSwitchMap().values()) {
dpidSets.add(new DatapathIDJsonSerializerWrapper(sw.getId(), sw.getInetAddress().toString(), sw.getConnectedSince().getTime()));
}
return dpidSets;
}
}
......@@ -38,8 +38,8 @@ window.Switch = Backbone.Model.extend({
dataType:"json",
success:function (data) {
//console.log("fetched switch " + self.id + " desc");
//console.log(data[self.id][0]);
self.set(data[self.id][0]);
//console.log(data['desc']);
self.set(data['desc']);
}
});
......@@ -49,8 +49,8 @@ window.Switch = Backbone.Model.extend({
dataType:"json",
success:function (data) {
//console.log("fetched switch " + self.id + " aggregate");
//console.log(data[self.id][0]);
self.set(data[self.id][0]);
//console.log(data['aggregate']);
self.set(data['aggregate']);
}
});
self.trigger('add');
......@@ -278,8 +278,8 @@ window.SwitchCollection = Backbone.Collection.extend({
//console.log("old_ids" + old_ids);
_.each(data, function(sw) {
old_ids = _.without(old_ids, sw['dpid']);
self.add({id: sw['dpid'], inetAddress: sw.inetAddress,
old_ids = _.without(old_ids, sw['switchDPID']);
self.add({id: sw['switchDPID'], inetAddress: sw.inetAddress,
connectedSince: new Date(sw.connectedSince).toLocaleString()})});
// old_ids now holds switches that no longer exist; remove them
......
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