use of org.onosproject.net.intent.IntentService in project onos by opennetworkinglab.
the class IntentKeyImrCompleter method complete.
@Override
public int complete(Session session, CommandLine commandLine, List<String> candidates) {
// Delegate string completer
StringsCompleter delegate = new StringsCompleter();
// Fetch our service and feed it's offerings to the string completer
IntentService service = AbstractShellCommand.get(IntentService.class);
SortedSet<String> strings = delegate.getStrings();
service.getIntents().forEach(intent -> {
if (intent instanceof LinkCollectionIntent || intent instanceof PointToPointIntent) {
strings.add(intent.key().toString());
}
});
// Now let the completer do the work for figuring out what to offer.
return delegate.complete(session, commandLine, candidates);
}
use of org.onosproject.net.intent.IntentService in project onos by opennetworkinglab.
the class StopMonitorCommand method doExecute.
@Override
protected void doExecute() {
imrService = get(IntentMonitorAndRerouteService.class);
intentService = get(IntentService.class);
if (appId != null && appName != null) {
if (key != null) {
/*
Intent key might be a StringKey or a LongKey, but in any case is
provided via CLI as a string. To solve only ambiguity we check if
"--longkey" CLI parameter has been set.
*/
if (treatAsLongKey) {
try {
Key intentKeyLong = Key.of(Integer.decode(key), new DefaultApplicationId(appId, appName));
if (imrService.stopMonitorIntent(intentKeyLong)) {
print("Stopped monitoring of intent with LongKey %s", intentKeyLong);
return;
}
} catch (NumberFormatException nfe) {
print("\"%s\" is not a valid LongKey", key);
return;
}
} else {
Key intentKeyString = Key.of(key, new DefaultApplicationId(appId, appName));
if (imrService.stopMonitorIntent(intentKeyString)) {
print("Stopped monitoring of intent with StringKey %s", intentKeyString);
return;
}
}
// No intent found in IMR
print("No monitored intent with key %s found", key);
} else {
intentService.getIntents().forEach(i -> {
if (i.appId().equals(new DefaultApplicationId(appId, appName))) {
imrService.stopMonitorIntent(i.key());
print("Stopped monitoring of intent with key %s", i.key());
}
});
}
}
}
use of org.onosproject.net.intent.IntentService in project onos by opennetworkinglab.
the class ApplicationNameImrCompleter method complete.
@Override
public int complete(Session session, CommandLine commandLine, List<String> candidates) {
// Delegate string completer
StringsCompleter delegate = new StringsCompleter();
// Fetch our service and feed it's offerings to the string completer
IntentService service = AbstractShellCommand.get(IntentService.class);
SortedSet<String> strings = delegate.getStrings();
service.getIntents().forEach(intent -> strings.add(intent.appId().name()));
// Now let the completer do the work for figuring out what to offer.
return delegate.complete(session, commandLine, candidates);
}
use of org.onosproject.net.intent.IntentService in project onos by opennetworkinglab.
the class AddOpticalIntentCommand method doExecute.
@Override
protected void doExecute() {
IntentService service = get(IntentService.class);
DeviceService deviceService = get(DeviceService.class);
ConnectPoint ingress = createConnectPoint(ingressString);
ConnectPoint egress = createConnectPoint(egressString);
Intent intent = createOpticalIntent(ingress, egress, deviceService, key(), appId(), bidirectional, createOchSignal(), null);
service.submit(intent);
print("Optical intent submitted:\n%s", intent.toString());
}
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();
}
Aggregations