Search in sources :

Example 6 with ProvisioningRuntime

use of org.jboss.galleon.runtime.ProvisioningRuntime in project galleon by wildfly.

the class AbstractInstallationCommand method getFeatureContainer.

public FeatureContainer getFeatureContainer(PmSession session, ProvisioningLayout<FeaturePackLayout> layout) throws ProvisioningException, CommandExecutionException, IOException {
    FeatureContainer container;
    ProvisioningManager manager = getManager(session);
    if (manager.getProvisionedState() == null) {
        throw new CommandExecutionException("Specified directory doesn't contain an installation");
    }
    if (layout == null) {
        ProvisioningConfig config = manager.getProvisioningConfig();
        try (ProvisioningRuntime runtime = manager.getRuntime(config)) {
            container = FeatureContainers.fromProvisioningRuntime(session, runtime);
        }
    } else {
        try (ProvisioningRuntime runtime = manager.getRuntime(layout)) {
            container = FeatureContainers.fromProvisioningRuntime(session, runtime);
        }
    }
    return container;
}
Also used : ProvisioningConfig(org.jboss.galleon.config.ProvisioningConfig) ProvisioningManager(org.jboss.galleon.ProvisioningManager) ProvisioningRuntime(org.jboss.galleon.runtime.ProvisioningRuntime) FeatureContainer(org.jboss.galleon.cli.model.FeatureContainer) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException)

Example 7 with ProvisioningRuntime

use of org.jboss.galleon.runtime.ProvisioningRuntime in project galleon by wildfly.

the class ProvisioningDiffProvider method getMergedConfig.

public ProvisioningConfig getMergedConfig() throws ProvisioningException {
    if (mergedConfig != null) {
        return mergedConfig;
    }
    if (!hasConfigChanges()) {
        mergedConfig = provisionedConfig;
        return provisionedConfig;
    }
    final ProvisioningConfig.Builder configBuilder = initProvisioningConfig();
    final Collection<ConfigModel> definedConfigs = provisionedConfig.getDefinedConfigs();
    if (!definedConfigs.isEmpty()) {
        for (ConfigModel originalConfig : definedConfigs) {
            final ConfigModel updatedConfig = updatedConfigs.remove(originalConfig.getId());
            if (updatedConfig != null) {
                configBuilder.addConfig(updatedConfig);
                continue;
            }
            if (removedConfigs.contains(originalConfig.getId())) {
                continue;
            }
            configBuilder.addConfig(originalConfig);
        }
    }
    if (!updatedConfigs.isEmpty()) {
        for (ConfigModel updatedConfig : updatedConfigs.values()) {
            configBuilder.addConfig(updatedConfig);
        }
    }
    if (!addedConfigs.isEmpty()) {
        for (ConfigModel addedConfig : addedConfigs.values()) {
            configBuilder.addConfig(addedConfig);
        }
    }
    if (!removedConfigs.isEmpty()) {
        List<ProvisionedConfig> baseConfigs = null;
        for (ConfigId configId : removedConfigs) {
            if (provisionedConfig.hasDefinedConfig(configId)) {
                if (baseConfigs == null) {
                    final ProvisioningConfig.Builder baseBuilder = initProvisioningConfig();
                    for (ProvisionedConfig config : provisionedState.getConfigs()) {
                        final ConfigId provisionedId = new ConfigId(config.getModel(), config.getName());
                        if (!provisionedConfig.hasDefinedConfig(provisionedId)) {
                            baseBuilder.excludeDefaultConfig(provisionedId);
                        }
                    }
                    try (ProvisioningRuntime baseRt = ProvisioningRuntimeBuilder.newInstance(log).initLayout(layout.getFactory(), baseBuilder.build()).build()) {
                        baseConfigs = baseRt.getConfigs();
                    }
                }
                if (getProvisionedConfig(baseConfigs, configId.getModel(), configId.getName()) != null) {
                    if (provisionedConfig.isInheritConfigs(true)) {
                        if (!provisionedConfig.isConfigModelExcluded(configId)) {
                            configBuilder.excludeDefaultConfig(configId);
                        }
                    } else if (provisionedConfig.isConfigModelIncluded(configId)) {
                        configBuilder.excludeDefaultConfig(configId);
                    }
                }
            } else if (provisionedConfig.isInheritConfigs(true)) {
                if (!provisionedConfig.isConfigModelExcluded(configId)) {
                    configBuilder.excludeDefaultConfig(configId);
                }
            } else if (provisionedConfig.isConfigModelIncluded(configId)) {
                configBuilder.excludeDefaultConfig(configId);
            }
        }
    }
    mergedConfig = configBuilder.build();
    return mergedConfig;
}
Also used : ProvisioningConfig(org.jboss.galleon.config.ProvisioningConfig) ConfigModel(org.jboss.galleon.config.ConfigModel) ProvisioningRuntime(org.jboss.galleon.runtime.ProvisioningRuntime) ConfigId(org.jboss.galleon.config.ConfigId) ProvisionedConfig(org.jboss.galleon.state.ProvisionedConfig)

Example 8 with ProvisioningRuntime

use of org.jboss.galleon.runtime.ProvisioningRuntime in project galleon by wildfly.

the class ProvisioningManager method getFsDiff.

/**
 * Returns the status of the filesystem describing which files have been
 * added, removed and modified since the last provisioning state transition.
 *
 * @return current status of the filesystem
 * @throws ProvisioningException  in case of an error during the status check
 */
public FsDiff getFsDiff() throws ProvisioningException {
    final ProvisioningConfig config = getProvisioningConfig();
    if (config == null || !config.hasFeaturePackDeps()) {
        return null;
    }
    log.verbose("Detecting user changes");
    final Path hashesDir = LayoutUtils.getHashesDir(getInstallationHome());
    if (Files.exists(hashesDir)) {
        final FsEntry originalState = new FsEntry(null, hashesDir);
        readHashes(originalState, new ArrayList<>());
        final FsEntry currentState = getDefaultFsEntryFactory().forPath(getInstallationHome());
        return FsDiff.diff(originalState, currentState);
    }
    try (ProvisioningRuntime rt = getRuntime(config)) {
        rt.provision();
        final FsEntryFactory fsFactory = getDefaultFsEntryFactory();
        final FsEntry originalState = fsFactory.forPath(rt.getStagedDir());
        final FsEntry currentState = fsFactory.forPath(getInstallationHome());
        final long startTime = log.isVerboseEnabled() ? System.nanoTime() : -1;
        final FsDiff fsDiff = FsDiff.diff(originalState, currentState);
        if (startTime != -1) {
            log.verbose(Errors.tookTime("  filesystem diff", startTime));
        }
        return fsDiff;
    }
}
Also used : ProvisioningConfig(org.jboss.galleon.config.ProvisioningConfig) Path(java.nio.file.Path) FsEntry(org.jboss.galleon.diff.FsEntry) ProvisioningRuntime(org.jboss.galleon.runtime.ProvisioningRuntime) FsDiff(org.jboss.galleon.diff.FsDiff) FsEntryFactory(org.jboss.galleon.diff.FsEntryFactory)

Example 9 with ProvisioningRuntime

use of org.jboss.galleon.runtime.ProvisioningRuntime in project galleon by wildfly.

the class FeatureContainers method fromFeaturePackId.

public static FeatureContainer fromFeaturePackId(PmSession session, FPID fpid, String name) throws ProvisioningException, IOException {
    if (fpid.getBuild() == null) {
        FeaturePackLocation loc = session.getUniverse().resolveLatestBuild(fpid.getLocation());
        fpid = loc.getFPID();
    }
    FeatureContainer fp = Caches.getFeaturePackInfo(fpid);
    if (fp != null) {
        return fp;
    }
    try (ProvisioningRuntime rt = buildFullRuntime(fpid, session)) {
        fp = new FeaturePackInfo(name, fpid, rt.getProvisioningConfig());
        populateFeatureContainer(fp, session, rt, true);
        Caches.addFeaturePackInfo(fpid, fp);
    }
    return fp;
}
Also used : ProvisioningRuntime(org.jboss.galleon.runtime.ProvisioningRuntime) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation)

Aggregations

ProvisioningRuntime (org.jboss.galleon.runtime.ProvisioningRuntime)9 ProvisioningConfig (org.jboss.galleon.config.ProvisioningConfig)4 Path (java.nio.file.Path)2 ArrayList (java.util.ArrayList)2 FeatureContainer (org.jboss.galleon.cli.model.FeatureContainer)2 ProvisionedConfig (org.jboss.galleon.state.ProvisionedConfig)2 IOException (java.io.IOException)1 DirectoryStream (java.nio.file.DirectoryStream)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 ProvisioningManager (org.jboss.galleon.ProvisioningManager)1 ProvisioningOption (org.jboss.galleon.ProvisioningOption)1 CommandExecutionException (org.jboss.galleon.cli.CommandExecutionException)1 AbstractDynamicCommand (org.jboss.galleon.cli.cmd.AbstractDynamicCommand)1 ConfigInfo (org.jboss.galleon.cli.model.ConfigInfo)1 ConfigId (org.jboss.galleon.config.ConfigId)1 ConfigModel (org.jboss.galleon.config.ConfigModel)1 FeaturePackConfig (org.jboss.galleon.config.FeaturePackConfig)1 FsDiff (org.jboss.galleon.diff.FsDiff)1