Skip to content
Snippets Groups Projects
Commit 6ea4281e authored by abat's avatar abat
Browse files

Merge into master from pull request #167:

Enhancements to Topology REST API. [#28640601] (https://github.com/floodlight/floodlight/pull/167)
parents c3ec93a0 2931b14b
No related branches found
No related tags found
No related merge requests found
......@@ -87,6 +87,10 @@ public class RestApiServer
// Add everything in the module context to the rest
for (Class<? extends IFloodlightService> s : fmlContext.getAllServices()) {
if (logger.isDebugEnabled()) {
logger.debug("Adding {} for service {} into context",
s.getCanonicalName(), fmlContext.getServiceImpl(s));
}
context.getAttributes().put(s.getCanonicalName(),
fmlContext.getServiceImpl(s));
}
......
......@@ -91,10 +91,12 @@ public class TopologyManager implements
protected BlockingQueue<LDUpdate> ldUpdates;
protected Set<LDUpdate> appliedUpdates;
// These must be accessed using getCurrentInstance(), not directly
protected TopologyInstance currentInstance;
protected TopologyInstance currentInstanceWithoutTunnels;
protected SingletonTask newInstanceTask;
private Date lastUpdateTime;
/**
......@@ -425,11 +427,11 @@ public class TopologyManager implements
// As we might have two topologies, simply get the union of
// both of them and send it.
bp = currentInstance.getBlockedPorts();
bp = getCurrentInstance(true).getBlockedPorts();
if (bp != null)
blockedPorts.addAll(bp);
bp = currentInstanceWithoutTunnels.getBlockedPorts();
bp = getCurrentInstance(false).getBlockedPorts();
if (bp != null)
blockedPorts.addAll(bp);
......@@ -569,7 +571,6 @@ public class TopologyManager implements
m.put(ITopologyService.class, this);
m.put(IRoutingService.class, this);
return m;
}
@Override
......@@ -610,10 +611,14 @@ public class TopologyManager implements
ScheduledExecutorService ses = threadPool.getScheduledExecutor();
newInstanceTask = new SingletonTask(ses, new NewInstanceWorker());
linkDiscovery.addListener(this);
restApi.addRestletRoutable(new TopologyWebRoutable());
newInstanceTask.reschedule(1, TimeUnit.MILLISECONDS);
floodlightProvider.addOFMessageListener(OFType.PACKET_IN, this);
floodlightProvider.addHAListener(this);
addRestletRoutable();
}
protected void addRestletRoutable() {
restApi.addRestletRoutable(new TopologyWebRoutable());
}
// ****************
......@@ -728,7 +733,7 @@ public class TopologyManager implements
protected void doFloodBDDP(long pinSwitch, OFPacketIn pi,
FloodlightContext cntx) {
TopologyInstance ti = this.currentInstanceWithoutTunnels;
TopologyInstance ti = getCurrentInstance(false);
Set<Long> switches = ti.getSwitchesInOpenflowDomain(pinSwitch);
......
package net.floodlightcontroller.topology.web;
import java.util.Set;
import net.floodlightcontroller.topology.ITopologyService;
import net.floodlightcontroller.topology.NodePortTuple;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;
public class BlockedPortsResource extends ServerResource {
@Get("json")
public Set<NodePortTuple> retrieve() {
ITopologyService topology =
(ITopologyService)getContext().getAttributes().
get(ITopologyService.class.getCanonicalName());
return topology.getBlockedPorts();
}
}
......@@ -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", BroadcastDomainResource.class);
router.attach("/blockedports/json", BlockedPortsResource.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