Search in sources :

Example 1 with IntentInstaller

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

the class VirtualIntentInstallCoordinator method getInstallers.

/**
 * Generates a mapping for installable Intents to installers.
 *
 * @param intentData the Intent data which contains installable Intents
 * @return the mapping for installable Intents to installers
 */
private ArrayListMultimap<IntentInstaller, Intent> getInstallers(IntentData intentData) {
    ArrayListMultimap<IntentInstaller, Intent> intentInstallers = ArrayListMultimap.create();
    intentData.installables().forEach(intent -> {
        IntentInstaller installer = installerRegistry.getInstaller(intent.getClass());
        if (installer != null) {
            intentInstallers.put(installer, intent);
        } else {
            log.warn(INSTALLER_NOT_FOUND, intent);
        }
    });
    return intentInstallers;
}
Also used : IntentInstaller(org.onosproject.net.intent.IntentInstaller) Intent(org.onosproject.net.intent.Intent)

Example 2 with IntentInstaller

use of org.onosproject.net.intent.IntentInstaller 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);
    });
}
Also used : IntentInstaller(org.onosproject.net.intent.IntentInstaller) IntentInstallationContext(org.onosproject.net.intent.IntentInstallationContext) Intent(org.onosproject.net.intent.Intent) IntentOperationContext(org.onosproject.net.intent.IntentOperationContext)

Example 3 with IntentInstaller

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

the class InstallCoordinator 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);
    });
}
Also used : IntentInstaller(org.onosproject.net.intent.IntentInstaller) IntentInstallationContext(org.onosproject.net.intent.IntentInstallationContext) Intent(org.onosproject.net.intent.Intent) IntentOperationContext(org.onosproject.net.intent.IntentOperationContext)

Example 4 with IntentInstaller

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

the class InstallCoordinator method getInstallers.

/**
 * Generates a mapping for installable Intents to installers.
 *
 * @param intentData the Intent data which contains installable Intents
 * @return the mapping for installable Intents to installers
 */
private ArrayListMultimap<IntentInstaller, Intent> getInstallers(IntentData intentData) {
    ArrayListMultimap<IntentInstaller, Intent> intentInstallers = ArrayListMultimap.create();
    intentData.installables().forEach(intent -> {
        IntentInstaller installer = installerRegistry.getInstaller(intent.getClass());
        if (installer != null) {
            intentInstallers.put(installer, intent);
        } else {
            log.warn(INSTALLER_NOT_FOUND, intent);
        }
    });
    return intentInstallers;
}
Also used : IntentInstaller(org.onosproject.net.intent.IntentInstaller) Intent(org.onosproject.net.intent.Intent)

Aggregations

Intent (org.onosproject.net.intent.Intent)4 IntentInstaller (org.onosproject.net.intent.IntentInstaller)4 IntentInstallationContext (org.onosproject.net.intent.IntentInstallationContext)2 IntentOperationContext (org.onosproject.net.intent.IntentOperationContext)2