use of org.onosproject.net.ResourceGroup in project onos by opennetworkinglab.
the class SimpleFabricForwarding method buildUniIntents.
// Builds unicast Intents for a L2 Network.
private Set<MultiPointToSinglePointIntent> buildUniIntents(FabricNetwork fabricNetwork, Set<Host> hosts) {
Set<Interface> interfaces = fabricNetwork.interfaces();
if (!fabricNetwork.isForward() || interfaces.size() < 2) {
return ImmutableSet.of();
}
Set<MultiPointToSinglePointIntent> uniIntents = Sets.newHashSet();
ResourceGroup resourceGroup = ResourceGroup.of(fabricNetwork.name());
hosts.forEach(host -> {
FilteredConnectPoint hostFcp = buildFilteredConnectedPoint(host);
Set<FilteredConnectPoint> srcFcps = interfaces.stream().map(this::buildFilteredConnectedPoint).filter(fcp -> !fcp.equals(hostFcp)).collect(Collectors.toSet());
Key key = buildKey(fabricNetwork.name(), "UNI", hostFcp.connectPoint(), host.mac());
TrafficSelector selector = DefaultTrafficSelector.builder().matchEthDst(host.mac()).build();
MultiPointToSinglePointIntent.Builder intentBuilder = MultiPointToSinglePointIntent.builder().appId(appId).key(key).selector(selector).filteredIngressPoints(srcFcps).filteredEgressPoint(hostFcp).constraints(buildConstraints(L2NETWORK_CONSTRAINTS, fabricNetwork.encapsulation())).priority(PRI_L2NETWORK_UNICAST).resourceGroup(resourceGroup);
uniIntents.add(intentBuilder.build());
});
return uniIntents;
}
use of org.onosproject.net.ResourceGroup 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;
}
use of org.onosproject.net.ResourceGroup in project onos by opennetworkinglab.
the class PointToPointIntentCompilerTest method testRGBandwidthConstrainedIntentAllocation.
/**
* Tests if bandwidth resources get allocated correctly using the resource
* group. An intent with a resource group is submitted.
*/
@Test
public void testRGBandwidthConstrainedIntentAllocation() {
final double bpsTotal = 1000.0;
ResourceGroup resourceGroup = ResourceGroup.of(100);
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, resourceGroup);
PointToPointIntentCompiler compiler = makeCompiler(hops, resourceService);
compiler.compile(intent, null);
ResourceAllocation rAOne = new ResourceAllocation(RESOURCE_SW1_P1, resourceGroup);
ResourceAllocation rATwo = new ResourceAllocation(RESOURCE_SW1_P2, resourceGroup);
ResourceAllocation rAThree = new ResourceAllocation(RESOURCE_SW2_P1, resourceGroup);
ResourceAllocation rAFour = new ResourceAllocation(RESOURCE_SW2_P2, resourceGroup);
ResourceAllocation rAFive = new ResourceAllocation(RESOURCE_SW3_P1, resourceGroup);
ResourceAllocation rASix = new ResourceAllocation(RESOURCE_SW3_P2, resourceGroup);
Set<ResourceAllocation> expectedresourceAllocations = ImmutableSet.of(rAOne, rATwo, rAThree, rAFour, rAFive, rASix);
Set<ResourceAllocation> resourceAllocations = ImmutableSet.copyOf(resourceService.getResourceAllocations(resourceGroup));
assertThat(resourceAllocations, hasSize(6));
assertEquals(expectedresourceAllocations, resourceAllocations);
}
use of org.onosproject.net.ResourceGroup in project onos by opennetworkinglab.
the class VplsIntentUtility method buildBrcIntents.
/**
* Builds broadcast Intents for a VPLS.
*
* @param vplsData the VPLS
* @param appId the application id for Intents
* @return broadcast Intents for the VPLS
*/
public static Set<Intent> buildBrcIntents(VplsData vplsData, ApplicationId appId) {
Set<Interface> interfaces = vplsData.interfaces();
// At least two or more network interfaces to build broadcast Intents
if (interfaces.size() < 2) {
return ImmutableSet.of();
}
Set<Intent> brcIntents = Sets.newHashSet();
ResourceGroup resourceGroup = ResourceGroup.of(vplsData.name());
// Generates broadcast Intents from any network interface to other
// network interface from the VPLS.
interfaces.forEach(src -> {
FilteredConnectPoint srcFcp = VplsIntentUtility.buildFilteredConnectedPoint(src);
Set<FilteredConnectPoint> dstFcps = interfaces.stream().filter(iface -> !iface.equals(src)).map(VplsIntentUtility::buildFilteredConnectedPoint).collect(Collectors.toSet());
Key key = VplsIntentUtility.buildKey(PREFIX_BROADCAST, srcFcp.connectPoint(), vplsData.name(), MacAddress.BROADCAST, appId);
Intent brcIntent = buildBrcIntent(key, appId, srcFcp, dstFcps, vplsData.encapsulationType(), resourceGroup);
brcIntents.add(brcIntent);
});
return brcIntents;
}
use of org.onosproject.net.ResourceGroup in project onos by opennetworkinglab.
the class VplsIntentUtility method buildUniIntents.
/**
* Builds unicast Intents for a VPLS.
*
* @param vplsData the VPLS
* @param hosts the hosts of the VPLS
* @param appId application ID for Intents
* @return unicast Intents for the VPLS
*/
public static Set<Intent> buildUniIntents(VplsData vplsData, Set<Host> hosts, ApplicationId appId) {
Set<Interface> interfaces = vplsData.interfaces();
if (interfaces.size() < 2) {
return ImmutableSet.of();
}
Set<Intent> uniIntents = Sets.newHashSet();
ResourceGroup resourceGroup = ResourceGroup.of(vplsData.name());
hosts.forEach(host -> {
FilteredConnectPoint hostFcp = buildFilteredConnectedPoint(host);
Set<FilteredConnectPoint> srcFcps = interfaces.stream().map(VplsIntentUtility::buildFilteredConnectedPoint).filter(fcp -> !fcp.equals(hostFcp)).collect(Collectors.toSet());
Key key = buildKey(PREFIX_UNICAST, hostFcp.connectPoint(), vplsData.name(), host.mac(), appId);
Intent uniIntent = buildUniIntent(key, appId, srcFcps, hostFcp, host, vplsData.encapsulationType(), resourceGroup);
uniIntents.add(uniIntent);
});
return uniIntents;
}
Aggregations