use of org.onosproject.net.link.LinkService in project onos by opennetworkinglab.
the class TrafficMonitorBase method createTrafficLinks.
protected void createTrafficLinks(Highlights highlights, TrafficLinkMap linkMap, Set<Intent> intents, LinkHighlight.Flavor flavor, boolean showTraffic) {
for (Intent intent : intents) {
List<Intent> installables = services.intent().getInstallableIntents(intent.key());
Iterable<Link> links = null;
if (installables != null) {
for (Intent installable : installables) {
if (installable instanceof PathIntent) {
links = ((PathIntent) installable).path().links();
} else if (installable instanceof FlowRuleIntent) {
Collection<Link> l = new ArrayList<>();
l.addAll(linkResources(installable));
// Add cross connect links
if (intent instanceof OpticalConnectivityIntent) {
OpticalConnectivityIntent ocIntent = (OpticalConnectivityIntent) intent;
LinkService linkService = services.link();
DeviceService deviceService = services.device();
l.addAll(linkService.getDeviceIngressLinks(ocIntent.getSrc().deviceId()).stream().filter(i -> deviceService.getDevice(i.src().deviceId()).type() == Device.Type.SWITCH).collect(Collectors.toList()));
l.addAll(linkService.getDeviceEgressLinks(ocIntent.getDst().deviceId()).stream().filter(e -> deviceService.getDevice(e.dst().deviceId()).type() == Device.Type.SWITCH).collect(Collectors.toList()));
}
links = l;
} else if (installable instanceof FlowObjectiveIntent) {
links = linkResources(installable);
} else if (installable instanceof LinkCollectionIntent) {
links = ((LinkCollectionIntent) installable).links();
} else if (installable instanceof OpticalPathIntent) {
links = ((OpticalPathIntent) installable).path().links();
}
if (links == null) {
links = Lists.newArrayList();
}
links = addEdgeLinksIfNeeded(intent, Lists.newArrayList(links));
boolean isOptical = intent instanceof OpticalConnectivityIntent;
processLinks(linkMap, links, flavor, isOptical, showTraffic);
updateHighlights(highlights, links);
}
}
}
}
use of org.onosproject.net.link.LinkService in project onos by opennetworkinglab.
the class ProtectedIntentMonitor method protectedIntentMultiLayer.
/**
* Returns the packet to optical mapping given a head and tail of a protection path.
*
* @param head head of path
* @param tail tail of path
*/
private Set<Link> protectedIntentMultiLayer(ConnectPoint head, ConnectPoint tail) {
List<Link> links = new LinkedList<>();
LinkService linkService = services.link();
IntentService intentService = services.intent();
// Ingress cross connect link
links.addAll(linkService.getEgressLinks(head).stream().filter(l -> l.type() == Link.Type.OPTICAL).collect(Collectors.toList()));
// Egress cross connect link
links.addAll(linkService.getIngressLinks(tail).stream().filter(l -> l.type() == Link.Type.OPTICAL).collect(Collectors.toList()));
// The protected intent does not rely on a multi-layer mapping
if (links.size() != 2) {
return Collections.emptySet();
}
// Expected head and tail of optical circuit (not connectivity!) intent
ConnectPoint ocHead = links.get(0).dst();
ConnectPoint ocTail = links.get(1).src();
// Optical connectivity
// FIXME: assumes that transponder (OTN device) is a one-to-one mapping
// We need to track the multi-layer aspects better
intentService.getIntents().forEach(intent -> {
if (intent instanceof OpticalConnectivityIntent) {
OpticalConnectivityIntent ocIntent = (OpticalConnectivityIntent) intent;
if (ocHead.deviceId().equals(ocIntent.getSrc().deviceId()) && ocTail.deviceId().equals(ocIntent.getDst().deviceId())) {
intentService.getInstallableIntents(ocIntent.key()).forEach(i -> {
if (i instanceof FlowRuleIntent) {
FlowRuleIntent fr = (FlowRuleIntent) i;
links.addAll(linkResources(fr));
}
});
}
}
});
return new LinkedHashSet<>(links);
}
use of org.onosproject.net.link.LinkService in project onos by opennetworkinglab.
the class VirtualNetworkLinkManagerTest method testGetDeviceLinksByNullId.
/**
* Tests querying for links using a null device identifier.
*/
@Test(expected = NullPointerException.class)
public void testGetDeviceLinksByNullId() {
manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
LinkService linkService = manager.get(virtualNetwork.id(), LinkService.class);
// test the getDeviceLinks() method with a null device identifier.
linkService.getDeviceLinks(null);
}
use of org.onosproject.net.link.LinkService in project onos by opennetworkinglab.
the class VirtualNetworkLinkManagerTest method testGetLinksByNullId.
/**
* Tests querying for links using a null connect point.
*/
@Test(expected = NullPointerException.class)
public void testGetLinksByNullId() {
manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
LinkService linkService = manager.get(virtualNetwork.id(), LinkService.class);
// test the getLinks() method with a null connect point.
linkService.getLinks(null);
}
use of org.onosproject.net.link.LinkService in project onos by opennetworkinglab.
the class VirtualNetworkLinkManagerTest method testGetDeviceEgressLinksByNullId.
/**
* Tests querying for device egress links using a null device identifier.
*/
@Test(expected = NullPointerException.class)
public void testGetDeviceEgressLinksByNullId() {
manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
LinkService linkService = manager.get(virtualNetwork.id(), LinkService.class);
// test the getDeviceEgressLinks() method with a null device identifier.
linkService.getDeviceEgressLinks(null);
}
Aggregations