diff --git a/example/cli.py b/example/cli.py index f50788fca2311fb79662694412134d619a1e6b62..ca8b443d5f5d254e3bb2cdba600b2306564334ed 100755 --- a/example/cli.py +++ b/example/cli.py @@ -46,45 +46,51 @@ class RestApi(object): usage_desc = """ Command descriptions: - host <MAC> - - link - + host [debug] + link [tunnellinks] + port <blocked | broadcast> memory - switch - - switch_stats [port, queue, flow, aggregate, desc, table, features, host] - - per_switch_stats [DPID] [port, queue, flow, aggregate, desc, table, features, host] - - """ + switchclusters + counter [DPID] <name> + switch_stats [DPID] <port | queue | flow | aggregate | desc | table | features | host> +""" def lookupPath(cmd): path = '' numargs = len(args.otherargs) - - if args.cmd == 'switch_stats' and numargs == 1: - path = '/wm/core/switch/all/'+args.otherargs[0]+'/json' - elif args.cmd == 'per_switch_stats' and numargs == 2: - path = '/wm/core/switch/'+args.ortherargs[0]+'/'+args.otherargs[1]+'/json' + + if args.cmd == 'switch_stats': + if numargs == 1: + path = '/wm/core/switch/all/'+args.otherargs[0]+'/json' + elif numargs == 2: + path = '/wm/core/switch/'+args.otherargs[0]+'/'+args.otherargs[1]+'/json' elif args.cmd == 'switch': path = '/wm/core/controller/switches/json' - elif args.cmd == 'counter' and numargs == 1: - path = '/wm/core/counter/'+args.otherargs[0]+'/json' - elif args.cmd == 'switch_counter' and numargs == 2: - path = '/wm/core/counter/'+args.otherargs[0]+'/'+otherargs[1]+'/json' + elif args.cmd == 'counter': + if numargs == 1: + path = '/wm/core/counter/'+args.otherargs[0]+'/json' + elif numargs == 2: + path = '/wm/core/counter/'+args.otherargs[0]+'/'+args.otherargs[1]+'/json' elif args.cmd == 'memory': path = '/wm/core/memory/json' elif args.cmd == 'link': - path = '/wm/topology/links/json' + if numargs == 0: + path = '/wm/topology/links/json' + elif numargs == 1: + path = '/wm/topology/'+args.otherargs[0]+'/json' + elif args.cmd == 'port' and numargs == 1: + if args.otherargs[0] == "blocked": + path = '/wm/topology/blockedports/json' + elif args.otherargs[0] == "broadcast": + path = '/wm/topology/broadcastdomainports/json' elif args.cmd == 'switchclusters': path = '/wm/topology/switchclusters/json' elif args.cmd == 'host': - if len(args.otherargs) == 0: - args.otherargs.append("all") - path = '/wm/devicemanager/device/'+args.otherargs[0]+'/json' + path = '/wm/device/' + if len(args.otherargs) == 1 and args.otherargs[0] == 'debug': + path = '/wm/device/debug' else: print usage_desc path = '' diff --git a/src/main/java/net/floodlightcontroller/linkdiscovery/ILinkDiscoveryService.java b/src/main/java/net/floodlightcontroller/linkdiscovery/ILinkDiscoveryService.java index e950bee8bd73b44175c7518c734b12c8a2da0bbc..f1142fd31c2b310e1789bf8125f2e9c776ce6289 100644 --- a/src/main/java/net/floodlightcontroller/linkdiscovery/ILinkDiscoveryService.java +++ b/src/main/java/net/floodlightcontroller/linkdiscovery/ILinkDiscoveryService.java @@ -44,7 +44,15 @@ public interface ILinkDiscoveryService extends IFloodlightService { * @return linkTuple */ public LinkInfo getLinkInfo(SwitchPortTuple idPort, boolean isSrcPort); - + + /** + * Get the link type of the link tuple based on link info. + * @param linkTuple + * @param linkInfo + * @return linkType + */ + public ILinkDiscovery.LinkType getLinkType(LinkTuple lt, LinkInfo info); + /** * Retrieves a map of all known link connections between OpenFlow switches * and the associated info (valid time, port states) for the link. diff --git a/src/main/java/net/floodlightcontroller/linkdiscovery/LinkInfo.java b/src/main/java/net/floodlightcontroller/linkdiscovery/LinkInfo.java index d77df91b81dfe76e3c27568eaba04b47fbea0099..7c8d7491c9f3a391d869b027ecb4c32e4b79f952 100644 --- a/src/main/java/net/floodlightcontroller/linkdiscovery/LinkInfo.java +++ b/src/main/java/net/floodlightcontroller/linkdiscovery/LinkInfo.java @@ -92,15 +92,6 @@ public class LinkInfo { public void setDstPortState(int dstPortState) { this.dstPortState = dstPortState; } - - public static ILinkDiscovery.LinkType getLinkType(LinkTuple lt, LinkInfo info) { - if (info.getUnicastValidTime() != null) { - return ILinkDiscovery.LinkType.DIRECT_LINK; - } else if (info.getMulticastValidTime() != null) { - return ILinkDiscovery.LinkType.MULTIHOP_LINK; - } - return ILinkDiscovery.LinkType.INVALID_LINK; - } /* (non-Javadoc) * @see java.lang.Object#hashCode() diff --git a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java index 537b0f288682ccd6dd0fc171c1b6c15eebd9b2df..37311e2f302ef069d82c7c8df74bc6b8bc885299 100644 --- a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java +++ b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkDiscoveryManager.java @@ -216,8 +216,13 @@ public class LinkDiscoveryManager return shuttingDown; } - protected ILinkDiscovery.LinkType getLinkType(LinkTuple lt, LinkInfo info) { - return LinkInfo.getLinkType(lt, info); + public ILinkDiscovery.LinkType getLinkType(LinkTuple lt, LinkInfo info) { + if (info.getUnicastValidTime() != null) { + return ILinkDiscovery.LinkType.DIRECT_LINK; + } else if (info.getMulticastValidTime() != null) { + return ILinkDiscovery.LinkType.MULTIHOP_LINK; + } + return ILinkDiscovery.LinkType.INVALID_LINK; } private void doUpdatesThread() throws InterruptedException { @@ -616,7 +621,7 @@ public class LinkDiscoveryManager lt.getSrc().getPort(), lt.getDst().getPort(), newLinkInfo.getSrcPortState(), newLinkInfo.getDstPortState(), - LinkInfo.getLinkType(lt, newLinkInfo), + getLinkType(lt, newLinkInfo), EvAction.LINK_ADDED, "LLDP Recvd"); } else { // Since the link info is already there, we need to @@ -672,14 +677,14 @@ public class LinkDiscoveryManager lt.getSrc().getPort(), lt.getDst().getPort(), newLinkInfo.getSrcPortState(), newLinkInfo.getDstPortState(), - LinkInfo.getLinkType(lt, newLinkInfo), + getLinkType(lt, newLinkInfo), EvAction.LINK_PORT_STATE_UPDATED, "LLDP Recvd"); } } if (linkChanged) { - updates.add(new LDUpdate(lt, newLinkInfo.getSrcPortState(), newLinkInfo.getDstPortState(), LinkInfo.getLinkType(lt, newLinkInfo), updateOperation)); + updates.add(new LDUpdate(lt, newLinkInfo.getSrcPortState(), newLinkInfo.getDstPortState(), getLinkType(lt, newLinkInfo), updateOperation)); } } finally { lock.writeLock().unlock(); @@ -813,7 +818,7 @@ public class LinkDiscoveryManager // send an LDUpdate. updates.add(new LDUpdate(lt, linkInfo.getSrcPortState(), linkInfo.getDstPortState(), - LinkInfo.getLinkType(lt, linkInfo), + getLinkType(lt, linkInfo), UpdateOperation.ADD_OR_UPDATE)); writeLink(lt, linkInfo); linkInfoChanged = true; @@ -936,7 +941,7 @@ public class LinkDiscoveryManager } else if (linkChanged) { updates.add(new LDUpdate(lt, info.getSrcPortState(), info.getDstPortState(), - LinkInfo.getLinkType(lt, info), + getLinkType(lt, info), UpdateOperation.ADD_OR_UPDATE)); } } @@ -1073,7 +1078,7 @@ public class LinkDiscoveryManager rowValues.put(LINK_SRC_SWITCH, srcDpid); rowValues.put(LINK_SRC_PORT, lt.getSrc().getPort()); - LinkType type = (LinkInfo.getLinkType(lt, linkInfo)); + LinkType type = getLinkType(lt, linkInfo); if (type == LinkType.DIRECT_LINK) rowValues.put(LINK_TYPE, "internal"); else if (type == LinkType.MULTIHOP_LINK) diff --git a/src/main/java/net/floodlightcontroller/linkdiscovery/web/LinksResource.java b/src/main/java/net/floodlightcontroller/linkdiscovery/web/LinksResource.java index 43761d141fdff683aecd01d36165ab197df5c1bd..e721e99045799a9345a5eb1afb63e26dc5c4674b 100644 --- a/src/main/java/net/floodlightcontroller/linkdiscovery/web/LinksResource.java +++ b/src/main/java/net/floodlightcontroller/linkdiscovery/web/LinksResource.java @@ -21,7 +21,7 @@ public class LinksResource extends ServerResource { for (LinkTuple lt : linkSet) { LinkInfo info = topo.getLinkInfo(lt.getSrc(), true); LinkTuple withType = new LinkTuple(lt.getSrc(), lt.getDst()); - withType.setType(LinkInfo.getLinkType(lt, info)); + withType.setType(topo.getLinkType(lt, info)); links.add(withType); } }