Skip to content
Snippets Groups Projects
Commit 4afee94e authored by Srinivasan Ramasubramanian's avatar Srinivasan Ramasubramanian
Browse files

REST API for getting the list of ports that are enabled for incoming traffic.

parent b3e10e71
No related branches found
No related tags found
No related merge requests found
package net.floodlightcontroller.topology.web;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import net.floodlightcontroller.core.IFloodlightProviderService;
import net.floodlightcontroller.topology.ITopologyService;
import net.floodlightcontroller.topology.NodePortTuple;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;
public class EnabledPortsResource extends ServerResource {
@Get("json")
public List<NodePortTuple> retrieve() {
List<NodePortTuple> result = new ArrayList<NodePortTuple>();
IFloodlightProviderService floodlightProvider =
(IFloodlightProviderService)getContext().getAttributes().
get(IFloodlightProviderService.class.getCanonicalName());
ITopologyService topology=
(ITopologyService)getContext().getAttributes().
get(ITopologyService.class.getCanonicalName());
if (floodlightProvider == null || topology == null)
return result;
Set<Long> switches = floodlightProvider.getSwitches().keySet();
if (switches == null) return result;
for(long sw: switches) {
Set<Short> ports = topology.getPorts(sw);
if (ports == null) continue;
for(short p: ports) {
result.add(new NodePortTuple(sw, p));
}
}
return result;
}
}
......@@ -17,6 +17,7 @@ public class TopologyWebRoutable implements RestletRoutable {
router.attach("/tunnellinks/json", TunnelLinksResource.class);
router.attach("/switchclusters/json", SwitchClustersResource.class);
router.attach("/broadcastdomainports/json", BroadcastDomainPortsResource.class);
router.attach("/enabledports/json", EnabledPortsResource.class);
router.attach("/blockedports/json", BlockedPortsResource.class);
router.attach("/route/{src-dpid}/{src-port}/{dst-dpid}/{dst-port}/json", RouteResource.class);
return router;
......
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