Search in sources :

Example 6 with IntentService

use of org.onosproject.net.intent.IntentService 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 7 with IntentService

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

the class IntentRemoveCommand method purgeIntents.

/**
 * Purges the intents passed as argument.
 *
 * @param intents list of intents to purge
 */
private void purgeIntents(Iterable<Intent> intents) {
    IntentService intentService = get(IntentService.class);
    this.purgeAfterRemove = true;
    removeIntentsByAppId(intentService, intents, null);
}
Also used : IntentService(org.onosproject.net.intent.IntentService)

Example 8 with IntentService

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

the class IntentsDiagnosisCommand method buildServiceRefs.

private ServiceRefs buildServiceRefs() {
    IntentService intentsService = get(IntentService.class);
    if (intentsService == null) {
        return null;
    }
    DeviceService deviceService = get(DeviceService.class);
    if (deviceService == null) {
        return null;
    }
    FlowStatisticService flowStatsService = get(FlowStatisticService.class);
    if (flowStatsService == null) {
        return null;
    }
    FlowRuleService flowService = get(FlowRuleService.class);
    if (flowService == null) {
        return null;
    }
    WorkPartitionService workPartitionService = get(WorkPartitionService.class);
    if (workPartitionService == null) {
        return null;
    }
    ObjectiveTrackerService objectiveTrackerService = get(ObjectiveTrackerService.class);
    if (objectiveTrackerService == null) {
        return null;
    }
    return new ServiceRefs(intentsService, deviceService, flowService, workPartitionService, objectiveTrackerService);
}
Also used : IntentService(org.onosproject.net.intent.IntentService) WorkPartitionService(org.onosproject.net.intent.WorkPartitionService) DeviceService(org.onosproject.net.device.DeviceService) FlowStatisticService(org.onosproject.net.statistic.FlowStatisticService) FlowRuleService(org.onosproject.net.flow.FlowRuleService) ObjectiveTrackerService(org.onosproject.net.intent.ObjectiveTrackerService)

Example 9 with IntentService

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

the class AddMultiPointToSinglePointIntentCommand method doExecute.

@Override
protected void doExecute() {
    IntentService service = get(IntentService.class);
    if (deviceStrings.length < 2) {
        return;
    }
    String egressDeviceString = deviceStrings[deviceStrings.length - 1];
    FilteredConnectPoint egress = new FilteredConnectPoint(ConnectPoint.deviceConnectPoint(egressDeviceString));
    Set<FilteredConnectPoint> ingressPoints = new HashSet<>();
    for (int index = 0; index < deviceStrings.length - 1; index++) {
        String ingressDeviceString = deviceStrings[index];
        ConnectPoint ingress = ConnectPoint.deviceConnectPoint(ingressDeviceString);
        ingressPoints.add(new FilteredConnectPoint(ingress));
    }
    TrafficSelector selector = buildTrafficSelector();
    TrafficTreatment treatment = buildTrafficTreatment();
    List<Constraint> constraints = buildConstraints();
    Intent intent = MultiPointToSinglePointIntent.builder().appId(appId()).key(key()).selector(selector).treatment(treatment).filteredIngressPoints(ingressPoints).filteredEgressPoint(egress).constraints(constraints).priority(priority()).resourceGroup(resourceGroup()).build();
    service.submit(intent);
    print("Multipoint to single point intent submitted:\n%s", intent.toString());
}
Also used : IntentService(org.onosproject.net.intent.IntentService) Constraint(org.onosproject.net.intent.Constraint) TrafficSelector(org.onosproject.net.flow.TrafficSelector) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) Intent(org.onosproject.net.intent.Intent) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) Constraint(org.onosproject.net.intent.Constraint) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) HashSet(java.util.HashSet)

Example 10 with IntentService

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

the class AddProtectedTransportIntentCommand method doExecute.

@Override
protected void doExecute() {
    intentService = get(IntentService.class);
    DeviceId did1 = DeviceId.deviceId(deviceId1Str);
    DeviceId did2 = DeviceId.deviceId(deviceId2Str);
    Intent intent;
    intent = ProtectedTransportIntent.builder().key(key()).appId(appId()).one(did1).two(did2).build();
    print("Submitting: %s", intent);
    intentService.submit(intent);
}
Also used : IntentService(org.onosproject.net.intent.IntentService) DeviceId(org.onosproject.net.DeviceId) ProtectedTransportIntent(org.onosproject.net.intent.ProtectedTransportIntent) Intent(org.onosproject.net.intent.Intent)

Aggregations

IntentService (org.onosproject.net.intent.IntentService)36 Intent (org.onosproject.net.intent.Intent)19 ApplicationId (org.onosproject.core.ApplicationId)8 ConnectPoint (org.onosproject.net.ConnectPoint)8 CoreService (org.onosproject.core.CoreService)7 Key (org.onosproject.net.intent.Key)7 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)6 FlowRuleIntent (org.onosproject.net.intent.FlowRuleIntent)6 Path (javax.ws.rs.Path)5 Produces (javax.ws.rs.Produces)5 StringsCompleter (org.apache.karaf.shell.support.completers.StringsCompleter)5 Link (org.onosproject.net.Link)5 TrafficSelector (org.onosproject.net.flow.TrafficSelector)5 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)5 Constraint (org.onosproject.net.intent.Constraint)5 OpticalConnectivityIntent (org.onosproject.net.intent.OpticalConnectivityIntent)5 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)3 IOException (java.io.IOException)3 HashSet (java.util.HashSet)3 Consumes (javax.ws.rs.Consumes)3