added groupAction in group stats and some other incomplete stuff
diff --git a/src/main/java/net/floodlightcontroller/core/web/serializers/OFGroupDescStatsEntryModSerializer.java b/src/main/java/net/floodlightcontroller/core/web/serializers/OFGroupDescStatsEntryModSerializer.java
index d4f214a..dadf82f 100644
--- a/src/main/java/net/floodlightcontroller/core/web/serializers/OFGroupDescStatsEntryModSerializer.java
+++ b/src/main/java/net/floodlightcontroller/core/web/serializers/OFGroupDescStatsEntryModSerializer.java
@@ -59,7 +59,9 @@
else if(action.getType().compareTo(OFActionType.POP_MPLS) == 0){
jGen.writeStringField("POP_MPLS", "True");
}
-
+ else if(action.getType().compareTo(OFActionType.GROUP) == 0){
+ jGen.writeNumberField("goToGroup", ((OFActionGroup)action).getGroup().getGroupNumber());
+ }
}
jGen.writeEndObject();
}
diff --git a/src/main/java/net/onrc/onos/apps/segmentrouting/web/RouterStatisticsResource.java b/src/main/java/net/onrc/onos/apps/segmentrouting/web/RouterStatisticsResource.java
index 8e79639..944bf1c 100644
--- a/src/main/java/net/onrc/onos/apps/segmentrouting/web/RouterStatisticsResource.java
+++ b/src/main/java/net/onrc/onos/apps/segmentrouting/web/RouterStatisticsResource.java
@@ -1,15 +1,23 @@
package net.onrc.onos.apps.segmentrouting.web;
-import java.util.HashMap;
-import net.floodlightcontroller.core.web.ControllerSwitchesResource;
+import java.util.List;
+import java.util.concurrent.Future;
+
+import net.floodlightcontroller.core.IFloodlightProviderService;
+import net.floodlightcontroller.core.IOFSwitch;
import net.onrc.onos.core.topology.ITopologyService;
import net.onrc.onos.core.topology.MutableTopology;
+import net.onrc.onos.core.util.Dpid;
-import org.restlet.resource.ResourceException;
+import org.apache.commons.codec.binary.Hex;
+import org.projectfloodlight.openflow.util.HexString;
import org.restlet.resource.ServerResource;
import org.restlet.representation.Representation;
import org.restlet.resource.Get;
+
+import com.esotericsoftware.minlog.Log;
+
import static net.onrc.onos.core.topology.web.TopologyResource.eval;
/**
* Base class for return router statistics
@@ -17,25 +25,50 @@
*/
public class RouterStatisticsResource extends ServerResource {
/**
- * Gets the switches and ports information from the network topology.
+ * Gets the switches/routers and ports information from the network topology.
*
- * @return a Representation of a Collection of switches from the network
+ * @return a Representation of a Collection of switches/routers from the network
* topology. Each switch contains the switch ports.
*/
@Get("json")
public Representation retrieve() {
+ String routerId = (String) getRequestAttributes().get("routerId");
+ String statsType = (String) getRequestAttributes().get("statsType");
+ //if (routerId == null && statsType == null){
ITopologyService topologyService =
- (ITopologyService) getContext().getAttributes()
+ (ITopologyService) getContext().getAttributes()
.get(ITopologyService.class.getCanonicalName());
MutableTopology mutableTopology = topologyService.getTopology();
mutableTopology.acquireReadLock();
try {
- return eval(toRepresentation(mutableTopology.getSwitches(), null));
+ if (routerId == null && statsType == null){
+ return eval(toRepresentation(mutableTopology.getSwitches(), null));
+ }
+ else if(routerId != null && statsType == "port"){
+ Log.debug("\n\n\nGot router port stats request\n\n\n");
+ System.out.println("\n\n\nGot router port stats request\n\n\n");
+ Long rId = HexString.toLong(routerId);
+ return eval(toRepresentation(mutableTopology.getSwitch(new Dpid(rId)), null));
+ }
} finally {
mutableTopology.releaseReadLock();
}
+ // }
+ /*else if(routerId != null && statsType == "port"){
+ Long rId = HexString.toLong(routerId);
+ IFloodlightProviderService floodlightProvider =
+ (IFloodlightProviderService) getContext().getAttributes().
+ get(IFloodlightProviderService.class.getCanonicalName());
+ IOFSwitch sw = floodlightProvider.getSwitches().get(rId);
+ Future<List<OFStatsReply>> future;
+ List<OFStatsReply> values = null;
+
+ }*/
+ return null;
}
+
+
diff --git a/src/main/java/net/onrc/onos/apps/segmentrouting/web/SegmentRoutingWebRoutable.java b/src/main/java/net/onrc/onos/apps/segmentrouting/web/SegmentRoutingWebRoutable.java
index 3e121d6..668a1ca 100644
--- a/src/main/java/net/onrc/onos/apps/segmentrouting/web/SegmentRoutingWebRoutable.java
+++ b/src/main/java/net/onrc/onos/apps/segmentrouting/web/SegmentRoutingWebRoutable.java
@@ -16,7 +16,9 @@
@Override
public Restlet getRestlet(Context context) {
Router router = new Router(context);
- router.attach("/routers", SwitchesResource.class);
+ //TODO: rewrite SwitchesResource for router specific info.
+ router.attach("/routers", RouterStatisticsResource.class);
+ router.attach("/router/{routerId}/{statsType}", RouterStatisticsResource.class);
return router;
}