Built REST APIs to look into Ramcloud for debugging
Change-Id: Id979797a2ddc7a86535c20cacd307e452e63f0de
diff --git a/src/main/java/net/onrc/onos/ofcontroller/floodlightlistener/RCNetworkGraphPublisher.java b/src/main/java/net/onrc/onos/ofcontroller/floodlightlistener/RCNetworkGraphPublisher.java
index 0067e27..5bc5b7c 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/floodlightlistener/RCNetworkGraphPublisher.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/floodlightlistener/RCNetworkGraphPublisher.java
@@ -41,8 +41,8 @@
IOFSwitchPortListener,
ILinkDiscoveryListener,
IFloodlightModule {
- private final static Logger log = LoggerFactory.getLogger(RCNetworkGraphPublisher.class);
-
+ private static final Logger log = LoggerFactory.getLogger(RCNetworkGraphPublisher.class);
+
private IFloodlightProviderService floodlightProvider;
private ILinkDiscoveryService linkDiscovery;
private IControllerRegistryService registryService;
diff --git a/src/main/java/net/onrc/onos/ofcontroller/networkgraph/NetworkGraphModule.java b/src/main/java/net/onrc/onos/ofcontroller/networkgraph/NetworkGraphModule.java
index 490f30f..09c1c66 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/networkgraph/NetworkGraphModule.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/networkgraph/NetworkGraphModule.java
@@ -10,6 +10,8 @@
import net.floodlightcontroller.core.module.FloodlightModuleException;
import net.floodlightcontroller.core.module.IFloodlightModule;
import net.floodlightcontroller.core.module.IFloodlightService;
+import net.floodlightcontroller.restserver.IRestApiService;
+import net.onrc.onos.ofcontroller.networkgraph.web.NetworkGraphWebRoutable;
public class NetworkGraphModule implements IFloodlightModule, INetworkGraphService {
@@ -19,6 +21,7 @@
private NetworkGraphImpl networkGraph;
private SouthboundNetworkGraph southboundNetworkGraph;
+ private IRestApiService restApi;
@Override
public Collection<Class<? extends IFloodlightService>> getModuleServices() {
@@ -39,20 +42,24 @@
@Override
public Collection<Class<? extends IFloodlightService>> getModuleDependencies() {
- return null;
+ List<Class<? extends IFloodlightService>> dependencies =
+ new ArrayList<Class<? extends IFloodlightService>>();
+ dependencies.add(IRestApiService.class);
+ return dependencies;
}
@Override
public void init(FloodlightModuleContext context)
throws FloodlightModuleException {
+ restApi = context.getServiceImpl(IRestApiService.class);
+
networkGraph = new NetworkGraphImpl();
southboundNetworkGraph = new SouthboundNetworkGraph(networkGraph);
}
@Override
public void startUp(FloodlightModuleContext context) {
- // TODO Auto-generated method stub
-
+ restApi.addRestletRoutable(new NetworkGraphWebRoutable());
}
@Override
diff --git a/src/main/java/net/onrc/onos/ofcontroller/networkgraph/web/NetworkGraphWebRoutable.java b/src/main/java/net/onrc/onos/ofcontroller/networkgraph/web/NetworkGraphWebRoutable.java
new file mode 100644
index 0000000..4dd82e6
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/networkgraph/web/NetworkGraphWebRoutable.java
@@ -0,0 +1,25 @@
+package net.onrc.onos.ofcontroller.networkgraph.web;
+
+import org.restlet.Context;
+import org.restlet.Restlet;
+import org.restlet.routing.Router;
+
+import net.floodlightcontroller.restserver.RestletRoutable;
+
+public class NetworkGraphWebRoutable implements RestletRoutable {
+
+ @Override
+ public Restlet getRestlet(Context context) {
+ Router router = new Router(context);
+ router.attach("/switches/json", RamcloudSwitchesResource.class);
+ router.attach("/links/json", RamcloudLinksResource.class);
+ return router;
+ }
+
+ @Override
+ public String basePath() {
+ // TODO Auto-generated method stub
+ return "/wm/onos/rc";
+ }
+
+}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/networkgraph/web/RamcloudLinksResource.java b/src/main/java/net/onrc/onos/ofcontroller/networkgraph/web/RamcloudLinksResource.java
new file mode 100644
index 0000000..abd1831
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/networkgraph/web/RamcloudLinksResource.java
@@ -0,0 +1,14 @@
+package net.onrc.onos.ofcontroller.networkgraph.web;
+
+import net.onrc.onos.datastore.topology.RCLink;
+
+import org.restlet.resource.Get;
+import org.restlet.resource.ServerResource;
+
+public class RamcloudLinksResource extends ServerResource {
+
+ @Get("json")
+ public Iterable<RCLink> retrieve() {
+ return RCLink.getAllLinks();
+ }
+}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/networkgraph/web/RamcloudSwitchesResource.java b/src/main/java/net/onrc/onos/ofcontroller/networkgraph/web/RamcloudSwitchesResource.java
new file mode 100644
index 0000000..98e1050
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/networkgraph/web/RamcloudSwitchesResource.java
@@ -0,0 +1,20 @@
+package net.onrc.onos.ofcontroller.networkgraph.web;
+
+import net.onrc.onos.datastore.topology.RCSwitch;
+import net.onrc.onos.ofcontroller.networkgraph.INetworkGraphService;
+
+import org.restlet.resource.Get;
+import org.restlet.resource.ServerResource;
+
+public class RamcloudSwitchesResource extends ServerResource {
+
+ @Get("json")
+ public Iterable<RCSwitch> retrieve() {
+ INetworkGraphService networkGraphService =
+ (INetworkGraphService) getContext().getAttributes().
+ get(INetworkGraphService.class.getCanonicalName());
+
+ return RCSwitch.getAllSwitches();
+ }
+
+}