Search in sources :

Example 71 with ConnectPoint

use of org.onosproject.net.ConnectPoint in project onos by opennetworkinglab.

the class PathCompiler method compile.

/**
 * Compiles an intent down to flows.
 *
 * @param creator how to create the flows
 * @param intent intent to process
 * @param flows list of generated flows
 * @param devices list of devices that correspond to the flows
 */
public void compile(PathCompilerCreateFlow<T> creator, PathIntent intent, List<T> flows, List<DeviceId> devices) {
    // Note: right now recompile is not considered
    // TODO: implement recompile behavior
    List<Link> links = intent.path().links();
    Optional<EncapsulationConstraint> encapConstraint = intent.constraints().stream().filter(constraint -> constraint instanceof EncapsulationConstraint).map(x -> (EncapsulationConstraint) x).findAny();
    // if no encapsulation or is involved only a single switch use the default behaviour
    if (!encapConstraint.isPresent() || links.size() == 2) {
        for (int i = 0; i < links.size() - 1; i++) {
            ConnectPoint ingress = links.get(i).dst();
            ConnectPoint egress = links.get(i + 1).src();
            creator.createFlow(intent.selector(), intent.treatment(), ingress, egress, intent.priority(), isLast(links, i), flows, devices);
        }
        return;
    }
    encapConstraint.map(EncapsulationConstraint::encapType).map(type -> {
        switch(type) {
            case VLAN:
                manageVlanEncap(creator, flows, devices, intent);
                break;
            case MPLS:
                manageMplsEncap(creator, flows, devices, intent);
                break;
            default:
        }
        return 0;
    });
}
Also used : EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint) MplsCriterion(org.onosproject.net.flow.criteria.MplsCriterion) Identifier(org.onlab.util.Identifier) LabelAllocator(org.onosproject.net.resource.impl.LabelAllocator) IntentCompilationException(org.onosproject.net.intent.IntentCompilationException) Link(org.onosproject.net.Link) ResourceService(org.onosproject.net.resource.ResourceService) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) ConnectPoint(org.onosproject.net.ConnectPoint) EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint) Ethernet(org.onlab.packet.Ethernet) TrafficSelector(org.onosproject.net.flow.TrafficSelector) Map(java.util.Map) L2ModificationInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction) LinkKey.linkKey(org.onosproject.net.LinkKey.linkKey) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) Criterion(org.onosproject.net.flow.criteria.Criterion) LinkKey(org.onosproject.net.LinkKey) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) PathIntent(org.onosproject.net.intent.PathIntent) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) MplsLabel(org.onlab.packet.MplsLabel) EthTypeCriterion(org.onosproject.net.flow.criteria.EthTypeCriterion) Instruction(org.onosproject.net.flow.instructions.Instruction) VlanId(org.onlab.packet.VlanId) Set(java.util.Set) Sets(com.google.common.collect.Sets) EthType(org.onlab.packet.EthType) List(java.util.List) EncapsulationType(org.onosproject.net.EncapsulationType) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion) Optional(java.util.Optional) DeviceId(org.onosproject.net.DeviceId) ConnectPoint(org.onosproject.net.ConnectPoint) Link(org.onosproject.net.Link) ConnectPoint(org.onosproject.net.ConnectPoint) EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint)

Example 72 with ConnectPoint

use of org.onosproject.net.ConnectPoint in project onos by opennetworkinglab.

the class PointToPointIntentCompiler method createFailoverTreatmentGroup.

/**
 * Creates a new failover group with the initial ports of the links
 * from the primary and backup path.
 *
 * @param links         links from the primary path
 * @param backupLinks   links from the backup path
 * @param intent        intent from which this call originates
 */
private void createFailoverTreatmentGroup(List<Link> links, List<Link> backupLinks, PointToPointIntent intent) {
    List<GroupBucket> buckets = new ArrayList<>();
    TrafficTreatment.Builder tBuilderIn = DefaultTrafficTreatment.builder();
    ConnectPoint src = links.get(0).src();
    tBuilderIn.setOutput(src.port());
    TrafficTreatment.Builder tBuilderIn2 = DefaultTrafficTreatment.builder();
    ConnectPoint src2 = backupLinks.get(0).src();
    tBuilderIn2.setOutput(src2.port());
    buckets.add(DefaultGroupBucket.createFailoverGroupBucket(tBuilderIn.build(), src.port(), null));
    buckets.add(DefaultGroupBucket.createFailoverGroupBucket(tBuilderIn2.build(), src2.port(), null));
    GroupBuckets groupBuckets = new GroupBuckets(buckets);
    GroupDescription groupDesc = new DefaultGroupDescription(src.deviceId(), Group.Type.FAILOVER, groupBuckets, makeGroupKey(intent.id()), null, intent.appId());
    log.trace("adding failover group {}", groupDesc);
    groupService.addGroup(groupDesc);
}
Also used : DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupDescription(org.onosproject.net.group.GroupDescription) ArrayList(java.util.ArrayList) GroupBucket(org.onosproject.net.group.GroupBucket) DefaultGroupBucket(org.onosproject.net.group.DefaultGroupBucket) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) GroupBuckets(org.onosproject.net.group.GroupBuckets) ConnectPoint(org.onosproject.net.ConnectPoint) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription)

Example 73 with ConnectPoint

use of org.onosproject.net.ConnectPoint in project onos by opennetworkinglab.

the class PointToPointIntentCompiler method createFailoverFlowRules.

/**
 * Manufactures flow rule with treatment that is defined by failover
 * group and traffic selector determined by ingress port of the intent.
 *
 * @param intent intent which is being compiled (for appId)
 * @return       a list of a singular flow rule with fast failover
 *               outport traffic treatment
 */
private List<FlowRule> createFailoverFlowRules(PointToPointIntent intent) {
    List<FlowRule> flowRules = new ArrayList<>();
    ConnectPoint ingress = intent.filteredIngressPoint().connectPoint();
    DeviceId deviceId = ingress.deviceId();
    // flow rule with failover traffic treatment
    TrafficSelector trafficSelector = DefaultTrafficSelector.builder(intent.selector()).matchInPort(ingress.port()).build();
    FlowRule.Builder flowRuleBuilder = DefaultFlowRule.builder();
    flowRules.add(flowRuleBuilder.withSelector(trafficSelector).withTreatment(buildFailoverTreatment(deviceId, makeGroupKey(intent.id()))).fromApp(intent.appId()).makePermanent().forDevice(deviceId).withPriority(PRIORITY).build());
    return flowRules;
}
Also used : DeviceId(org.onosproject.net.DeviceId) ArrayList(java.util.ArrayList) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 74 with ConnectPoint

use of org.onosproject.net.ConnectPoint 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;
}
Also used : DefaultEdgeLink.createEdgeLink(org.onosproject.net.DefaultEdgeLink.createEdgeLink) ListIterator(java.util.ListIterator) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) PortNumber(org.onosproject.net.PortNumber) TimeoutException(java.util.concurrent.TimeoutException) Link(org.onosproject.net.Link) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) ByteBuffer(java.nio.ByteBuffer) ConnectPoint(org.onosproject.net.ConnectPoint) Pair(org.apache.commons.lang3.tuple.Pair) Port(org.onosproject.net.Port) GroupListener(org.onosproject.net.group.GroupListener) Arrays.asList(java.util.Arrays.asList) PathNotFoundException(org.onosproject.net.intent.impl.PathNotFoundException) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) ImmutableSet(com.google.common.collect.ImmutableSet) Deactivate(org.osgi.service.component.annotations.Deactivate) Set(java.util.Set) Collectors(java.util.stream.Collectors) List(java.util.List) Stream(java.util.stream.Stream) FlowRule(org.onosproject.net.flow.FlowRule) GroupBuckets(org.onosproject.net.group.GroupBuckets) LinkService(org.onosproject.net.link.LinkService) Path(org.onosproject.net.Path) DeviceId(org.onosproject.net.DeviceId) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupDescription(org.onosproject.net.group.GroupDescription) IntStream(java.util.stream.IntStream) IntentCompilationException(org.onosproject.net.intent.IntentCompilationException) CompletableFuture(java.util.concurrent.CompletableFuture) GroupBucket(org.onosproject.net.group.GroupBucket) GroupKey(org.onosproject.net.group.GroupKey) Group(org.onosproject.net.group.Group) ArrayList(java.util.ArrayList) Component(org.osgi.service.component.annotations.Component) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) DefaultPath(org.onosproject.net.DefaultPath) Intent(org.onosproject.net.intent.Intent) Activate(org.osgi.service.component.annotations.Activate) EdgeLink(org.onosproject.net.EdgeLink) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) IntentId(org.onosproject.net.intent.IntentId) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) PathIntent(org.onosproject.net.intent.PathIntent) Instructions(org.onosproject.net.flow.instructions.Instructions) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) Instruction(org.onosproject.net.flow.instructions.Instruction) GroupService(org.onosproject.net.group.GroupService) ProtectionConstraint(org.onosproject.net.intent.constraint.ProtectionConstraint) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) ProviderId(org.onosproject.net.provider.ProviderId) DefaultGroupBucket(org.onosproject.net.group.DefaultGroupBucket) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) ScalarWeight(org.onlab.graph.ScalarWeight) Reference(org.osgi.service.component.annotations.Reference) Collections(java.util.Collections) DisjointPath(org.onosproject.net.DisjointPath) DefaultEdgeLink.createEdgeLink(org.onosproject.net.DefaultEdgeLink.createEdgeLink) EdgeLink(org.onosproject.net.EdgeLink) DefaultEdgeLink.createEdgeLink(org.onosproject.net.DefaultEdgeLink.createEdgeLink) Link(org.onosproject.net.Link) EdgeLink(org.onosproject.net.EdgeLink) Pair(org.apache.commons.lang3.tuple.Pair)

Example 75 with ConnectPoint

use of org.onosproject.net.ConnectPoint in project onos by opennetworkinglab.

the class ProtectedTransportIntentCompiler method createSubTransitIntent.

/**
 * Creates required Intents required to transit uni-directionally along the Path.
 *
 * @param intent parent IntentId
 * @param path whole path
 * @param vid VlanId to use as tunnel labels
 * @param resources to be passed down to generated Intents
 * @return List of transit Intents, if any is required.
 */
LinkCollectionIntent createSubTransitIntent(Intent intent, Path path, VlanId vid, Collection<NetworkResource> resources) {
    checkArgument(path.links().size() > 1);
    // transit ingress/egress
    ConnectPoint one = path.links().get(0).dst();
    ConnectPoint two = path.links().get(path.links().size() - 1).src();
    return LinkCollectionIntent.builder().key(intent.key()).appId(intent.appId()).priority(intent.priority()).resources(resources).links(ImmutableSet.copyOf(path.links())).filteredIngressPoints(ImmutableSet.of(vlanPort(one, vid))).filteredEgressPoints(ImmutableSet.of(vlanPort(two, vid))).applyTreatmentOnEgress(true).cost(path.cost()).build();
}
Also used : ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Aggregations

ConnectPoint (org.onosproject.net.ConnectPoint)536 Test (org.junit.Test)149 DeviceId (org.onosproject.net.DeviceId)125 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)91 Link (org.onosproject.net.Link)88 Set (java.util.Set)86 PortNumber (org.onosproject.net.PortNumber)86 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)83 VlanId (org.onlab.packet.VlanId)78 TrafficSelector (org.onosproject.net.flow.TrafficSelector)75 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)72 Logger (org.slf4j.Logger)71 Port (org.onosproject.net.Port)70 List (java.util.List)69 Ethernet (org.onlab.packet.Ethernet)69 DeviceService (org.onosproject.net.device.DeviceService)67 Collectors (java.util.stream.Collectors)66 MacAddress (org.onlab.packet.MacAddress)64 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)64 Intent (org.onosproject.net.intent.Intent)62