Search in sources :

Example 11 with PointToPointIntent

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

the class PointToPointIntentCompilerTest method testTwoBandwidthConstrainedIntentAllocation.

/**
 * Tests that bandwidth resources don't get allocated twice if the intent
 * is submitted twice.
 */
@Test
public void testTwoBandwidthConstrainedIntentAllocation() {
    final double bpsTotal = 1000.0;
    String[] hops = { S1, S2, S3 };
    final ResourceService resourceService = MockResourceService.makeCustomBandwidthResourceService(bpsTotal);
    final List<Constraint> constraints = Collections.singletonList(new BandwidthConstraint(Bandwidth.bps(BPS_TO_RESERVE)));
    final PointToPointIntent intent = makeIntent(new ConnectPoint(DID_1, PORT_1), new ConnectPoint(DID_3, PORT_2), constraints);
    PointToPointIntentCompiler compiler = makeCompiler(hops, resourceService);
    compiler.compile(intent, null);
    // Resubmit the same intent
    compiler.compile(intent, null);
    Key intentKey = intent.key();
    ResourceAllocation rAOne = new ResourceAllocation(RESOURCE_SW1_P1, intentKey);
    ResourceAllocation rATwo = new ResourceAllocation(RESOURCE_SW1_P2, intentKey);
    ResourceAllocation rAThree = new ResourceAllocation(RESOURCE_SW2_P1, intentKey);
    ResourceAllocation rAFour = new ResourceAllocation(RESOURCE_SW2_P2, intentKey);
    ResourceAllocation rAFive = new ResourceAllocation(RESOURCE_SW3_P1, intentKey);
    ResourceAllocation rASix = new ResourceAllocation(RESOURCE_SW3_P2, intentKey);
    Set<ResourceAllocation> expectedresourceAllocations = ImmutableSet.of(rAOne, rATwo, rAThree, rAFour, rAFive, rASix);
    Set<ResourceAllocation> resourceAllocations = ImmutableSet.copyOf(resourceService.getResourceAllocations(intentKey));
    assertThat(resourceAllocations, hasSize(6));
    assertEquals(expectedresourceAllocations, resourceAllocations);
}
Also used : Constraint(org.onosproject.net.intent.Constraint) BandwidthConstraint(org.onosproject.net.intent.constraint.BandwidthConstraint) ResourceService(org.onosproject.net.resource.ResourceService) MockResourceService(org.onosproject.net.resource.MockResourceService) PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) ResourceAllocation(org.onosproject.net.resource.ResourceAllocation) Key(org.onosproject.net.intent.Key) BandwidthConstraint(org.onosproject.net.intent.constraint.BandwidthConstraint) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Example 12 with PointToPointIntent

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

the class PointToPointIntentCompilerTest method testSuggestedPathBandwidthConstrainedIntentSuccess.

/**
 * Tests that requests with suggested path
 * and with sufficient available bandwidth succeed.
 */
@Test
public void testSuggestedPathBandwidthConstrainedIntentSuccess() {
    final double bpsTotal = 1000.0;
    final double bpsToReserve = 100.0;
    final ResourceService resourceService = MockResourceService.makeCustomBandwidthResourceService(bpsTotal);
    final List<Constraint> constraints = Collections.singletonList(new BandwidthConstraint(Bandwidth.bps(bpsToReserve)));
    String[] suggestedPathHops = { S1, S4, S5, S3 };
    List<Link> suggestedPath = NetTestTools.createPath(suggestedPathHops).links();
    final PointToPointIntent intent = makeIntentSuggestedPath(new ConnectPoint(DID_1, PORT_1), new ConnectPoint(DID_3, PORT_2), suggestedPath, constraints);
    String[][] hops = { { S1, S2, S3 }, suggestedPathHops };
    final PointToPointIntentCompiler compiler = makeCompilerSuggestedPath(hops, resourceService);
    final List<Intent> compiledIntents = compiler.compile(intent, null);
    assertThat(compiledIntents, Matchers.notNullValue());
    assertThat(compiledIntents, hasSize(1));
    assertThat("key is inherited", compiledIntents.stream().map(Intent::key).collect(Collectors.toList()), everyItem(is(intent.key())));
}
Also used : Constraint(org.onosproject.net.intent.Constraint) BandwidthConstraint(org.onosproject.net.intent.constraint.BandwidthConstraint) ResourceService(org.onosproject.net.resource.ResourceService) MockResourceService(org.onosproject.net.resource.MockResourceService) PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) Intent(org.onosproject.net.intent.Intent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) Link(org.onosproject.net.Link) BandwidthConstraint(org.onosproject.net.intent.constraint.BandwidthConstraint) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Example 13 with PointToPointIntent

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

the class AbstractIntentInstallerTest method createP2PIntent.

/**
 * Creates point to point Intent for test.
 *
 * @return the point to point Intent
 */
public PointToPointIntent createP2PIntent() {
    PointToPointIntent intent;
    TrafficSelector selector = DefaultTrafficSelector.emptySelector();
    TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
    FilteredConnectPoint ingress = new FilteredConnectPoint(CP1);
    FilteredConnectPoint egress = new FilteredConnectPoint(CP2);
    intent = PointToPointIntent.builder().selector(selector).treatment(treatment).filteredIngressPoint(ingress).filteredEgressPoint(egress).appId(APP_ID).build();
    return intent;
}
Also used : PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Example 14 with PointToPointIntent

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

the class AbstractIntentInstallerTest method createP2PIntentNonDisruptive.

/**
 * Creates point to point Intent for testing non-disruptive reallocation.
 *
 * @return the point to point Intent
 */
public PointToPointIntent createP2PIntentNonDisruptive() {
    PointToPointIntent intent;
    TrafficSelector selector = DefaultTrafficSelector.emptySelector();
    TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
    FilteredConnectPoint ingress = new FilteredConnectPoint(CP1);
    FilteredConnectPoint egress = new FilteredConnectPoint(CP4_1);
    List<Constraint> constraints = ImmutableList.of(nonDisruptive());
    intent = PointToPointIntent.builder().selector(selector).treatment(treatment).filteredIngressPoint(ingress).filteredEgressPoint(egress).constraints(constraints).appId(APP_ID).build();
    return intent;
}
Also used : Constraint(org.onosproject.net.intent.Constraint) PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Example 15 with PointToPointIntent

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

the class PeerConnectivityManager method buildIntents.

/**
 * Builds the required intents between a BGP speaker and an external router.
 *
 * @param portOne the BGP speaker connect point
 * @param vlanOne the BGP speaker VLAN
 * @param ipOne the BGP speaker IP address
 * @param portTwo the external BGP peer connect point
 * @param vlanTwo the external BGP peer VLAN
 * @param ipTwo the external BGP peer IP address
 * @param encap the encapsulation type
 * @return the intents to install
 */
private Collection<PointToPointIntent> buildIntents(ConnectPoint portOne, VlanId vlanOne, IpAddress ipOne, ConnectPoint portTwo, VlanId vlanTwo, IpAddress ipTwo, EncapsulationType encap) {
    List<PointToPointIntent> intents = new ArrayList<>();
    TrafficTreatment.Builder treatmentToPeer = DefaultTrafficTreatment.builder();
    TrafficTreatment.Builder treatmentToSpeaker = DefaultTrafficTreatment.builder();
    PointToPointIntent.Builder intentBuilder;
    TrafficSelector selector;
    Key key;
    byte tcpProtocol;
    byte icmpProtocol;
    if (ipOne.isIp4()) {
        tcpProtocol = IPv4.PROTOCOL_TCP;
        icmpProtocol = IPv4.PROTOCOL_ICMP;
    } else {
        tcpProtocol = IPv6.PROTOCOL_TCP;
        icmpProtocol = IPv6.PROTOCOL_ICMP6;
    }
    // Add VLAN treatment for traffic going from BGP speaker to BGP peer
    treatmentToPeer = applyVlanTreatment(vlanOne, vlanTwo, treatmentToPeer);
    // Path from BGP speaker to BGP peer matching destination TCP port 179
    selector = buildSelector(tcpProtocol, vlanOne, ipOne, ipTwo, null, BGP_PORT);
    key = buildKey(ipOne, ipTwo, SUFFIX_DST);
    intentBuilder = PointToPointIntent.builder().appId(appId).key(key).filteredIngressPoint(new FilteredConnectPoint(portOne)).filteredEgressPoint(new FilteredConnectPoint(portTwo)).selector(selector).treatment(treatmentToPeer.build()).priority(PRIORITY_OFFSET);
    encap(intentBuilder, encap);
    intents.add(intentBuilder.build());
    // Path from BGP speaker to BGP peer matching source TCP port 179
    selector = buildSelector(tcpProtocol, vlanOne, ipOne, ipTwo, BGP_PORT, null);
    key = buildKey(ipOne, ipTwo, SUFFIX_SRC);
    intentBuilder = PointToPointIntent.builder().appId(appId).key(key).filteredIngressPoint(new FilteredConnectPoint(portOne)).filteredEgressPoint(new FilteredConnectPoint(portTwo)).selector(selector).treatment(treatmentToPeer.build()).priority(PRIORITY_OFFSET);
    encap(intentBuilder, encap);
    intents.add(intentBuilder.build());
    // ICMP path from BGP speaker to BGP peer
    selector = buildSelector(icmpProtocol, vlanOne, ipOne, ipTwo, null, null);
    key = buildKey(ipOne, ipTwo, SUFFIX_ICMP);
    intentBuilder = PointToPointIntent.builder().appId(appId).key(key).filteredIngressPoint(new FilteredConnectPoint(portOne)).filteredEgressPoint(new FilteredConnectPoint(portTwo)).selector(selector).treatment(treatmentToPeer.build()).priority(PRIORITY_OFFSET);
    encap(intentBuilder, encap);
    intents.add(intentBuilder.build());
    // Add VLAN treatment for traffic going from BGP peer to BGP speaker
    treatmentToSpeaker = applyVlanTreatment(vlanTwo, vlanOne, treatmentToSpeaker);
    // Path from BGP peer to BGP speaker matching destination TCP port 179
    selector = buildSelector(tcpProtocol, vlanTwo, ipTwo, ipOne, null, BGP_PORT);
    key = buildKey(ipTwo, ipOne, SUFFIX_DST);
    intentBuilder = PointToPointIntent.builder().appId(appId).key(key).filteredIngressPoint(new FilteredConnectPoint(portTwo)).filteredEgressPoint(new FilteredConnectPoint(portOne)).selector(selector).treatment(treatmentToSpeaker.build()).priority(PRIORITY_OFFSET);
    encap(intentBuilder, encap);
    intents.add(intentBuilder.build());
    // Path from BGP peer to BGP speaker matching source TCP port 179
    selector = buildSelector(tcpProtocol, vlanTwo, ipTwo, ipOne, BGP_PORT, null);
    key = buildKey(ipTwo, ipOne, SUFFIX_SRC);
    intentBuilder = PointToPointIntent.builder().appId(appId).key(key).filteredIngressPoint(new FilteredConnectPoint(portTwo)).filteredEgressPoint(new FilteredConnectPoint(portOne)).selector(selector).treatment(treatmentToSpeaker.build()).priority(PRIORITY_OFFSET);
    encap(intentBuilder, encap);
    intents.add(intentBuilder.build());
    // ICMP path from BGP peer to BGP speaker
    selector = buildSelector(icmpProtocol, vlanTwo, ipTwo, ipOne, null, null);
    key = buildKey(ipTwo, ipOne, SUFFIX_ICMP);
    intentBuilder = PointToPointIntent.builder().appId(appId).key(key).filteredIngressPoint(new FilteredConnectPoint(portTwo)).filteredEgressPoint(new FilteredConnectPoint(portOne)).selector(selector).treatment(treatmentToSpeaker.build()).priority(PRIORITY_OFFSET);
    encap(intentBuilder, encap);
    intents.add(intentBuilder.build());
    return intents;
}
Also used : PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) ArrayList(java.util.ArrayList) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) Key(org.onosproject.net.intent.Key) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Aggregations

PointToPointIntent (org.onosproject.net.intent.PointToPointIntent)48 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)28 ConnectPoint (org.onosproject.net.ConnectPoint)24 Intent (org.onosproject.net.intent.Intent)19 Test (org.junit.Test)18 AbstractIntentTest (org.onosproject.net.intent.AbstractIntentTest)16 LinkCollectionIntent (org.onosproject.net.intent.LinkCollectionIntent)16 TrafficSelector (org.onosproject.net.flow.TrafficSelector)13 Key (org.onosproject.net.intent.Key)13 ArrayList (java.util.ArrayList)12 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)12 Link (org.onosproject.net.Link)11 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)11 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)11 Constraint (org.onosproject.net.intent.Constraint)11 FlowRuleIntent (org.onosproject.net.intent.FlowRuleIntent)10 BandwidthConstraint (org.onosproject.net.intent.constraint.BandwidthConstraint)10 PathIntent (org.onosproject.net.intent.PathIntent)8 MockResourceService (org.onosproject.net.resource.MockResourceService)8 ResourceService (org.onosproject.net.resource.ResourceService)8