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

Changes to REST API for links. ...

Changes to REST API for links.  http://<controller>:8080/wm/topology/links/json would now return only direct and tunnel links (LinkType.DIRECT_LINK or LinkType.TUNNEL).  To get external links, use http://<controller>:8080/wm/topology/external-links/json.
parent 256a5723
No related branches found
No related tags found
No related merge requests found
package net.floodlightcontroller.linkdiscovery.web;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import net.floodlightcontroller.linkdiscovery.ILinkDiscovery.LinkType;
import net.floodlightcontroller.linkdiscovery.ILinkDiscoveryService;
import net.floodlightcontroller.linkdiscovery.LinkInfo;
import net.floodlightcontroller.routing.Link;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;
public class ExternalLinksResource extends ServerResource {
@Get("json")
public Set<LinkWithType> retrieve() {
ILinkDiscoveryService ld = (ILinkDiscoveryService)getContext().getAttributes().
get(ILinkDiscoveryService.class.getCanonicalName());
Map<Link, LinkInfo> links = new HashMap<Link, LinkInfo>();
Set<LinkWithType> returnLinkSet = new HashSet<LinkWithType>();
if (ld != null) {
links.putAll(ld.getLinks());
for (Link link: links.keySet()) {
LinkInfo info = links.get(link);
LinkType type = ld.getLinkType(link, info);
if (type == LinkType.MULTIHOP_LINK) {
LinkWithType lwt = new LinkWithType(link,
info.getSrcPortState(),
info.getDstPortState(),
type);
returnLinkSet.add(lwt);
}
}
}
return returnLinkSet;
}
}
......@@ -5,6 +5,7 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import net.floodlightcontroller.linkdiscovery.ILinkDiscovery.LinkType;
import net.floodlightcontroller.linkdiscovery.ILinkDiscoveryService;
import net.floodlightcontroller.linkdiscovery.LinkInfo;
import net.floodlightcontroller.routing.Link;
......@@ -25,11 +26,14 @@ public class LinksResource extends ServerResource {
links.putAll(ld.getLinks());
for (Link link: links.keySet()) {
LinkInfo info = links.get(link);
LinkType type = ld.getLinkType(link, info);
LinkWithType lwt = new LinkWithType(link,
info.getSrcPortState(),
info.getDstPortState(),
ld.getLinkType(link, info));
returnLinkSet.add(lwt);
type);
if (type == LinkType.DIRECT_LINK || type == LinkType.TUNNEL)
returnLinkSet.add(lwt);
}
}
return returnLinkSet;
......
......@@ -3,6 +3,7 @@ package net.floodlightcontroller.topology.web;
import org.restlet.Context;
import org.restlet.routing.Router;
import net.floodlightcontroller.linkdiscovery.web.ExternalLinksResource;
import net.floodlightcontroller.linkdiscovery.web.LinksResource;
import net.floodlightcontroller.restserver.RestletRoutable;
......@@ -14,6 +15,7 @@ public class TopologyWebRoutable implements RestletRoutable {
public Router getRestlet(Context context) {
Router router = new Router(context);
router.attach("/links/json", LinksResource.class);
router.attach("/external-links/json", ExternalLinksResource.class);
router.attach("/tunnellinks/json", TunnelLinksResource.class);
router.attach("/switchclusters/json", SwitchClustersResource.class);
router.attach("/broadcastdomainports/json", BroadcastDomainPortsResource.class);
......
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