Search in sources :

Example 1 with SinglePointToMultiPointIntent

use of org.onosproject.net.intent.SinglePointToMultiPointIntent 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 2 with SinglePointToMultiPointIntent

use of org.onosproject.net.intent.SinglePointToMultiPointIntent 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 3 with SinglePointToMultiPointIntent

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

the class SimpleFabricForwarding method buildBrcIntents.

// Build Boadcast Intents for a L2 Network.
private Set<SinglePointToMultiPointIntent> buildBrcIntents(FabricNetwork fabricNetwork) {
    Set<Interface> interfaces = fabricNetwork.interfaces();
    if (interfaces.size() < 2 || !fabricNetwork.isForward() || !fabricNetwork.isBroadcast()) {
        return ImmutableSet.of();
    }
    Set<SinglePointToMultiPointIntent> brcIntents = Sets.newHashSet();
    ResourceGroup resourceGroup = ResourceGroup.of(fabricNetwork.name());
    // Generates broadcast Intents from any network interface to other
    // network interface from the L2 Network.
    interfaces.forEach(src -> {
        FilteredConnectPoint srcFcp = buildFilteredConnectedPoint(src);
        Set<FilteredConnectPoint> dstFcps = interfaces.stream().filter(iface -> !iface.equals(src)).map(this::buildFilteredConnectedPoint).collect(Collectors.toSet());
        Key key = buildKey(fabricNetwork.name(), "BCAST", srcFcp.connectPoint(), MacAddress.BROADCAST);
        TrafficSelector selector = DefaultTrafficSelector.builder().matchEthDst(MacAddress.BROADCAST).build();
        SinglePointToMultiPointIntent.Builder intentBuilder = SinglePointToMultiPointIntent.builder().appId(appId).key(key).selector(selector).filteredIngressPoint(srcFcp).filteredEgressPoints(dstFcps).constraints(buildConstraints(L2NETWORK_CONSTRAINTS, fabricNetwork.encapsulation())).priority(PRI_L2NETWORK_BROADCAST).resourceGroup(resourceGroup);
        brcIntents.add(intentBuilder.build());
    });
    return brcIntents;
}
Also used : SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) Interface(org.onosproject.net.intf.Interface) ResourceGroup(org.onosproject.net.ResourceGroup) Key(org.onosproject.net.intent.Key) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Example 4 with SinglePointToMultiPointIntent

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

the class VplsIntentUtility method buildBrcIntent.

/**
 * Builds a broadcast intent.
 *
 * @param key key to identify the intent
 * @param appId application ID for this Intent
 * @param src the source connect point
 * @param dsts the destination connect points
 * @param encap the encapsulation type
 * @param resourceGroup resource group for this Intent
 * @return the generated single-point to multi-point intent
 */
static SinglePointToMultiPointIntent buildBrcIntent(Key key, ApplicationId appId, FilteredConnectPoint src, Set<FilteredConnectPoint> dsts, EncapsulationType encap, ResourceGroup resourceGroup) {
    log.debug("Building broadcast intent {} for source {}", SP2MP, src);
    SinglePointToMultiPointIntent.Builder intentBuilder;
    TrafficSelector selector = DefaultTrafficSelector.builder().matchEthDst(MacAddress.BROADCAST).build();
    intentBuilder = SinglePointToMultiPointIntent.builder().appId(appId).key(key).selector(selector).filteredIngressPoint(src).filteredEgressPoints(dsts).constraints(PARTIAL_FAILURE_CONSTRAINT).priority(PRIORITY_OFFSET + PRIORITY_BRC).resourceGroup(resourceGroup);
    setEncap(intentBuilder, PARTIAL_FAILURE_CONSTRAINT, encap);
    return intentBuilder.build();
}
Also used : SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector)

Example 5 with SinglePointToMultiPointIntent

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

the class SinglePointToMultiPointIntentCodec method decode.

@Override
public SinglePointToMultiPointIntent decode(ObjectNode json, CodecContext context) {
    SinglePointToMultiPointIntent.Builder builder = SinglePointToMultiPointIntent.builder();
    IntentCodec.intentAttributes(json, context, builder);
    ConnectivityIntentCodec.intentAttributes(json, context, builder);
    ObjectNode ingressJson = nullIsIllegal(get(json, INGRESS_POINT), INGRESS_POINT + IntentCodec.MISSING_MEMBER_MESSAGE);
    ConnectPoint ingress = context.codec(ConnectPoint.class).decode(ingressJson, context);
    builder.filteredIngressPoint(new FilteredConnectPoint(ingress));
    ArrayNode egressJson = nullIsIllegal((ArrayNode) json.get(EGRESS_POINT), EGRESS_POINT + IntentCodec.MISSING_MEMBER_MESSAGE);
    final JsonCodec<ConnectPoint> connectPointCodec = context.codec(ConnectPoint.class);
    Set<FilteredConnectPoint> egressCp = new HashSet<>();
    for (int i = 0; i < egressJson.size(); i++) {
        ConnectPoint cp = connectPointCodec.decode(get(egressJson, i), context);
        egressCp.add(new FilteredConnectPoint(cp));
    }
    builder.filteredEgressPoints(egressCp);
    return builder.build();
}
Also used : SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) HashSet(java.util.HashSet)

Aggregations

SinglePointToMultiPointIntent (org.onosproject.net.intent.SinglePointToMultiPointIntent)19 ConnectPoint (org.onosproject.net.ConnectPoint)14 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)14 Intent (org.onosproject.net.intent.Intent)11 Test (org.junit.Test)10 LinkCollectionIntent (org.onosproject.net.intent.LinkCollectionIntent)10 AbstractIntentTest (org.onosproject.net.intent.AbstractIntentTest)9 TrafficSelector (org.onosproject.net.flow.TrafficSelector)8 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)6 Key (org.onosproject.net.intent.Key)6 MultiPointToSinglePointIntent (org.onosproject.net.intent.MultiPointToSinglePointIntent)4 HashSet (java.util.HashSet)3 List (java.util.List)3 Set (java.util.Set)3 Collectors (java.util.stream.Collectors)3 Constraint (org.onosproject.net.intent.Constraint)3 IntentService (org.onosproject.net.intent.IntentService)3 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 ImmutableSet (com.google.common.collect.ImmutableSet)2