use of org.onosproject.net.intent.PointToPointIntent in project onos by opennetworkinglab.
the class IntentsDiagnosisCommand method doExecute.
@Override
protected void doExecute() {
print("intents-diagnosis");
ServiceRefs svcRefs = buildServiceRefs();
if (svcRefs == null) {
return;
}
try {
for (Intent intent : svcRefs.intentsService().getIntents()) {
if (key != null && !intent.key().toString().equals(key)) {
continue;
}
print("");
printIntentHdr(intent, svcRefs);
if (intent instanceof PointToPointIntent) {
diagnosisP2Pintent((PointToPointIntent) intent, svcRefs);
} else {
// TODO : it needs to implement other types of intent
print(" It doesn't support %s intent.", intent.getClass().getSimpleName());
}
}
if (dumpIntentByLink) {
dumpIntentsByLink(svcRefs);
}
} catch (Exception e) {
print("error: " + e);
}
}
use of org.onosproject.net.intent.PointToPointIntent in project onos by opennetworkinglab.
the class IntentsDiagnosisCommand method checkP2PFlowRuleIntent.
private void checkP2PFlowRuleIntent(PointToPointIntent intent, FlowRuleIntent installable, ServiceRefs svcRefs) {
final Map<DeviceId, DeviceOnIntent> devs = createDevicesOnP2PIntent(intent, installable);
boolean errorOccurred = false;
// checking the number of links & CPs in P2P intent
for (DeviceOnIntent dev : devs.values()) {
if (dev.getIngressLinks().size() > 1) {
error("MULTIPLE NUMBER OF INGRESS LINKs on " + dev.deviceId() + ": " + dev.getIngressLinks());
errorOccurred = true;
}
if (dev.getIngressCps().size() > 1) {
error("MULTIPLE NUMBER OF INGRESS CONNECT POINTs on " + dev.deviceId() + ": " + dev.getIngressCps());
errorOccurred = true;
}
if (dev.getEgressLinks().size() > 1) {
error("MULTIPLE NUMBER OF EGRESS LINKs: on " + dev.deviceId() + ": " + dev.getEgressLinks());
errorOccurred = true;
}
if (dev.getEgressCps().size() > 1) {
error("MULTIPLE NUMBER OF EGRESS CONNECT POINTs: on " + dev.deviceId() + ": " + dev.getEgressCps());
errorOccurred = true;
}
}
ConnectPoint startCp = intent.filteredIngressPoint().connectPoint();
DeviceOnIntent startDev = devs.get(startCp.deviceId());
if (startDev == null) {
error("STARTING CONNECT POINT DEVICE: " + startCp.deviceId() + " is not on intent");
errorOccurred = true;
}
ConnectPoint endCp = intent.filteredEgressPoint().connectPoint();
DeviceOnIntent endDev = devs.get(endCp.deviceId());
if (endDev == null) {
error("END CONNECT POINT DEVICE: " + endCp.deviceId() + " is not on intent");
errorOccurred = true;
}
if (!errorOccurred) {
// Per device checking with path-order
DeviceOnIntent dev = startDev;
int i = 0;
for (; i < MAX_INTENT_PATH; i++) {
perDeviceChecking(dev, svcRefs);
// P2P intent has only 1 egress CP
ConnectPoint egressCp = dev.getEgressCps().stream().findFirst().orElse(null);
if (egressCp != null && Objects.equals(endCp, egressCp)) {
break;
}
// P2P intent has only 1 egress link
Link egressLink = dev.getEgressLinks().stream().findFirst().orElse(null);
if (egressLink == null) {
error("INVALID EGRESS LINK & CONNECT POINT for: " + dev);
errorOccurred = true;
break;
}
if (Objects.equals(egressLink.dst(), endCp)) {
break;
}
// P2P intent only 1 ingress link
dev = devs.values().stream().filter(nextDev -> Objects.equals(egressLink, nextDev.getIngressLinks().stream().findFirst().orElse(null))).findAny().orElse(null);
if (dev == null) {
error("FAILED TO FIND NEXT DEV for: " + dev + ", LINK: " + egressLink);
errorOccurred = true;
break;
}
}
if (i == MAX_INTENT_PATH) {
error("MAX INTENT PATH WAS EXCEEDED");
errorOccurred = true;
}
}
if (errorOccurred) {
// Installable checking
dump("");
dump("ERROR OCCURRED. DO PER FLOW CHECKING");
perFlowRuleChecking(installable, svcRefs);
}
if (svcRefs.workPartitionService.isMine(intent.key(), Key::hash)) {
checkIntentsByLink(installable, svcRefs);
}
}
use of org.onosproject.net.intent.PointToPointIntent in project onos by opennetworkinglab.
the class IntentsDiagnosisCommand method diagnosisP2Pintent.
private void diagnosisP2Pintent(PointToPointIntent intent, ServiceRefs svcRefs) {
List<Intent> installableIntents = svcRefs.intentsService().getInstallableIntents(intent.key());
if (installableIntents.size() == 0) {
error("NO INSTALLABLE INTENTS");
return;
}
Set<String> notSupport = new HashSet<>();
for (Intent installable : installableIntents) {
if (installable instanceof FlowRuleIntent) {
checkP2PFlowRuleIntent(intent, (FlowRuleIntent) installable, svcRefs);
} else {
// TODO : it needs to implement other types of installables
notSupport.add(installable.getClass().getSimpleName());
}
}
if (notSupport.size() > 0) {
print(" It doesn't support %s.", notSupport);
}
}
use of org.onosproject.net.intent.PointToPointIntent in project onos by opennetworkinglab.
the class IntentsListCommand method detailsFormat.
/**
* Returns detailed information text about a specific intent.
*
* @param intent to print
* @param state of intent
* @return detailed information or "" if {@code state} was null
*/
private StringBuilder detailsFormat(Intent intent, IntentState state) {
StringBuilder builder = new StringBuilder();
if (state == null) {
return builder;
}
if (!intent.resources().isEmpty()) {
builder.append('\n').append(format(RESOURCES, intent.resources()));
}
if (intent instanceof ConnectivityIntent) {
ConnectivityIntent ci = (ConnectivityIntent) intent;
if (!ci.selector().criteria().isEmpty()) {
builder.append('\n').append(format(COMMON_SELECTOR, formatSelector(ci.selector())));
}
if (!ci.treatment().allInstructions().isEmpty()) {
builder.append('\n').append(format(TREATMENT, ci.treatment().allInstructions()));
}
if (ci.constraints() != null && !ci.constraints().isEmpty()) {
builder.append('\n').append(format(CONSTRAINTS, ci.constraints()));
}
}
if (intent instanceof HostToHostIntent) {
HostToHostIntent pi = (HostToHostIntent) intent;
builder.append('\n').append(format(SRC + HOST, pi.one()));
builder.append('\n').append(format(DST + HOST, pi.two()));
} else if (intent instanceof PointToPointIntent) {
PointToPointIntent pi = (PointToPointIntent) intent;
builder.append('\n').append(formatFilteredCps(Sets.newHashSet(pi.filteredIngressPoint()), INGRESS));
builder.append('\n').append(formatFilteredCps(Sets.newHashSet(pi.filteredEgressPoint()), EGRESS));
} else if (intent instanceof MultiPointToSinglePointIntent) {
MultiPointToSinglePointIntent pi = (MultiPointToSinglePointIntent) intent;
builder.append('\n').append(formatFilteredCps(pi.filteredIngressPoints(), INGRESS));
builder.append('\n').append(formatFilteredCps(Sets.newHashSet(pi.filteredEgressPoint()), EGRESS));
} else if (intent instanceof SinglePointToMultiPointIntent) {
SinglePointToMultiPointIntent pi = (SinglePointToMultiPointIntent) intent;
builder.append('\n').append(formatFilteredCps(Sets.newHashSet(pi.filteredIngressPoint()), INGRESS));
builder.append('\n').append(formatFilteredCps(pi.filteredEgressPoints(), EGRESS));
} else if (intent instanceof PathIntent) {
PathIntent pi = (PathIntent) intent;
builder.append(format("path=%s, cost=%f", pi.path().links(), pi.path().cost()));
} else if (intent instanceof LinkCollectionIntent) {
LinkCollectionIntent li = (LinkCollectionIntent) intent;
builder.append('\n').append(format("links=%s", li.links()));
builder.append('\n').append(format(CP, li.egressPoints()));
} else if (intent instanceof OpticalCircuitIntent) {
OpticalCircuitIntent ci = (OpticalCircuitIntent) intent;
builder.append('\n').append(format("src=%s, dst=%s", ci.getSrc(), ci.getDst()));
builder.append('\n').append(format("signal type=%s", ci.getSignalType()));
builder.append('\n').append(format("bidirectional=%s", ci.isBidirectional()));
} else if (intent instanceof OpticalConnectivityIntent) {
OpticalConnectivityIntent ci = (OpticalConnectivityIntent) intent;
builder.append('\n').append(format("src=%s, dst=%s", ci.getSrc(), ci.getDst()));
builder.append('\n').append(format("signal type=%s", ci.getSignalType()));
builder.append('\n').append(format("bidirectional=%s", ci.isBidirectional()));
builder.append('\n').append(format("ochSignal=%s", ci.ochSignal()));
} else if (intent instanceof OpticalOduIntent) {
OpticalOduIntent ci = (OpticalOduIntent) intent;
builder.append('\n').append(format("src=%s, dst=%s", ci.getSrc(), ci.getDst()));
builder.append('\n').append(format("signal type=%s", ci.getSignalType()));
builder.append('\n').append(format("bidirectional=%s", ci.isBidirectional()));
}
List<Intent> installable = service.getInstallableIntents(intent.key()).stream().filter(i -> contentFilter.filter(i)).collect(Collectors.toList());
if (showInstallable && installable != null && !installable.isEmpty()) {
builder.append('\n').append(format(INSTALLABLE, installable));
}
return builder;
}
use of org.onosproject.net.intent.PointToPointIntent in project onos by opennetworkinglab.
the class PointToPointIntentCompiler method filterInvalidSubIntents.
/**
* Deletes intents from the given list if the ports or links the intent
* relies on are no longer viable. The failover flow rule intent is never
* deleted -- only its contents are updated.
*
* @param oldInstallables list of intents to examine
* @return list of reusable installable intents
*/
private List<Intent> filterInvalidSubIntents(List<Intent> oldInstallables, PointToPointIntent pointIntent) {
List<Intent> intentList = new ArrayList<>();
intentList.addAll(oldInstallables);
Iterator<Intent> iterator = intentList.iterator();
while (iterator.hasNext()) {
Intent intent = iterator.next();
intent.resources().forEach(resource -> {
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()) {
setPathsToRemove(intent);
}
} else {
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);
}
}
}
});
}
removeAndUpdateIntents(intentList, pointIntent);
return intentList;
}
Aggregations