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 ...@@ -87,6 +87,10 @@ public class RestApiServer
// Add everything in the module context to the rest // Add everything in the module context to the rest
for (Class<? extends IFloodlightService> s : fmlContext.getAllServices()) { 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(), context.getAttributes().put(s.getCanonicalName(),
fmlContext.getServiceImpl(s)); fmlContext.getServiceImpl(s));
} }
......
...@@ -91,10 +91,12 @@ public class TopologyManager implements ...@@ -91,10 +91,12 @@ public class TopologyManager implements
protected BlockingQueue<LDUpdate> ldUpdates; protected BlockingQueue<LDUpdate> ldUpdates;
protected Set<LDUpdate> appliedUpdates; protected Set<LDUpdate> appliedUpdates;
// These must be accessed using getCurrentInstance(), not directly
protected TopologyInstance currentInstance; protected TopologyInstance currentInstance;
protected TopologyInstance currentInstanceWithoutTunnels; protected TopologyInstance currentInstanceWithoutTunnels;
protected SingletonTask newInstanceTask; protected SingletonTask newInstanceTask;
private Date lastUpdateTime; private Date lastUpdateTime;
/** /**
...@@ -425,11 +427,11 @@ public class TopologyManager implements ...@@ -425,11 +427,11 @@ public class TopologyManager implements
// As we might have two topologies, simply get the union of // As we might have two topologies, simply get the union of
// both of them and send it. // both of them and send it.
bp = currentInstance.getBlockedPorts(); bp = getCurrentInstance(true).getBlockedPorts();
if (bp != null) if (bp != null)
blockedPorts.addAll(bp); blockedPorts.addAll(bp);
bp = currentInstanceWithoutTunnels.getBlockedPorts(); bp = getCurrentInstance(false).getBlockedPorts();
if (bp != null) if (bp != null)
blockedPorts.addAll(bp); blockedPorts.addAll(bp);
...@@ -569,7 +571,6 @@ public class TopologyManager implements ...@@ -569,7 +571,6 @@ public class TopologyManager implements
m.put(ITopologyService.class, this); m.put(ITopologyService.class, this);
m.put(IRoutingService.class, this); m.put(IRoutingService.class, this);
return m; return m;
} }
@Override @Override
...@@ -610,10 +611,14 @@ public class TopologyManager implements ...@@ -610,10 +611,14 @@ public class TopologyManager implements
ScheduledExecutorService ses = threadPool.getScheduledExecutor(); ScheduledExecutorService ses = threadPool.getScheduledExecutor();
newInstanceTask = new SingletonTask(ses, new NewInstanceWorker()); newInstanceTask = new SingletonTask(ses, new NewInstanceWorker());
linkDiscovery.addListener(this); linkDiscovery.addListener(this);
restApi.addRestletRoutable(new TopologyWebRoutable());
newInstanceTask.reschedule(1, TimeUnit.MILLISECONDS); newInstanceTask.reschedule(1, TimeUnit.MILLISECONDS);
floodlightProvider.addOFMessageListener(OFType.PACKET_IN, this); floodlightProvider.addOFMessageListener(OFType.PACKET_IN, this);
floodlightProvider.addHAListener(this); floodlightProvider.addHAListener(this);
addRestletRoutable();
}
protected void addRestletRoutable() {
restApi.addRestletRoutable(new TopologyWebRoutable());
} }
// **************** // ****************
...@@ -728,7 +733,7 @@ public class TopologyManager implements ...@@ -728,7 +733,7 @@ public class TopologyManager implements
protected void doFloodBDDP(long pinSwitch, OFPacketIn pi, protected void doFloodBDDP(long pinSwitch, OFPacketIn pi,
FloodlightContext cntx) { FloodlightContext cntx) {
TopologyInstance ti = this.currentInstanceWithoutTunnels; TopologyInstance ti = getCurrentInstance(false);
Set<Long> switches = ti.getSwitchesInOpenflowDomain(pinSwitch); 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 { ...@@ -17,6 +17,7 @@ public class TopologyWebRoutable implements RestletRoutable {
router.attach("/tunnellinks/json", TunnelLinksResource.class); router.attach("/tunnellinks/json", TunnelLinksResource.class);
router.attach("/switchclusters/json", SwitchClustersResource.class); router.attach("/switchclusters/json", SwitchClustersResource.class);
router.attach("/broadcastdomainports/json", BroadcastDomainResource.class); router.attach("/broadcastdomainports/json", BroadcastDomainResource.class);
router.attach("/blockedports/json", BlockedPortsResource.class);
return router; 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