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