use of org.onosproject.net.intent.IntentService in project onos by opennetworkinglab.
the class IntentDetailsCommand method detailIntents.
/**
* Print detailed data for intents, given a list of IDs.
*
* @param intentsIds List of intent IDs
*/
public void detailIntents(List<String> intentsIds) {
if (intentsIds != null) {
ids = intentsIds.stream().map(IntentId::valueOf).collect(Collectors.toSet());
}
IntentService service = get(IntentService.class);
Tools.stream(service.getIntentData()).filter(this::filter).forEach(this::printIntentData);
}
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 IntentsWebResource method createIntent.
/**
* Submits a new intent.
* Creates and submits intent from the JSON request.
*
* @param stream input JSON
* @return status of the request - CREATED if the JSON is correct,
* BAD_REQUEST if the JSON is invalid
* @onos.rsModel IntentHost
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response createIntent(InputStream stream) {
try {
IntentService service = get(IntentService.class);
ObjectNode root = readTreeFromStream(mapper(), stream);
Intent intent = codec(Intent.class).decode(root, this);
service.submit(intent);
UriBuilder locationBuilder = uriInfo.getBaseUriBuilder().path("intents").path(intent.appId().name()).path(Long.toString(intent.id().fingerprint()));
return Response.created(locationBuilder.build()).build();
} catch (IOException ioe) {
throw new IllegalArgumentException(ioe);
}
}
use of org.onosproject.net.intent.IntentService in project onos by opennetworkinglab.
the class ProtectedIntentMonitor method protectedIntentMultiLayer.
/**
* Returns the packet to optical mapping given a head and tail of a protection path.
*
* @param head head of path
* @param tail tail of path
*/
private Set<Link> protectedIntentMultiLayer(ConnectPoint head, ConnectPoint tail) {
List<Link> links = new LinkedList<>();
LinkService linkService = services.link();
IntentService intentService = services.intent();
// Ingress cross connect link
links.addAll(linkService.getEgressLinks(head).stream().filter(l -> l.type() == Link.Type.OPTICAL).collect(Collectors.toList()));
// Egress cross connect link
links.addAll(linkService.getIngressLinks(tail).stream().filter(l -> l.type() == Link.Type.OPTICAL).collect(Collectors.toList()));
// The protected intent does not rely on a multi-layer mapping
if (links.size() != 2) {
return Collections.emptySet();
}
// Expected head and tail of optical circuit (not connectivity!) intent
ConnectPoint ocHead = links.get(0).dst();
ConnectPoint ocTail = links.get(1).src();
// Optical connectivity
// FIXME: assumes that transponder (OTN device) is a one-to-one mapping
// We need to track the multi-layer aspects better
intentService.getIntents().forEach(intent -> {
if (intent instanceof OpticalConnectivityIntent) {
OpticalConnectivityIntent ocIntent = (OpticalConnectivityIntent) intent;
if (ocHead.deviceId().equals(ocIntent.getSrc().deviceId()) && ocTail.deviceId().equals(ocIntent.getDst().deviceId())) {
intentService.getInstallableIntents(ocIntent.key()).forEach(i -> {
if (i instanceof FlowRuleIntent) {
FlowRuleIntent fr = (FlowRuleIntent) i;
links.addAll(linkResources(fr));
}
});
}
}
});
return new LinkedHashSet<>(links);
}
use of org.onosproject.net.intent.IntentService in project onos by opennetworkinglab.
the class VirtualNetworkIntentRemoveCommand method doExecute.
@Override
protected void doExecute() {
VirtualNetworkService service = get(VirtualNetworkService.class);
IntentService intentService = service.get(NetworkId.networkId(networkId), IntentService.class);
CoreService coreService = get(CoreService.class);
if (purgeAfterRemove || sync) {
print("Using \"sync\" to remove/purge intents - this may take a while...");
print("Check \"summary\" to see remove/purge progress.");
}
ApplicationId appId = appId();
if (!isNullOrEmpty(applicationIdString)) {
appId = coreService.getAppId(applicationIdString);
if (appId == null) {
print("Cannot find application Id %s", applicationIdString);
return;
}
}
if (isNullOrEmpty(keyString)) {
for (Intent intent : intentService.getIntents()) {
if (intent.appId().equals(appId)) {
removeIntent(intentService, intent);
}
}
} else {
final Key key;
if (keyString.startsWith("0x")) {
// The intent uses a LongKey
keyString = keyString.replaceFirst("0x", "");
key = Key.of(new BigInteger(keyString, 16).longValue(), appId);
} else {
// The intent uses a StringKey
key = Key.of(keyString, appId);
}
Intent intent = intentService.getIntent(key);
if (intent != null) {
removeIntent(intentService, intent);
} else {
print("Intent not found!");
}
}
}
Aggregations