use of org.onosproject.net.intent.IntentInstallationContext in project onos by opennetworkinglab.
the class VirtualIntentInstallCoordinator method failed.
/**
* Handles failed operation context.
*
* @param context the operation context
*/
public void failed(IntentOperationContext context) {
IntentInstallationContext intentInstallationContext = context.intentInstallationContext();
intentInstallationContext.addErrorContext(context);
intentInstallationContext.removePendingContext(context);
if (intentInstallationContext.isPendingContextsEmpty()) {
finish(intentInstallationContext);
}
}
use of org.onosproject.net.intent.IntentInstallationContext in project onos by opennetworkinglab.
the class VirtualIntentInstallCoordinator method installIntents.
/**
* Applies Intent data to be uninstalled and to be installed.
*
* @param toUninstall Intent data to be uninstalled
* @param toInstall Intent data to be installed
*/
public void installIntents(Optional<IntentData> toUninstall, Optional<IntentData> toInstall) {
// If no any Intents to be uninstalled or installed, ignore it.
if (!toUninstall.isPresent() && !toInstall.isPresent()) {
return;
}
// Classify installable Intents to different installers.
ArrayListMultimap<IntentInstaller, Intent> uninstallInstallers;
ArrayListMultimap<IntentInstaller, Intent> installInstallers;
Set<IntentInstaller> allInstallers = Sets.newHashSet();
if (toUninstall.isPresent()) {
uninstallInstallers = getInstallers(toUninstall.get());
allInstallers.addAll(uninstallInstallers.keySet());
} else {
uninstallInstallers = ArrayListMultimap.create();
}
if (toInstall.isPresent()) {
installInstallers = getInstallers(toInstall.get());
allInstallers.addAll(installInstallers.keySet());
} else {
installInstallers = ArrayListMultimap.create();
}
// Generates an installation context for the high level Intent.
IntentInstallationContext installationContext = new IntentInstallationContext(toUninstall.orElse(null), toInstall.orElse(null));
// Generates different operation context for different installable Intents.
Map<IntentInstaller, IntentOperationContext> contexts = Maps.newHashMap();
allInstallers.forEach(installer -> {
List<Intent> intentsToUninstall = uninstallInstallers.get(installer);
List<Intent> intentsToInstall = installInstallers.get(installer);
// Connect context to high level installation context
IntentOperationContext context = new IntentOperationContext(intentsToUninstall, intentsToInstall, installationContext);
installationContext.addPendingContext(context);
contexts.put(installer, context);
});
// Apply contexts to installers
contexts.forEach((installer, context) -> {
installer.apply(context);
});
}
use of org.onosproject.net.intent.IntentInstallationContext in project onos by opennetworkinglab.
the class InstallCoordinator method failed.
/**
* Handles failed operation context.
*
* @param context the operation context
*/
public void failed(IntentOperationContext context) {
IntentInstallationContext intentInstallationContext = context.intentInstallationContext();
intentInstallationContext.addErrorContext(context);
intentInstallationContext.removePendingContext(context);
if (intentInstallationContext.isPendingContextsEmpty()) {
finish(intentInstallationContext);
}
}
use of org.onosproject.net.intent.IntentInstallationContext in project onos by opennetworkinglab.
the class FlowObjectiveIntentInstallerTest method testUninstallAndInstallIntent.
/**
* Do both uninstall and install flow objective Intents.
*/
@Test
public void testUninstallAndInstallIntent() {
List<Intent> intentsToUninstall = createFlowObjectiveIntents();
List<Intent> intentsToInstall = createAnotherFlowObjectiveIntents();
IntentData toInstall = new IntentData(createP2PIntent(), IntentState.INSTALLING, new WallClockTimestamp());
toInstall = IntentData.compiled(toInstall, intentsToInstall);
IntentData toUninstall = new IntentData(createP2PIntent(), IntentState.INSTALLED, new WallClockTimestamp());
toUninstall = IntentData.compiled(toUninstall, intentsToUninstall);
IntentOperationContext<FlowObjectiveIntent> operationContext;
IntentInstallationContext context = new IntentInstallationContext(toUninstall, toInstall);
operationContext = new IntentOperationContext(intentsToUninstall, intentsToInstall, context);
installer.apply(operationContext);
IntentOperationContext successContext = intentInstallCoordinator.successContext;
assertEquals(successContext, operationContext);
}
use of org.onosproject.net.intent.IntentInstallationContext in project onos by opennetworkinglab.
the class FlowObjectiveIntentInstallerTest method testNoAnyIntentToApply.
/**
* Nothing to uninstall or install.
*/
@Test
public void testNoAnyIntentToApply() {
IntentData toInstall = null;
IntentData toUninstall = null;
IntentOperationContext<FlowObjectiveIntent> operationContext;
IntentInstallationContext context = new IntentInstallationContext(toUninstall, toInstall);
operationContext = new IntentOperationContext<>(ImmutableList.of(), ImmutableList.of(), context);
installer.apply(operationContext);
IntentOperationContext successContext = intentInstallCoordinator.successContext;
assertEquals(successContext, operationContext);
}
Aggregations