Java Code Examples for org.onosproject.net.Link#src()
The following examples show how to use
org.onosproject.net.Link#src() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BasicPceccHandler.java From onos with Apache License 2.0 | 5 votes |
private LinkedList<PcepValueType> createEroSubObj(Path path) { LinkedList<PcepValueType> subObjects = new LinkedList<>(); List<Link> links = path.links(); ConnectPoint source = null; ConnectPoint destination = null; IpAddress ipDstAddress = null; IpAddress ipSrcAddress = null; PcepValueType subObj = null; long portNo; for (Link link : links) { source = link.src(); if (!(source.equals(destination))) { //set IPv4SubObject for ERO object portNo = source.port().toLong(); portNo = ((portNo & IDENTIFIER_SET) == IDENTIFIER_SET) ? portNo & SET : portNo; ipSrcAddress = Ip4Address.valueOf((int) portNo); subObj = new IPv4SubObject(ipSrcAddress.getIp4Address().toInt()); subObjects.add(subObj); } destination = link.dst(); portNo = destination.port().toLong(); portNo = ((portNo & IDENTIFIER_SET) == IDENTIFIER_SET) ? portNo & SET : portNo; ipDstAddress = Ip4Address.valueOf((int) portNo); subObj = new IPv4SubObject(ipDstAddress.getIp4Address().toInt()); subObjects.add(subObj); } return subObjects; }
Example 2
Source File: PcepTunnelProvider.java From onos with Apache License 2.0 | 5 votes |
/** * Creates list of hops for ERO object from Path. * * @param path network path * @return list of ERO subobjects */ private LinkedList<PcepValueType> createPcepPath(Path path) { LinkedList<PcepValueType> llSubObjects = new LinkedList<>(); List<Link> listLink = path.links(); ConnectPoint source = null; ConnectPoint destination = null; IpAddress ipDstAddress = null; IpAddress ipSrcAddress = null; PcepValueType subObj = null; long portNo; for (Link link : listLink) { source = link.src(); if (!(source.equals(destination))) { //set IPv4SubObject for ERO object portNo = source.port().toLong(); portNo = ((portNo & IDENTIFIER_SET) == IDENTIFIER_SET) ? portNo & SET : portNo; ipSrcAddress = Ip4Address.valueOf((int) portNo); subObj = new IPv4SubObject(ipSrcAddress.getIp4Address().toInt()); llSubObjects.add(subObj); } destination = link.dst(); portNo = destination.port().toLong(); portNo = ((portNo & IDENTIFIER_SET) == IDENTIFIER_SET) ? portNo & SET : portNo; ipDstAddress = Ip4Address.valueOf((int) portNo); subObj = new IPv4SubObject(ipDstAddress.getIp4Address().toInt()); llSubObjects.add(subObj); } return llSubObjects; }
Example 3
Source File: AnnotateLinkCommand.java From onos with Apache License 2.0 | 5 votes |
private LinkDescription description(Link link, String key, String value) { checkNotNull(key, "Key cannot be null"); DefaultAnnotations.Builder builder = DefaultAnnotations.builder(); if (value != null) { builder.set(key, value); } else { builder.remove(key); } return new DefaultLinkDescription(link.src(), link.dst(), link.type(), link.isExpected(), builder.build()); }
Example 4
Source File: OFSwitchManager.java From onos with Apache License 2.0 | 5 votes |
@Override public ConnectPoint neighbour(NetworkId networkId, DeviceId deviceId, PortNumber portNumber) { ConnectPoint cp = new ConnectPoint(deviceId, portNumber); LinkService linkService = virtualNetService.get(networkId, LinkService.class); Set<Link> links = linkService.getEgressLinks(cp); log.trace("neighbour cp {} egressLinks {}", cp, links); if (links != null && links.size() > 0) { Link link = links.iterator().next(); return link.src(); } return null; }
Example 5
Source File: UiLinkId.java From onos with Apache License 2.0 | 5 votes |
/** * Returns the direction of the given link, or null if this link ID does * not correspond to the given link. * * @param link the link to examine * @return corresponding direction */ Direction directionOf(Link link) { ConnectPoint src = link.src(); ElementId srcId = src.elementId(); return elementA.equals(srcId) ? Direction.A_TO_B : elementB.equals(srcId) ? Direction.B_TO_A : null; }
Example 6
Source File: HostToHostIntentCompiler.java From onos with Apache License 2.0 | 5 votes |
private FilteredConnectPoint getFilteredPointFromLink(Link link) { FilteredConnectPoint filteredConnectPoint; if (link.src().elementId() instanceof DeviceId) { filteredConnectPoint = new FilteredConnectPoint(link.src()); } else if (link.dst().elementId() instanceof DeviceId) { filteredConnectPoint = new FilteredConnectPoint(link.dst()); } else { throw new IntentCompilationException(DEVICE_ID_NOT_FOUND); } return filteredConnectPoint; }
Example 7
Source File: PceWebTopovMessageHandler.java From onos with Apache License 2.0 | 4 votes |
/** * Handles the event of topology listeners. */ private void findTunnelAndHighlights() { Collection<Tunnel> tunnelSet = null; Highlights highlights = new Highlights(); paths.clear(); tunnelSet = tunnelService.queryTunnel(MPLS); if (tunnelSet.size() == 0) { log.warn("Tunnel does not exist"); sendMessage(highlightsMessage(highlights)); return; } for (Tunnel tunnel : tunnelSet) { if (tunnel.path() == null) { log.error("path does not exist"); sendMessage(highlightsMessage(highlights)); return; } if (!tunnel.state().equals(ACTIVE)) { log.debug("Tunnel state is not active"); sendMessage(highlightsMessage(highlights)); return; } Link firstLink = tunnel.path().links().get(0); if (firstLink != null) { if (firstLink.src() != null) { highlights = addBadge(highlights, firstLink.src().deviceId().toString(), SRC); } } Link lastLink = tunnel.path().links().get(tunnel.path().links().size() - 1); if (lastLink != null) { if (lastLink.dst() != null) { highlights = addBadge(highlights, lastLink.dst().deviceId().toString(), DST); } } paths.add(tunnel.path()); } ImmutableSet.Builder<Link> builder = ImmutableSet.builder(); allPathLinks = buildPaths(builder).build(); hilightAndSendPaths(highlights); }
Example 8
Source File: PceWebTopovMessageHandler.java From onos with Apache License 2.0 | 4 votes |
/** * Handles the event of topology listeners. */ private void highlightsForTunnel(List<Tunnel> tunnels) { Highlights highlights = new Highlights(); paths.clear(); if (tunnels.isEmpty()) { log.error("path does not exist"); sendMessage(TopoJson.highlightsMessage(highlights)); return; } for (Tunnel tunnel : tunnels) { if (tunnel.path() == null) { log.error("path does not exist"); sendMessage(highlightsMessage(highlights)); return; } if (!tunnel.state().equals(ACTIVE)) { log.debug("Tunnel state is not active"); sendMessage(highlightsMessage(highlights)); return; } Link firstLink = tunnel.path().links().get(0); if (firstLink != null) { if (firstLink.src() != null) { highlights = addBadge(highlights, firstLink.src().deviceId().toString(), SRC); } } Link lastLink = tunnel.path().links().get(tunnel.path().links().size() - 1); if (lastLink != null) { if (lastLink.dst() != null) { highlights = addBadge(highlights, lastLink.dst().deviceId().toString(), DST); } } paths.add(tunnel.path()); } ImmutableSet.Builder<Link> builder = ImmutableSet.builder(); allPathLinks = buildPaths(builder).build(); hilightAndSendPaths(highlights); }
Example 9
Source File: LinkCollectionCompiler.java From onos with Apache License 2.0 | 4 votes |
/** * Creates the domain intents that the {@link LinkCollectionIntent} contains. * * @param intent the link collection intent * @param domainService the domain service * @return the resulting list of domain intents */ protected List<Intent> getDomainIntents(LinkCollectionIntent intent, DomainService domainService) { ImmutableList.Builder<Intent> intentList = ImmutableList.builder(); // domain handling is only applied for a single entry and exit point // TODO: support multi point to multi point if (intent.filteredIngressPoints().size() != 1 || intent .filteredEgressPoints().size() != 1) { log.warn("Multiple ingress or egress ports not supported!"); return intentList.build(); } ImmutableList.Builder<Link> domainLinks = ImmutableList.builder(); // get the initial ingress connection point FilteredConnectPoint ingress = intent.filteredIngressPoints().iterator().next(); FilteredConnectPoint egress; DeviceId currentDevice = ingress.connectPoint().deviceId(); // the current domain (or LOCAL) DomainId currentDomain = domainService.getDomain(currentDevice); // if we entered a domain store the domain ingress FilteredConnectPoint domainIngress = LOCAL.equals(currentDomain) ? null : ingress; // loop until (hopefully) all links have been checked once // this is necessary because a set is not sorted by default for (int i = 0; i < intent.links().size(); i++) { // find the next link List<Link> nextLinks = getEgressLinks(intent.links(), currentDevice); // no matching link exists if (nextLinks.isEmpty()) { throw new IntentCompilationException( "No matching link starting at " + ingress .connectPoint().deviceId()); } // get the first link Link nextLink = nextLinks.get(0); ingress = new FilteredConnectPoint(nextLink.src()); egress = new FilteredConnectPoint(nextLink.dst()); // query the domain for the domain of the link's destination DomainId dstDomain = domainService .getDomain(egress.connectPoint().deviceId()); if (!currentDomain.equals(dstDomain)) { // we are leaving the current domain or LOCAL log.debug("Domain transition from {} to {}.", currentDomain, dstDomain); if (!LOCAL.equals(currentDomain)) { // add the domain intent to the intent list intentList.add(createDomainP2PIntent(intent, domainIngress, ingress, domainLinks.build())); // TODO: might end up with an unused builder // reset domain links builder domainLinks = ImmutableList.builder(); } // update current domain (might be LOCAL) currentDomain = dstDomain; // update the domain's ingress domainIngress = LOCAL.equals(currentDomain) ? null : egress; } else { if (!LOCAL.equals(currentDomain)) { // we are staying in the same domain, store the traversed link domainLinks.add(nextLink); log.debug("{} belongs to the same domain.", egress.connectPoint().deviceId()); } } currentDevice = egress.connectPoint().deviceId(); } // get the egress point egress = intent.filteredEgressPoints().iterator().next(); // still inside a domain? if (!LOCAL.equals(currentDomain) && currentDomain.equals(domainService.getDomain( egress.connectPoint().deviceId()))) { // add intent intentList.add(createDomainP2PIntent(intent, domainIngress, egress, domainLinks.build())); } return intentList.build(); }
Example 10
Source File: TopologySimulator.java From onos with Apache License 2.0 | 2 votes |
/** * Produces a link description from the given link. * * @param link link to copy * @return link description */ static DefaultLinkDescription description(Link link) { return new DefaultLinkDescription(link.src(), link.dst(), link.type()); }