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