use of org.onosproject.net.EdgeLink in project onos by opennetworkinglab.
the class AbstractPathService method getPaths.
@Override
public Set<Path> getPaths(ElementId src, ElementId dst, LinkWeigher weigher) {
checkNotNull(src, ELEMENT_ID_NULL);
checkNotNull(dst, ELEMENT_ID_NULL);
LinkWeigher internalWeigher = weigher != null ? weigher : DEFAULT_WEIGHER;
// Get the source and destination edge locations
EdgeLink srcEdge = getEdgeLink(src, true);
EdgeLink dstEdge = getEdgeLink(dst, false);
// If either edge is null, bail with no paths.
if (srcEdge == null || dstEdge == null) {
return ImmutableSet.of();
}
DeviceId srcDevice = srcEdge != NOT_HOST ? srcEdge.dst().deviceId() : (DeviceId) src;
DeviceId dstDevice = dstEdge != NOT_HOST ? dstEdge.src().deviceId() : (DeviceId) dst;
// is just one path, so build it and return it.
if (srcDevice.equals(dstDevice)) {
return edgeToEdgePaths(srcEdge, dstEdge, internalWeigher);
}
// Otherwise get all paths between the source and destination edge
// devices.
Topology topology = topologyService.currentTopology();
Set<Path> paths = topologyService.getPaths(topology, srcDevice, dstDevice, internalWeigher);
return edgeToEdgePaths(srcEdge, dstEdge, paths, internalWeigher);
}
use of org.onosproject.net.EdgeLink in project onos by opennetworkinglab.
the class AbstractPathService method getDisjointPaths.
@Override
public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst, LinkWeigher weigher) {
checkNotNull(src, ELEMENT_ID_NULL);
checkNotNull(dst, ELEMENT_ID_NULL);
LinkWeigher internalWeigher = weigher != null ? weigher : DEFAULT_WEIGHER;
// Get the source and destination edge locations
EdgeLink srcEdge = getEdgeLink(src, true);
EdgeLink dstEdge = getEdgeLink(dst, false);
// If either edge is null, bail with no paths.
if (srcEdge == null || dstEdge == null) {
return ImmutableSet.of();
}
DeviceId srcDevice = srcEdge != NOT_HOST ? srcEdge.dst().deviceId() : (DeviceId) src;
DeviceId dstDevice = dstEdge != NOT_HOST ? dstEdge.src().deviceId() : (DeviceId) dst;
// is just one path, so build it and return it.
if (srcDevice.equals(dstDevice)) {
return edgeToEdgePathsDisjoint(srcEdge, dstEdge, internalWeigher);
}
// Otherwise get all paths between the source and destination edge
// devices.
Topology topology = topologyService.currentTopology();
Set<DisjointPath> paths = topologyService.getDisjointPaths(topology, srcDevice, dstDevice, internalWeigher);
return edgeToEdgePathsDisjoint(srcEdge, dstEdge, paths, internalWeigher);
}
use of org.onosproject.net.EdgeLink in project onos by opennetworkinglab.
the class AbstractPathService method getDisjointPaths.
@Override
public Set<DisjointPath> getDisjointPaths(ElementId src, ElementId dst, LinkWeigher weigher, Map<Link, Object> riskProfile) {
checkNotNull(src, ELEMENT_ID_NULL);
checkNotNull(dst, ELEMENT_ID_NULL);
LinkWeigher internalWeigher = weigher != null ? weigher : DEFAULT_WEIGHER;
// Get the source and destination edge locations
EdgeLink srcEdge = getEdgeLink(src, true);
EdgeLink dstEdge = getEdgeLink(dst, false);
// If either edge is null, bail with no paths.
if (srcEdge == null || dstEdge == null) {
return ImmutableSet.of();
}
DeviceId srcDevice = srcEdge != NOT_HOST ? srcEdge.dst().deviceId() : (DeviceId) src;
DeviceId dstDevice = dstEdge != NOT_HOST ? dstEdge.src().deviceId() : (DeviceId) dst;
// is just one path, so build it and return it.
if (srcDevice.equals(dstDevice)) {
return edgeToEdgePathsDisjoint(srcEdge, dstEdge, internalWeigher);
}
// Otherwise get all paths between the source and destination edge
// devices.
Topology topology = topologyService.currentTopology();
Set<DisjointPath> paths = topologyService.getDisjointPaths(topology, srcDevice, dstDevice, internalWeigher, riskProfile);
return edgeToEdgePathsDisjoint(srcEdge, dstEdge, paths, internalWeigher);
}
use of org.onosproject.net.EdgeLink in project onos by opennetworkinglab.
the class PointToPointIntentCompiler method pathAvailable.
/**
* Checks suggested path availability.
* It checks:
* - single links availability;
* - that first and last device of the path are coherent with ingress and egress devices;
* - links contiguity.
*
* @param intent Intent with suggested path to check
* @return true if the suggested path is available
*/
private boolean pathAvailable(PointToPointIntent intent) {
// Check links availability
List<Link> suggestedPath = intent.suggestedPath();
for (Link link : suggestedPath) {
if (!(link instanceof EdgeLink) && !linkService.getLinks(link.src()).contains(link)) {
return false;
}
}
// Check that first and last device of the path are intent ingress and egress devices
if (!suggestedPath.get(0).src().deviceId().equals(intent.filteredIngressPoint().connectPoint().deviceId())) {
return false;
}
if (!suggestedPath.get(suggestedPath.size() - 1).dst().deviceId().equals(intent.filteredEgressPoint().connectPoint().deviceId())) {
return false;
}
// Check contiguity
List<Pair<Link, Link>> linkPairs = IntStream.range(0, suggestedPath.size() - 1).mapToObj(i -> Pair.of(suggestedPath.get(i), suggestedPath.get(i + 1))).collect(Collectors.toList());
for (Pair<Link, Link> linkPair : linkPairs) {
if (!linkPair.getKey().dst().deviceId().equals(linkPair.getValue().src().deviceId())) {
return false;
}
}
return true;
}
use of org.onosproject.net.EdgeLink in project onos by opennetworkinglab.
the class ModelCache method updateHost.
private void updateHost(UiHost uiHost, Host h) {
UiEdgeLink existing = uiTopology.findEdgeLink(uiHost.edgeLinkId());
// TODO: review - do we need EdgeLink now that we are creating from id only?
EdgeLink currentElink = synthesizeLink(h);
UiLinkId currentElinkId = uiLinkId(currentElink);
if (existing != null) {
if (!currentElinkId.equals(existing.id())) {
// edge link has changed
insertNewUiEdgeLink(currentElinkId);
uiHost.setEdgeLinkId(currentElinkId);
uiTopology.remove(existing);
}
} else {
// no previously existing edge link
insertNewUiEdgeLink(currentElinkId);
uiHost.setEdgeLinkId(currentElinkId);
}
HostLocation hloc = h.location();
uiHost.setLocation(hloc.deviceId(), hloc.port());
}
Aggregations