private LinkEvent updateLink(LinkKey key, Link oldLink, Link newLink) { if (oldLink.state() != newLink.state() || (oldLink.type() == INDIRECT && newLink.type() == DIRECT) || !AnnotationsUtil.isEqual(oldLink.annotations(), newLink.annotations())) { links.put(key, newLink); // strictly speaking following can be ommitted srcLinks.put(oldLink.src().deviceId(), key); dstLinks.put(oldLink.dst().deviceId(), key); return new LinkEvent(LINK_UPDATED, newLink); } return null; }
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()); }
@Override public LinkEvent removeOrDownLink(ConnectPoint src, ConnectPoint dst) { Link link = getLink(src, dst); if (link == null) { return null; } if (link.isDurable()) { return link.state() == INACTIVE ? null : updateLink(linkKey(link.src(), link.dst()), link, new DefaultLink(link.providerId(), link.src(), link.dst(), link.type(), INACTIVE, link.isDurable(), link.annotations())); } return removeLink(src, dst); }
/** * Generates a link description from a link description entity. The endpoints * must be specified to indicate directionality. * * @param src the source ConnectPoint * @param dst the destination ConnectPoint * @param link the link config entity * @return a linkDescription based on the config */ public static LinkDescription descriptionOf( ConnectPoint src, ConnectPoint dst, Link link) { checkNotNull(src, "Must supply a source endpoint"); checkNotNull(dst, "Must supply a destination endpoint"); checkNotNull(link, "Must supply a link"); return new DefaultLinkDescription( src, dst, link.type(), link.isExpected(), (SparseAnnotations) link.annotations()); }
private ImmutableSet<ConnectPoint> findInfrastructurePoints() { ImmutableSet.Builder<ConnectPoint> builder = ImmutableSet.builder(); for (TopologyEdge edge : graph.getEdges()) { if (edge.link().type() == Type.EDGE) { // exclude EDGE link from infrastructure link // - Device <-> Host // - Device <-> remote domain Device continue; } builder.add(edge.link().src()); builder.add(edge.link().dst()); } return builder.build(); }
public void addEgressLink(Link link) { egressLinks.add(link); addEgessCp(link.src()); }
Link link = event.subject(); map.put("Src port", link.src().port().toString()); map.put("Dst port", link.dst().port().toString()); map.put("Te metric", link.annotations().value(TE_METRIC)); DiscreteResource devResource = Resources.discrete(link.src().deviceId(), link.src().port()).resource(); if (resService == null) { log.warn("resource service does not exist ");
if (resource instanceof Link) { Link link = (Link) resource; if (link.state() == Link.State.INACTIVE) { setPathsToRemove(intent); } else if (link instanceof EdgeLink) { ConnectPoint connectPoint = (link.src().elementId() instanceof DeviceId) ? link.src() : link.dst(); Port port = deviceService.getPort(connectPoint.deviceId(), connectPoint.port()); if (port == null || !port.isEnabled()) { Port port1 = deviceService.getPort(link.src().deviceId(), link.src().port()); Port port2 = deviceService.getPort(link.dst().deviceId(), link.dst().port()); if (port1 == null || !port1.isEnabled() || port2 == null || !port2.isEnabled()) { setPathsToRemove(intent);
public void addIngressLink(Link link) { ingressLinks.add(link); addIngressCp(link.dst()); }
@Override public double cost(Link link, ResourceContext context) { //TODO: Usage of annotations are for transient solution. In future will be replaces with the // network config service / Projection model. switch (type) { case COST: if (link.annotations().value(COST) != null) { return Double.parseDouble(link.annotations().value(COST)); } //If cost annotations absent return -1[It is not L3 device] return -1; case TE_COST: if (link.annotations().value(TE_COST) != null) { return Double.parseDouble(link.annotations().value(TE_COST)); } //If TE cost annotations absent return -1[It is not L3 device] return -1; default: return -1; } }
/** * Test if specified Link is intact. * * @param link to test * @return true if link is intact */ private boolean isLive(Link link) { // Only testing link state for now // in the long run, consider verifying OAM state on ports return link.state() != State.INACTIVE; }
private boolean isEdgePort(ConnectPoint point) { // Logical ports are not counted as edge ports nor are infrastructure // ports. Ports that have only edge links are considered edge ports. return !point.port().isLogical() && deviceService.getPort(point) != null && linkService.getLinks(point).stream() .allMatch(link -> link.type() == Type.EDGE); }
(linkEvent.type() == LINK_REMOVED || (linkEvent.type() == LINK_UPDATED && linkEvent.subject().isExpected()));
/** * Create a list of devices ordered from the ingress to the egress of a path. * @param resources the resources of the intent * @return a list of devices */ private List<DeviceId> createIngressToEgressDeviceList(Collection<NetworkResource> resources) { List<DeviceId> deviceIds = Lists.newArrayList(); List<Link> links = Lists.newArrayList(); for (NetworkResource resource : resources) { if (resource instanceof Link) { Link linkToAdd = (Link) resource; if (linkToAdd.type() != Link.Type.EDGE) { links.add(linkToAdd); } } } Collections.sort(links, LINK_COMPARATOR); int i = 0; for (Link orderedLink : links) { deviceIds.add(orderedLink.src().deviceId()); if (i == resources.size() - 1) { deviceIds.add(orderedLink.dst().deviceId()); } i++; } return deviceIds; }
/** * Get links originating from the source device ID. * * @param links list of available links * @param source the device ID of the source device * @return the list of links with the given source */ private List<Link> getEgressLinks(Set<Link> links, final DeviceId source) { return links.stream() .filter(link -> link.src().deviceId().equals(source)) .collect(Collectors.toList()); }
deviceId = link.dst().deviceId(); nodeLabelId = pceStore.getGlobalNodeLabel(deviceId); if (nodeLabelId == null) {
@Override public double cost(Link link, ResourceContext context) { //TODO: Usage of annotations are for transient solution. In future will be replaces with the // network config service / Projection model. switch (type) { case COST: if (link.annotations().value(COST) != null) { return Double.parseDouble(link.annotations().value(COST)); } //If cost annotations absent return -1[It is not L3 device] return -1; case TE_COST: if (link.annotations().value(TE_COST) != null) { return Double.parseDouble(link.annotations().value(TE_COST)); } //If TE cost annotations absent return -1[It is not L3 device] return -1; default: return -1; } }