Search in sources :

Example 11 with MultiPointToSinglePointIntent

use of org.onosproject.net.intent.MultiPointToSinglePointIntent in project onos by opennetworkinglab.

the class SimpleFabricForwarding method dump.

// Dump command handler
private void dump(String subject, PrintStream out) {
    if ("intents".equals(subject)) {
        out.println("Forwarding Broadcast Intents:\n");
        for (SinglePointToMultiPointIntent intent : bctIntentsMap.values()) {
            out.println("    " + intent.key().toString() + ": " + intent.selector().criteria() + ", [" + intent.filteredIngressPoint().connectPoint() + "] -> " + intent.filteredEgressPoints().stream().map(FilteredConnectPoint::connectPoint).collect(Collectors.toSet()));
        }
        out.println("");
        out.println("Forwarding Unicast Intents:\n");
        for (MultiPointToSinglePointIntent intent : uniIntentsMap.values()) {
            out.println("    " + intent.key().toString() + ": " + intent.selector().criteria() + ", [" + intent.filteredIngressPoints().stream().map(FilteredConnectPoint::connectPoint).collect(Collectors.toSet()) + "] -> " + intent.filteredEgressPoint().connectPoint());
        }
        out.println("");
        out.println("Forwarding Intents to Be Purged:\n");
        for (Key key : toBePurgedIntentKeys) {
            out.println("    " + key.toString());
        }
        out.println("");
    }
}
Also used : SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) Key(org.onosproject.net.intent.Key)

Example 12 with MultiPointToSinglePointIntent

use of org.onosproject.net.intent.MultiPointToSinglePointIntent in project onos by opennetworkinglab.

the class SimpleFabricForwarding method refresh.

private void refresh() {
    log.debug("simple fabric forwarding refresh");
    Map<Key, SinglePointToMultiPointIntent> newBctIntentsMap = Maps.newConcurrentMap();
    Map<Key, MultiPointToSinglePointIntent> newUniIntentsMap = Maps.newConcurrentMap();
    for (FabricNetwork fabricNetwork : simpleFabric.fabricNetworks()) {
        // if fabricNetwork.isForward == false or number of interfaces() < 2, no Intents generated
        for (SinglePointToMultiPointIntent intent : buildBrcIntents(fabricNetwork)) {
            newBctIntentsMap.put(intent.key(), intent);
        }
        for (MultiPointToSinglePointIntent intent : buildUniIntents(fabricNetwork, hostsFromL2Network(fabricNetwork))) {
            newUniIntentsMap.put(intent.key(), intent);
        }
        if (fabricNetwork.isDirty()) {
            fabricNetwork.setDirty(false);
        }
    }
    boolean bctUpdated = false;
    for (SinglePointToMultiPointIntent intent : bctIntentsMap.values()) {
        SinglePointToMultiPointIntent newIntent = newBctIntentsMap.get(intent.key());
        if (newIntent == null) {
            log.info("simple fabric forwarding withdraw broadcast intent: {}", intent.key().toString());
            toBePurgedIntentKeys.add(intent.key());
            intentService.withdraw(intent);
            bctUpdated = true;
        }
    }
    for (SinglePointToMultiPointIntent intent : newBctIntentsMap.values()) {
        SinglePointToMultiPointIntent oldIntent = bctIntentsMap.get(intent.key());
        if (oldIntent == null || !oldIntent.filteredEgressPoints().equals(intent.filteredEgressPoints()) || !oldIntent.filteredIngressPoint().equals(intent.filteredIngressPoint()) || !oldIntent.selector().equals(intent.selector()) || !oldIntent.treatment().equals(intent.treatment()) || !oldIntent.constraints().equals(intent.constraints())) {
            log.info("simple fabric forwarding submit broadcast intent: {}", intent.key().toString());
            toBePurgedIntentKeys.remove(intent.key());
            intentService.submit(intent);
            bctUpdated = true;
        }
    }
    boolean uniUpdated = false;
    for (MultiPointToSinglePointIntent intent : uniIntentsMap.values()) {
        MultiPointToSinglePointIntent newIntent = newUniIntentsMap.get(intent.key());
        if (newIntent == null) {
            log.info("simple fabric forwarding withdraw unicast intent: {}", intent.key().toString());
            toBePurgedIntentKeys.add(intent.key());
            intentService.withdraw(intent);
            uniUpdated = true;
        }
    }
    for (MultiPointToSinglePointIntent intent : newUniIntentsMap.values()) {
        MultiPointToSinglePointIntent oldIntent = uniIntentsMap.get(intent.key());
        if (oldIntent == null || !oldIntent.filteredEgressPoint().equals(intent.filteredEgressPoint()) || !oldIntent.filteredIngressPoints().equals(intent.filteredIngressPoints()) || !oldIntent.selector().equals(intent.selector()) || !oldIntent.treatment().equals(intent.treatment()) || !oldIntent.constraints().equals(intent.constraints())) {
            log.info("simple fabric forwarding submit unicast intent: {}", intent.key().toString());
            toBePurgedIntentKeys.remove(intent.key());
            intentService.submit(intent);
            uniUpdated = true;
        }
    }
    if (bctUpdated) {
        bctIntentsMap = newBctIntentsMap;
    }
    if (uniUpdated) {
        uniIntentsMap = newUniIntentsMap;
    }
}
Also used : SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) FabricNetwork(org.onosproject.simplefabric.api.FabricNetwork) Key(org.onosproject.net.intent.Key)

Example 13 with MultiPointToSinglePointIntent

use of org.onosproject.net.intent.MultiPointToSinglePointIntent in project onos by opennetworkinglab.

the class SimpleFabricForwarding method buildUniIntents.

// Builds unicast Intents for a L2 Network.
private Set<MultiPointToSinglePointIntent> buildUniIntents(FabricNetwork fabricNetwork, Set<Host> hosts) {
    Set<Interface> interfaces = fabricNetwork.interfaces();
    if (!fabricNetwork.isForward() || interfaces.size() < 2) {
        return ImmutableSet.of();
    }
    Set<MultiPointToSinglePointIntent> uniIntents = Sets.newHashSet();
    ResourceGroup resourceGroup = ResourceGroup.of(fabricNetwork.name());
    hosts.forEach(host -> {
        FilteredConnectPoint hostFcp = buildFilteredConnectedPoint(host);
        Set<FilteredConnectPoint> srcFcps = interfaces.stream().map(this::buildFilteredConnectedPoint).filter(fcp -> !fcp.equals(hostFcp)).collect(Collectors.toSet());
        Key key = buildKey(fabricNetwork.name(), "UNI", hostFcp.connectPoint(), host.mac());
        TrafficSelector selector = DefaultTrafficSelector.builder().matchEthDst(host.mac()).build();
        MultiPointToSinglePointIntent.Builder intentBuilder = MultiPointToSinglePointIntent.builder().appId(appId).key(key).selector(selector).filteredIngressPoints(srcFcps).filteredEgressPoint(hostFcp).constraints(buildConstraints(L2NETWORK_CONSTRAINTS, fabricNetwork.encapsulation())).priority(PRI_L2NETWORK_UNICAST).resourceGroup(resourceGroup);
        uniIntents.add(intentBuilder.build());
    });
    return uniIntents;
}
Also used : Host(org.onosproject.net.Host) Interface(org.onosproject.net.intf.Interface) FabricNetwork(org.onosproject.simplefabric.api.FabricNetwork) CoreService(org.onosproject.core.CoreService) LoggerFactory(org.slf4j.LoggerFactory) SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) HostService(org.onosproject.net.host.HostService) ConnectPoint(org.onosproject.net.ConnectPoint) EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Component(org.osgi.service.component.annotations.Component) SimpleFabricListener(org.onosproject.simplefabric.api.SimpleFabricListener) TrafficSelector(org.onosproject.net.flow.TrafficSelector) ImmutableList(com.google.common.collect.ImmutableList) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) IntentService(org.onosproject.net.intent.IntentService) SimpleFabricEvent(org.onosproject.simplefabric.api.SimpleFabricEvent) Map(java.util.Map) ApplicationId(org.onosproject.core.ApplicationId) Intent(org.onosproject.net.intent.Intent) PartialFailureConstraint(org.onosproject.net.intent.constraint.PartialFailureConstraint) Activate(org.osgi.service.component.annotations.Activate) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) ResourceGroup(org.onosproject.net.ResourceGroup) PRI_L2NETWORK_BROADCAST(org.onosproject.simplefabric.api.Constants.PRI_L2NETWORK_BROADCAST) SimpleFabricService(org.onosproject.simplefabric.api.SimpleFabricService) PrintStream(java.io.PrintStream) ImmutableSet(com.google.common.collect.ImmutableSet) Logger(org.slf4j.Logger) Deactivate(org.osgi.service.component.annotations.Deactivate) Collection(java.util.Collection) VlanId(org.onlab.packet.VlanId) Set(java.util.Set) FORWARDING_APP_ID(org.onosproject.simplefabric.api.Constants.FORWARDING_APP_ID) Maps(com.google.common.collect.Maps) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) Constraint(org.onosproject.net.intent.Constraint) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) Objects(java.util.Objects) Key(org.onosproject.net.intent.Key) List(java.util.List) EncapsulationType(org.onosproject.net.EncapsulationType) PRI_L2NETWORK_UNICAST(org.onosproject.simplefabric.api.Constants.PRI_L2NETWORK_UNICAST) MacAddress(org.onlab.packet.MacAddress) Reference(org.osgi.service.component.annotations.Reference) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) Interface(org.onosproject.net.intf.Interface) ResourceGroup(org.onosproject.net.ResourceGroup) Key(org.onosproject.net.intent.Key) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Example 14 with MultiPointToSinglePointIntent

use of org.onosproject.net.intent.MultiPointToSinglePointIntent in project onos by opennetworkinglab.

the class SimpleFabricRouting method dump.

// Dump Cli Handler
private void dump(String subject, PrintStream out) {
    if ("intents".equals(subject)) {
        out.println("Routing Route Intents:\n");
        for (Intent entry : intentService.getIntents()) {
            if (appId.equals(entry.appId())) {
                MultiPointToSinglePointIntent intent = (MultiPointToSinglePointIntent) entry;
                out.println("    " + intent.key().toString() + " to " + intent.egressPoint().toString() + " set " + intent.treatment().immediate().toString() + " from " + intent.ingressPoints().toString());
            }
        }
        out.println("");
        out.println("Routing Intercept Flow Rules:\n");
        List<FlowRule> rules = new ArrayList(interceptFlowRules);
        Collections.sort(rules, new Comparator<FlowRule>() {

            @Override
            public int compare(FlowRule a, FlowRule b) {
                int r = a.deviceId().toString().compareTo(b.deviceId().toString());
                // descending on priority
                return (r != 0) ? r : Integer.compare(b.priority(), a.priority());
            }
        });
        for (FlowRule rule : rules) {
            out.println("    device=" + rule.deviceId().toString() + " priority=" + rule.priority() + " selector=" + rule.selector().criteria().toString());
        }
        out.println("");
        out.println("Routing Intents to Be Purged:\n");
        for (Key key : toBePurgedIntentKeys) {
            out.println("    " + key.toString());
        }
        out.println("");
    } else if ("reactive-intents".equals(subject)) {
        for (Intent entry : intentService.getIntents()) {
            if (appId.equals(entry.appId())) {
                MultiPointToSinglePointIntent intent = (MultiPointToSinglePointIntent) entry;
                out.println(intent.key().toString() + " to " + intent.egressPoint().toString() + " set " + intent.treatment().immediate().toString() + " from " + intent.ingressPoints().toString());
            }
        }
    }
}
Also used : ArrayList(java.util.ArrayList) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) Intent(org.onosproject.net.intent.Intent) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) Key(org.onosproject.net.intent.Key)

Example 15 with MultiPointToSinglePointIntent

use of org.onosproject.net.intent.MultiPointToSinglePointIntent in project onos by opennetworkinglab.

the class SimpleFabricRouting method refreshRouteIntents.

/**
 * Refresh routes by examining network resource status.
 */
private void refreshRouteIntents() {
    for (Intent entry : intentService.getIntents()) {
        if (!appId.equals(entry.appId())) {
            continue;
        }
        MultiPointToSinglePointIntent intent = (MultiPointToSinglePointIntent) entry;
        if (!intentService.isLocal(intent.key())) {
            if (toBePurgedIntentKeys.contains(intent.key())) {
                // clear non local intent
                toBePurgedIntentKeys.remove(intent.key());
            }
            continue;
        }
        try {
            switch(intentService.getIntentState(intent.key())) {
                // case FAILED:   // failed intent is not auto removed
                case WITHDRAWN:
                    log.warn("intent found failed or withdrawn; " + "remove and try to purge intent: key={}", intent.key());
                    // purge intents here without withdraw
                    intentService.purge(intentService.getIntent(intent.key()));
                    toBePurgedIntentKeys.add(intent.key());
                    continue;
                default:
                    // no action
                    break;
            }
        } catch (Exception e) {
            log.warn("intent status lookup failed: error={}", e);
            // this intent seems invalid; no action
            continue;
        }
        // dummy loop to break on remove cases
        if (!deviceService.isAvailable(intent.egressPoint().deviceId())) {
            log.info("refresh route intents; remove intent for no device: key={}", intent.key());
            intentService.withdraw(intentService.getIntent(intent.key()));
            toBePurgedIntentKeys.add(intent.key());
            continue;
        }
        if (!(simpleFabric.fabricNetwork(intent.egressPoint(), VlanId.NONE) != null || (REACTIVE_ALLOW_LINK_CP && !linkService.getEgressLinks(intent.egressPoint()).isEmpty()))) {
            log.info("refresh route intents; remove intent for egress point not available: key={}", intent.key());
            intentService.withdraw(intentService.getIntent(intent.key()));
            toBePurgedIntentKeys.add(intent.key());
            continue;
        }
        // MAY NEED TO CHECK: intent.egressPoint and intent.treatment's dstMac is valid against hosts
        if (REACTIVE_SINGLE_TO_SINGLE && !REACTIVE_ALLOW_LINK_CP) {
            // single path intent only; no need to check ingress points
            continue;
        }
        Set<FilteredConnectPoint> newIngressPoints = new HashSet<>();
        boolean ingressPointChanged = false;
        for (FilteredConnectPoint cp : intent.filteredIngressPoints()) {
            if (deviceService.isAvailable(cp.connectPoint().deviceId()) && (simpleFabric.fabricNetwork(cp.connectPoint(), VlanId.NONE) != null || (REACTIVE_ALLOW_LINK_CP && !linkService.getIngressLinks(cp.connectPoint()).isEmpty()))) {
                newIngressPoints.add(cp);
            } else {
                log.info("refresh route ingress cp of " + "not in 2Networks nor links: {}", cp);
                ingressPointChanged = true;
            }
        }
        if (newIngressPoints.isEmpty()) {
            log.info("refresh route intents; " + "remove intent for no ingress nor egress point available: key={}", intent.key());
            intentService.withdraw(intentService.getIntent(intent.key()));
            toBePurgedIntentKeys.add(intent.key());
            continue;
        }
        // update ingress points
        if (ingressPointChanged) {
            MultiPointToSinglePointIntent updatedIntent = MultiPointToSinglePointIntent.builder().appId(appId).key(intent.key()).selector(intent.selector()).treatment(intent.treatment()).filteredIngressPoints(newIngressPoints).filteredEgressPoint(intent.filteredEgressPoint()).priority(intent.priority()).constraints(intent.constraints()).build();
            log.info("refresh route update intent: key={} updatedIntent={}", intent.key(), updatedIntent);
            // may remove from old purged entry
            toBePurgedIntentKeys.remove(intent.key());
            intentService.submit(updatedIntent);
        }
    }
}
Also used : MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) Intent(org.onosproject.net.intent.Intent) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) HashSet(java.util.HashSet)

Aggregations

MultiPointToSinglePointIntent (org.onosproject.net.intent.MultiPointToSinglePointIntent)52 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)31 ConnectPoint (org.onosproject.net.ConnectPoint)25 Test (org.junit.Test)21 TrafficSelector (org.onosproject.net.flow.TrafficSelector)21 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)20 AbstractIntentTest (org.onosproject.net.intent.AbstractIntentTest)20 Intent (org.onosproject.net.intent.Intent)16 Key (org.onosproject.net.intent.Key)14 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)12 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)12 LinkCollectionIntent (org.onosproject.net.intent.LinkCollectionIntent)11 HashSet (java.util.HashSet)10 Constraint (org.onosproject.net.intent.Constraint)9 PartialFailureConstraint (org.onosproject.net.intent.constraint.PartialFailureConstraint)9 Interface (org.onosproject.net.intf.Interface)9 Map (java.util.Map)8 IpPrefix (org.onlab.packet.IpPrefix)8 MacAddress (org.onlab.packet.MacAddress)8 ResolvedRoute (org.onosproject.routeservice.ResolvedRoute)6