use of org.onosproject.net.intent.Intent in project onos by opennetworkinglab.
the class OpticalIntentsWebResource method deleteIntent.
/**
* Delete the specified optical intent.
*
* @param appId application identifier
* @param keyString intent key
* @return 204 NO CONTENT
*/
@DELETE
@Consumes(MediaType.APPLICATION_JSON)
@Path("{appId}/{key}")
public Response deleteIntent(@PathParam("appId") String appId, @PathParam("key") String keyString) {
final ApplicationId app = get(CoreService.class).getAppId(appId);
nullIsNotFound(app, "Application Id not found");
IntentService intentService = get(IntentService.class);
Intent intent = intentService.getIntent(Key.of(keyString, app));
if (intent == null) {
intent = intentService.getIntent(Key.of(Long.decode(keyString), app));
}
nullIsNotFound(intent, "Intent Id is not found");
if ((intent instanceof OpticalConnectivityIntent) || (intent instanceof OpticalCircuitIntent)) {
intentService.withdraw(intent);
} else {
throw new IllegalArgumentException("Specified intent is not of type OpticalConnectivityIntent");
}
return Response.noContent().build();
}
use of org.onosproject.net.intent.Intent in project onos by opennetworkinglab.
the class OpticalConnectivityIntentCompiler method findFirstAvailableLambda.
/**
* Find the first available lambda on the given path by checking all the port resources.
*
* @param path the path
* @return list of consecutive and available OChSignals
*/
private List<OchSignal> findFirstAvailableLambda(OpticalConnectivityIntent intent, Path path) {
if (intent.ochSignal().isPresent()) {
// create lambdas w.r.t. slotGanularity/slotWidth
OchSignal ochSignal = intent.ochSignal().get();
if (ochSignal.gridType() == GridType.FLEX) {
// multiplier sits in the middle of slots
int startMultiplier = ochSignal.spacingMultiplier() - (ochSignal.slotGranularity() / 2);
return IntStream.range(0, ochSignal.slotGranularity()).mapToObj(x -> OchSignal.newFlexGridSlot(startMultiplier + (2 * x))).collect(Collectors.toList());
} else if (ochSignal.gridType() == GridType.DWDM) {
int startMultiplier = (int) (1 - ochSignal.slotGranularity() + ochSignal.spacingMultiplier() * ochSignal.channelSpacing().frequency().asHz() / ChannelSpacing.CHL_6P25GHZ.frequency().asHz());
return IntStream.range(0, ochSignal.slotGranularity()).mapToObj(x -> OchSignal.newFlexGridSlot(startMultiplier + (2 * x))).collect(Collectors.toList());
}
// TODO: add support for other gridTypes
log.error("Grid type: {} not supported for user defined signal intents", ochSignal.gridType());
return Collections.emptyList();
}
Set<OchSignal> lambdas = findCommonLambdas(path);
if (lambdas.isEmpty()) {
return Collections.emptyList();
}
return findFirstLambda(lambdas, slotCount());
}
use of org.onosproject.net.intent.Intent in project onos by opennetworkinglab.
the class LinkCollectionIntentCompilerDomainP2PTest method testCompilationDomainEndP2P.
/**
* We test the proper compilation of a domain ending with a domain device.
*/
@Test
public void testCompilationDomainEndP2P() {
intent = LinkCollectionIntent.builder().appId(APP_ID).selector(selector).treatment(treatment).applyTreatmentOnEgress(true).links(ImmutableSet.of(link(d1p0, d2p0))).filteredIngressPoints(ImmutableSet.of(new FilteredConnectPoint(d1p10))).filteredEgressPoints(ImmutableSet.of(new FilteredConnectPoint(d2p10))).constraints(domainConstraint).build();
sut.activate();
List<Intent> compiled = sut.compile(intent, Collections.emptyList());
assertThat(compiled, hasSize(2));
DomainPointToPointIntent domainIntent = ((DomainPointToPointIntent) compiled.get(0));
ConnectPoint ingress = domainIntent.filteredIngressPoints().iterator().next().connectPoint();
assertThat(ingress, equalTo(d2p0));
ConnectPoint egress = domainIntent.filteredEgressPoints().iterator().next().connectPoint();
assertThat(egress, equalTo(d2p10));
assertThat(domainIntent.links(), hasSize(0));
Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(1)).flowRules();
assertThat(rules, hasSize(1));
sut.deactivate();
}
use of org.onosproject.net.intent.Intent in project onos by opennetworkinglab.
the class LinkCollectionIntentCompilerDomainP2PTest method testCompilationDomainStartP2P.
/**
* We test the proper compilation of a domain starting with a domain device.
*/
@Test
public void testCompilationDomainStartP2P() {
intent = LinkCollectionIntent.builder().appId(APP_ID).selector(selector).treatment(treatment).applyTreatmentOnEgress(true).links(ImmutableSet.of(link(d2p0, d1p0))).filteredIngressPoints(ImmutableSet.of(new FilteredConnectPoint(d2p10))).filteredEgressPoints(ImmutableSet.of(new FilteredConnectPoint(d1p10))).constraints(domainConstraint).build();
sut.activate();
List<Intent> compiled = sut.compile(intent, Collections.emptyList());
assertThat(compiled, hasSize(2));
DomainPointToPointIntent domainIntent = ((DomainPointToPointIntent) compiled.get(0));
ConnectPoint ingress = domainIntent.filteredIngressPoints().iterator().next().connectPoint();
assertThat(ingress, equalTo(d2p10));
ConnectPoint egress = domainIntent.filteredEgressPoints().iterator().next().connectPoint();
assertThat(egress, equalTo(d2p0));
assertThat(domainIntent.links(), hasSize(0));
Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(1)).flowRules();
assertThat(rules, hasSize(1));
sut.deactivate();
}
use of org.onosproject.net.intent.Intent in project onos by opennetworkinglab.
the class LinkCollectionIntentCompilerDomainP2PTest method testCompilationDomainFullP2P.
/**
* We test the proper compilation of a path fully inside of a domain.
*/
@Test
public void testCompilationDomainFullP2P() {
intent = LinkCollectionIntent.builder().appId(APP_ID).selector(selector).treatment(treatment).applyTreatmentOnEgress(true).links(ImmutableSet.of(link(d2p0, d4p0))).filteredIngressPoints(ImmutableSet.of(new FilteredConnectPoint(d2p10))).filteredEgressPoints(ImmutableSet.of(new FilteredConnectPoint(d4p10))).constraints(domainConstraint).build();
sut.activate();
List<Intent> compiled = sut.compile(intent, Collections.emptyList());
assertThat(compiled, hasSize(1));
DomainPointToPointIntent domainIntent = ((DomainPointToPointIntent) compiled.get(0));
ConnectPoint ingress = domainIntent.filteredIngressPoints().iterator().next().connectPoint();
assertThat(ingress, equalTo(d2p10));
ConnectPoint egress = domainIntent.filteredEgressPoints().iterator().next().connectPoint();
assertThat(egress, equalTo(d4p10));
assertThat(domainIntent.links(), hasSize(1));
sut.deactivate();
}
Aggregations