Search in sources :

Example 26 with Intent

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();
}
Also used : IntentService(org.onosproject.net.intent.IntentService) CoreService(org.onosproject.core.CoreService) OpticalConnectivityIntent(org.onosproject.net.intent.OpticalConnectivityIntent) OpticalCircuitIntent(org.onosproject.net.intent.OpticalCircuitIntent) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) Intent(org.onosproject.net.intent.Intent) OpticalIntentUtility.createExplicitOpticalIntent(org.onosproject.net.optical.util.OpticalIntentUtility.createExplicitOpticalIntent) OpticalConnectivityIntent(org.onosproject.net.intent.OpticalConnectivityIntent) ApplicationId(org.onosproject.core.ApplicationId) OpticalCircuitIntent(org.onosproject.net.intent.OpticalCircuitIntent) Path(javax.ws.rs.Path) DefaultPath(org.onosproject.net.DefaultPath) DELETE(javax.ws.rs.DELETE) Consumes(javax.ws.rs.Consumes)

Example 27 with Intent

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());
}
Also used : DefaultOchSignalComparator(org.onosproject.net.DefaultOchSignalComparator) DeviceService(org.onosproject.net.device.DeviceService) LoggerFactory(org.slf4j.LoggerFactory) TopologyService(org.onosproject.net.topology.TopologyService) Link(org.onosproject.net.Link) ResourceService(org.onosproject.net.resource.ResourceService) ConnectPoint(org.onosproject.net.ConnectPoint) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) Topology(org.onosproject.net.topology.Topology) Port(org.onosproject.net.Port) Map(java.util.Map) OchPort(org.onosproject.net.optical.OchPort) DefaultLink(org.onosproject.net.DefaultLink) OchSignalType(org.onosproject.net.OchSignalType) ImmutableSet(com.google.common.collect.ImmutableSet) Resources(org.onosproject.net.resource.Resources) Deactivate(org.osgi.service.component.annotations.Deactivate) OpticalPathIntent(org.onosproject.net.intent.OpticalPathIntent) Collection(java.util.Collection) Set(java.util.Set) Resource(org.onosproject.net.resource.Resource) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) ResourceAllocation(org.onosproject.net.resource.ResourceAllocation) List(java.util.List) Stream(java.util.stream.Stream) Annotations(org.onosproject.net.Annotations) IntentCompiler(org.onosproject.net.intent.IntentCompiler) Optional(java.util.Optional) Path(org.onosproject.net.Path) ChannelSpacing(org.onosproject.net.ChannelSpacing) DeviceId(org.onosproject.net.DeviceId) IntStream(java.util.stream.IntStream) GridType(org.onosproject.net.GridType) TopologyEdge(org.onosproject.net.topology.TopologyEdge) AnnotationKeys(org.onosproject.net.AnnotationKeys) ArrayList(java.util.ArrayList) Component(org.osgi.service.component.annotations.Component) ImmutableList(com.google.common.collect.ImmutableList) DefaultPath(org.onosproject.net.DefaultPath) Intent(org.onosproject.net.intent.Intent) Activate(org.osgi.service.component.annotations.Activate) LinkedList(java.util.LinkedList) Logger(org.slf4j.Logger) IntentExtensionService(org.onosproject.net.intent.IntentExtensionService) ProviderId(org.onosproject.net.provider.ProviderId) Maps(com.google.common.collect.Maps) OchSignal(org.onosproject.net.OchSignal) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) DefaultAnnotations(org.onosproject.net.DefaultAnnotations) Weight(org.onlab.graph.Weight) OpticalDeviceServiceView.opticalView(org.onosproject.net.optical.device.OpticalDeviceServiceView.opticalView) LinkWeigher(org.onosproject.net.topology.LinkWeigher) Reference(org.osgi.service.component.annotations.Reference) ScalarWeight(org.onlab.graph.ScalarWeight) OpticalConnectivityIntent(org.onosproject.net.intent.OpticalConnectivityIntent) Collections(java.util.Collections) OchSignal(org.onosproject.net.OchSignal) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 28 with Intent

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();
}
Also used : DomainPointToPointIntent(org.onosproject.net.domain.DomainPointToPointIntent) DomainPointToPointIntent(org.onosproject.net.domain.DomainPointToPointIntent) Intent(org.onosproject.net.intent.Intent) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) FlowRule(org.onosproject.net.flow.FlowRule) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) Test(org.junit.Test)

Example 29 with Intent

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();
}
Also used : DomainPointToPointIntent(org.onosproject.net.domain.DomainPointToPointIntent) DomainPointToPointIntent(org.onosproject.net.domain.DomainPointToPointIntent) Intent(org.onosproject.net.intent.Intent) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) FlowRule(org.onosproject.net.flow.FlowRule) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) Test(org.junit.Test)

Example 30 with Intent

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();
}
Also used : DomainPointToPointIntent(org.onosproject.net.domain.DomainPointToPointIntent) DomainPointToPointIntent(org.onosproject.net.domain.DomainPointToPointIntent) Intent(org.onosproject.net.intent.Intent) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) Test(org.junit.Test)

Aggregations

Intent (org.onosproject.net.intent.Intent)282 Test (org.junit.Test)176 FlowRuleIntent (org.onosproject.net.intent.FlowRuleIntent)133 LinkCollectionIntent (org.onosproject.net.intent.LinkCollectionIntent)110 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)108 FlowRule (org.onosproject.net.flow.FlowRule)90 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)87 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)84 ConnectPoint (org.onosproject.net.ConnectPoint)78 DeviceId (org.onosproject.net.DeviceId)77 List (java.util.List)75 Collectors (java.util.stream.Collectors)71 AbstractIntentTest (org.onosproject.net.intent.AbstractIntentTest)70 PathIntent (org.onosproject.net.intent.PathIntent)70 Collection (java.util.Collection)60 VlanId (org.onlab.packet.VlanId)60 TrafficSelector (org.onosproject.net.flow.TrafficSelector)60 CoreService (org.onosproject.core.CoreService)59 Collections (java.util.Collections)57 ImmutableSet (com.google.common.collect.ImmutableSet)54