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;
}
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;
}
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;
}
}
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;
}
Aggregations