Search in sources :

Example 31 with PointToPointIntent

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);
    }
}
Also used : PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) Intent(org.onosproject.net.intent.Intent) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) PointToPointIntent(org.onosproject.net.intent.PointToPointIntent)

Example 32 with PointToPointIntent

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);
    }
}
Also used : PortStatistics(org.onosproject.net.device.PortStatistics) DeviceService(org.onosproject.net.device.DeviceService) FlowEntry(org.onosproject.net.flow.FlowEntry) HashMap(java.util.HashMap) DefaultDevice(org.onosproject.net.DefaultDevice) AnnotationKeys(org.onosproject.net.AnnotationKeys) Link(org.onosproject.net.Link) Command(org.apache.karaf.shell.api.action.Command) ConnectPoint(org.onosproject.net.ConnectPoint) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) FlowRuleService(org.onosproject.net.flow.FlowRuleService) IntentService(org.onosproject.net.intent.IntentService) Port(org.onosproject.net.Port) Map(java.util.Map) Intent(org.onosproject.net.intent.Intent) WorkPartitionService(org.onosproject.net.intent.WorkPartitionService) LinkKey(org.onosproject.net.LinkKey) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) ImmutableSet(com.google.common.collect.ImmutableSet) Device(org.onosproject.net.Device) Collection(java.util.Collection) MoreObjects(com.google.common.base.MoreObjects) Set(java.util.Set) Argument(org.apache.karaf.shell.api.action.Argument) Streams(com.google.common.collect.Streams) Field(java.lang.reflect.Field) SetMultimap(com.google.common.collect.SetMultimap) FlowStatisticService(org.onosproject.net.statistic.FlowStatisticService) ObjectiveTrackerService(org.onosproject.net.intent.ObjectiveTrackerService) Objects(java.util.Objects) AbstractShellCommand(org.onosproject.cli.AbstractShellCommand) Key(org.onosproject.net.intent.Key) List(java.util.List) Stream(java.util.stream.Stream) PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) FlowRule(org.onosproject.net.flow.FlowRule) Service(org.apache.karaf.shell.api.action.lifecycle.Service) Completion(org.apache.karaf.shell.api.action.Completion) Option(org.apache.karaf.shell.api.action.Option) DeviceId(org.onosproject.net.DeviceId) DeviceId(org.onosproject.net.DeviceId) ConnectPoint(org.onosproject.net.ConnectPoint) ConnectPoint(org.onosproject.net.ConnectPoint) Link(org.onosproject.net.Link) LinkKey(org.onosproject.net.LinkKey) Key(org.onosproject.net.intent.Key)

Example 33 with PointToPointIntent

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);
    }
}
Also used : Intent(org.onosproject.net.intent.Intent) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) HashSet(java.util.HashSet) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent)

Example 34 with PointToPointIntent

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;
}
Also used : StringFilter(org.onlab.util.StringFilter) StringUtils(org.apache.commons.lang.StringUtils) Tools(org.onlab.util.Tools) IntentState(org.onosproject.net.intent.IntentState) HashMap(java.util.HashMap) SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Command(org.apache.karaf.shell.api.action.Command) ConnectPoint(org.onosproject.net.ConnectPoint) ArrayList(java.util.ArrayList) Strings(com.google.common.base.Strings) Lists(com.google.common.collect.Lists) TrafficSelector(org.onosproject.net.flow.TrafficSelector) OpticalCircuitIntent(org.onosproject.net.intent.OpticalCircuitIntent) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) IntentService(org.onosproject.net.intent.IntentService) Map(java.util.Map) Intent(org.onosproject.net.intent.Intent) JsonNode(com.fasterxml.jackson.databind.JsonNode) WorkPartitionService(org.onosproject.net.intent.WorkPartitionService) Criterion(org.onosproject.net.flow.criteria.Criterion) NodeId(org.onosproject.cluster.NodeId) PathIntent(org.onosproject.net.intent.PathIntent) HostToHostIntent(org.onosproject.net.intent.HostToHostIntent) WordUtils.uncapitalize(org.apache.commons.lang3.text.WordUtils.uncapitalize) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Set(java.util.Set) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) String.format(java.lang.String.format) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) AbstractShellCommand(org.onosproject.cli.AbstractShellCommand) Key(org.onosproject.net.intent.Key) List(java.util.List) PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) Service(org.apache.karaf.shell.api.action.lifecycle.Service) ConnectivityIntent(org.onosproject.net.intent.ConnectivityIntent) OpticalOduIntent(org.onosproject.net.intent.OpticalOduIntent) MoreObjects.firstNonNull(com.google.common.base.MoreObjects.firstNonNull) Option(org.apache.karaf.shell.api.action.Option) OpticalConnectivityIntent(org.onosproject.net.intent.OpticalConnectivityIntent) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) HostToHostIntent(org.onosproject.net.intent.HostToHostIntent) PathIntent(org.onosproject.net.intent.PathIntent) PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) OpticalConnectivityIntent(org.onosproject.net.intent.OpticalConnectivityIntent) SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) OpticalCircuitIntent(org.onosproject.net.intent.OpticalCircuitIntent) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) Intent(org.onosproject.net.intent.Intent) PathIntent(org.onosproject.net.intent.PathIntent) HostToHostIntent(org.onosproject.net.intent.HostToHostIntent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) ConnectivityIntent(org.onosproject.net.intent.ConnectivityIntent) OpticalOduIntent(org.onosproject.net.intent.OpticalOduIntent) OpticalConnectivityIntent(org.onosproject.net.intent.OpticalConnectivityIntent) ConnectivityIntent(org.onosproject.net.intent.ConnectivityIntent) OpticalConnectivityIntent(org.onosproject.net.intent.OpticalConnectivityIntent) SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) OpticalOduIntent(org.onosproject.net.intent.OpticalOduIntent) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) OpticalCircuitIntent(org.onosproject.net.intent.OpticalCircuitIntent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent)

Example 35 with PointToPointIntent

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;
}
Also used : DefaultEdgeLink.createEdgeLink(org.onosproject.net.DefaultEdgeLink.createEdgeLink) EdgeLink(org.onosproject.net.EdgeLink) DeviceId(org.onosproject.net.DeviceId) Port(org.onosproject.net.Port) ArrayList(java.util.ArrayList) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) Intent(org.onosproject.net.intent.Intent) PathIntent(org.onosproject.net.intent.PathIntent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) ConnectPoint(org.onosproject.net.ConnectPoint) DefaultEdgeLink.createEdgeLink(org.onosproject.net.DefaultEdgeLink.createEdgeLink) Link(org.onosproject.net.Link) EdgeLink(org.onosproject.net.EdgeLink)

Aggregations

PointToPointIntent (org.onosproject.net.intent.PointToPointIntent)48 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)28 ConnectPoint (org.onosproject.net.ConnectPoint)24 Intent (org.onosproject.net.intent.Intent)19 Test (org.junit.Test)18 AbstractIntentTest (org.onosproject.net.intent.AbstractIntentTest)16 LinkCollectionIntent (org.onosproject.net.intent.LinkCollectionIntent)16 TrafficSelector (org.onosproject.net.flow.TrafficSelector)13 Key (org.onosproject.net.intent.Key)13 ArrayList (java.util.ArrayList)12 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)12 Link (org.onosproject.net.Link)11 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)11 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)11 Constraint (org.onosproject.net.intent.Constraint)11 FlowRuleIntent (org.onosproject.net.intent.FlowRuleIntent)10 BandwidthConstraint (org.onosproject.net.intent.constraint.BandwidthConstraint)10 PathIntent (org.onosproject.net.intent.PathIntent)8 MockResourceService (org.onosproject.net.resource.MockResourceService)8 ResourceService (org.onosproject.net.resource.ResourceService)8