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);
}
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()));
}
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()));
}
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("");
}
}
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;
}
Aggregations