Search in sources :

Example 6 with SinglePointToMultiPointIntent

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

the class SinglePointToMultiPointIntentCompilerTest method testPartialFailureConstraintFailure.

/**
 * Tests if compiling an intent without partial failure constraints set and
 * with a missing egress connect point generates an exception and no other
 * results.
 */
@Test
public void testPartialFailureConstraintFailure() {
    FilteredConnectPoint ingress = new FilteredConnectPoint(new ConnectPoint(DID_1, PORT_1));
    Set<FilteredConnectPoint> egress = ImmutableSet.of(new FilteredConnectPoint(new ConnectPoint(DID_4, PORT_2)), new FilteredConnectPoint(new ConnectPoint(DID_5, PORT_2)));
    SinglePointToMultiPointIntent intent = makeIntent(ingress, egress);
    String[] hops = { S3 };
    SinglePointToMultiPointIntentCompiler compiler = makeCompiler(null, new IntentTestsMocks.FixedMP2MPMockPathService(hops), null);
    assertThat(compiler, is(notNullValue()));
    intentException.expect(IntentException.class);
    List<Intent> result = compiler.compile(intent, null);
    assertThat(result, null);
}
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) IntentTestsMocks(org.onosproject.net.intent.IntentTestsMocks) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Example 7 with SinglePointToMultiPointIntent

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

the class SinglePointToMultiPointIntentCompilerTest method testFilteredConnectPointIntent.

/**
 * Tests filtered ingress and egress connect points.
 */
@Test
public void testFilteredConnectPointIntent() {
    FilteredConnectPoint ingress = new FilteredConnectPoint(new ConnectPoint(DID_1, PORT_1));
    Set<FilteredConnectPoint> egress = ImmutableSet.of(new FilteredConnectPoint(new ConnectPoint(DID_3, PORT_1), DefaultTrafficSelector.builder().matchVlanId(VlanId.vlanId("100")).build()), new FilteredConnectPoint(new ConnectPoint(DID_4, PORT_1), DefaultTrafficSelector.builder().matchVlanId(VlanId.vlanId("200")).build()));
    SinglePointToMultiPointIntent intent = makeIntent(ingress, egress, selector);
    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.class));
    if (resultIntent instanceof LinkCollectionIntent) {
        LinkCollectionIntent linkIntent = (LinkCollectionIntent) resultIntent;
        assertThat(linkIntent.links(), hasSize(3));
        assertThat(linkIntent.links(), linksHasPath(S1, S2));
        assertThat(linkIntent.links(), linksHasPath(S2, S3));
        assertThat(linkIntent.links(), linksHasPath(S2, S4));
        Set<FilteredConnectPoint> ingressPoints = linkIntent.filteredIngressPoints();
        assertThat("Link collection ingress points do not match base intent", ingressPoints.size() == 1 && ingressPoints.contains(intent.filteredIngressPoint()));
        assertThat("Link collection egress points do not match base intent", linkIntent.filteredEgressPoints().equals(intent.filteredEgressPoints()));
    }
    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)

Example 8 with SinglePointToMultiPointIntent

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

the class SinglePointToMultiPointIntentCompilerTest method testNonTrivialSelectorsIntent.

/**
 * Tests filtered ingress and egress points with an intent selector set.
 */
@Test
public void testNonTrivialSelectorsIntent() {
    FilteredConnectPoint ingress = new FilteredConnectPoint(new ConnectPoint(DID_1, PORT_1));
    Set<FilteredConnectPoint> egress = ImmutableSet.of(new FilteredConnectPoint(new ConnectPoint(DID_3, PORT_1), DefaultTrafficSelector.builder().matchVlanId(VlanId.vlanId("100")).build()), new FilteredConnectPoint(new ConnectPoint(DID_4, PORT_1), DefaultTrafficSelector.builder().matchVlanId(VlanId.vlanId("200")).build()));
    TrafficSelector ipPrefixSelector = DefaultTrafficSelector.builder().matchIPDst(IpPrefix.valueOf("192.168.100.0/24")).build();
    SinglePointToMultiPointIntent intent = makeIntent(ingress, egress, ipPrefixSelector);
    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.class));
    if (resultIntent instanceof LinkCollectionIntent) {
        LinkCollectionIntent linkIntent = (LinkCollectionIntent) resultIntent;
        assertThat(linkIntent.links(), hasSize(3));
        assertThat(linkIntent.links(), linksHasPath(S1, S2));
        assertThat(linkIntent.links(), linksHasPath(S2, S3));
        assertThat(linkIntent.links(), linksHasPath(S2, S4));
        Set<FilteredConnectPoint> ingressPoints = linkIntent.filteredIngressPoints();
        assertThat("Link collection ingress points do not match base intent", ingressPoints.size() == 1 && ingressPoints.contains(intent.filteredIngressPoint()));
        assertThat("Link collection egress points do not match base intent", linkIntent.filteredEgressPoints().equals(intent.filteredEgressPoints()));
        assertThat(linkIntent.selector(), is(ipPrefixSelector));
    }
    assertThat("key is inherited", resultIntent.key(), is(intent.key()));
}
Also used : SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) 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)

Example 9 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 10 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)

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