Search in sources :

Example 11 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 12 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 13 with SinglePointToMultiPointIntent

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

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

the class AddSinglePointToMultiPointIntentCommand method doExecute.

@Override
protected void doExecute() {
    IntentService service = get(IntentService.class);
    if (deviceStrings.length < 2) {
        return;
    }
    String ingressDeviceString = deviceStrings[0];
    ConnectPoint ingressPoint = ConnectPoint.deviceConnectPoint(ingressDeviceString);
    Set<FilteredConnectPoint> egressPoints = new HashSet<>();
    for (int index = 1; index < deviceStrings.length; index++) {
        String egressDeviceString = deviceStrings[index];
        ConnectPoint egress = ConnectPoint.deviceConnectPoint(egressDeviceString);
        egressPoints.add(new FilteredConnectPoint(egress));
    }
    TrafficSelector selector = buildTrafficSelector();
    TrafficTreatment treatment = buildTrafficTreatment();
    List<Constraint> constraints = buildConstraints();
    SinglePointToMultiPointIntent intent = SinglePointToMultiPointIntent.builder().appId(appId()).key(key()).selector(selector).treatment(treatment).filteredIngressPoint(new FilteredConnectPoint(ingressPoint)).filteredEgressPoints(egressPoints).constraints(constraints).priority(priority()).resourceGroup(resourceGroup()).build();
    service.submit(intent);
    print("Single point to multipoint intent submitted:\n%s", intent.toString());
}
Also used : IntentService(org.onosproject.net.intent.IntentService) SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) Constraint(org.onosproject.net.intent.Constraint) TrafficSelector(org.onosproject.net.flow.TrafficSelector) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) Constraint(org.onosproject.net.intent.Constraint) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) HashSet(java.util.HashSet)

Example 15 with SinglePointToMultiPointIntent

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

the class SinglePointToMultiPointIntentCompilerTest method testMultiEgressCompilation.

/**
 * Tests multiple egress points that share a common path to the ingress
 * point.
 */
@Test
public void testMultiEgressCompilation() {
    FilteredConnectPoint ingress = new FilteredConnectPoint(new ConnectPoint(DID_1, PORT_1));
    FilteredConnectPoint egressOne = new FilteredConnectPoint(new ConnectPoint(DID_3, PORT_2));
    FilteredConnectPoint egressTwo = new FilteredConnectPoint(new ConnectPoint(DID_4, PORT_2));
    FilteredConnectPoint egressThree = new FilteredConnectPoint(new ConnectPoint(DID_5, PORT_2));
    Set<FilteredConnectPoint> egress = Sets.newHashSet(egressOne, egressTwo, egressThree);
    SinglePointToMultiPointIntent intent = makeIntent(ingress, egress);
    assertThat(intent, is(notNullValue()));
    final String[] hops = { S2 };
    SinglePointToMultiPointIntentCompiler compiler = makeCompiler(hops);
    assertThat(compiler, is(notNullValue()));
    List<Intent> result = compiler.compile(intent, null);
    assertThat(result, is(notNullValue()));
    assertThat(result, hasSize(1));
    Intent resultIntent = result.get(0);
    assertThat(resultIntent instanceof LinkCollectionIntent, is(true));
    if (resultIntent instanceof LinkCollectionIntent) {
        LinkCollectionIntent linkIntent = (LinkCollectionIntent) resultIntent;
        assertThat(linkIntent.links(), hasSize(4));
        assertThat(linkIntent.links(), linksHasPath(S1, S2));
        assertThat(linkIntent.links(), linksHasPath(S2, S3));
        assertThat(linkIntent.links(), linksHasPath(S2, S4));
        assertThat(linkIntent.links(), linksHasPath(S2, S5));
    }
    assertThat("key is inherited", resultIntent.key(), is(intent.key()));
}
Also used : SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) Intent(org.onosproject.net.intent.Intent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Aggregations

SinglePointToMultiPointIntent (org.onosproject.net.intent.SinglePointToMultiPointIntent)22 ConnectPoint (org.onosproject.net.ConnectPoint)14 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)14 Intent (org.onosproject.net.intent.Intent)13 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 Key (org.onosproject.net.intent.Key)7 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)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