public B addFeaturePackDep(String origin, FeaturePackConfig dependency) throws ProvisioningDescriptionException { final UniverseSpec configuredUniverse = getConfiguredUniverse(dependency.getLocation()); return addFeaturePackDepResolved(origin, configuredUniverse == null ? dependency : FeaturePackConfig.builder(dependency.getLocation().replaceUniverse(configuredUniverse)).init(dependency).build(), false); }
/** * Installs the specified feature-pack. * * @param fpl feature-pack location * @throws ProvisioningException in case the installation fails */ public void install(FeaturePackLocation fpl) throws ProvisioningException { install(FeaturePackConfig.forLocation(fpl)); }
return true; final ProducerSpec producer = fpConfig.getLocation().getProducer(); final int inheritPkgs = isInheritPackages(producer); if(inheritPkgs == INHERIT_PKGS_NOT_FOUND || inheritPkgs == INHERIT_PKGS_TRANSITIVE && !fpConfig.isTransitive()) { return true; if(fpConfig.hasExcludedPackages()) { for(String excluded : fpConfig.getExcludedPackages()) { if(!isPackageExcluded(producer, excluded) && !isPackageIncluded(producer, excluded)) { return true; if(fpConfig.hasIncludedPackages()) { for(PackageConfig included : fpConfig.getIncludedPackages()) { if(!isPackageIncluded(producer, included.getName()) && !isPackageExcluded(producer, included.getName())) { return true; if (fpConfig.hasDefinedConfigs()) { boolean configsInherited = true; for(int i = levels.size() - 1; i >= 0; --i) { if (fpConfig.hasModelOnlyConfigs()) { boolean configsInherited = true; for(int i = levels.size() - 1; i >= 0; --i) {
@Override public void undoAction(ProvisioningConfig.Builder builder) throws ProvisioningException { for (Entry<FeaturePackConfig, T> entry : cf.entrySet()) { Integer index = indexes.get(entry.getKey().getLocation().getFPID()); // index could be null if doAction failed or did not execute. if (index != null) { FeaturePackConfig.Builder fpBuilder = entry.getKey().getBuilder(); undoAction(fpBuilder, entry.getValue()); builder.removeFeaturePackDep(entry.getKey().getLocation()); builder.addFeaturePackDep(index, fpBuilder.build()); } } }
void addFpConfig(FeaturePackConfig fpConfig) { fpConfigs = CollectionUtils.add(fpConfigs, fpConfig); if(fpConfig.isTransitive()) { transitive = CollectionUtils.put(transitive, fpConfig.getLocation().getProducer(), fpConfig); } }
private FeaturePackConfig.Builder getFpcBuilder(FPID fpid) { FeaturePackConfig.Builder fpcBuilder = updatedDirectFps.get(fpid); if(fpcBuilder != null) { return fpcBuilder; } fpcBuilder = updatedTransitiveFps.get(fpid); if(fpcBuilder != null) { return fpcBuilder; } fpcBuilder = addedTransitiveFps.get(fpid); if(fpcBuilder != null) { return fpcBuilder; } FeaturePackConfig fpc = provisionedConfig.getFeaturePackDep(fpid.getProducer()); if(fpc != null) { fpcBuilder = FeaturePackConfig.builder(fpc); updatedDirectFps = CollectionUtils.put(updatedDirectFps, fpid, fpcBuilder); return fpcBuilder; } fpc = provisionedConfig.getTransitiveDep(fpid.getProducer()); if(fpc != null) { fpcBuilder = FeaturePackConfig.builder(fpc); updatedTransitiveFps = CollectionUtils.put(updatedTransitiveFps, fpid, fpcBuilder); return fpcBuilder; } fpcBuilder = FeaturePackConfig.transitiveBuilder(fpid.getLocation()); addedTransitiveFps = CollectionUtils.putLinked(addedTransitiveFps, fpid, fpcBuilder); return fpcBuilder; }
if(featurePack.hasPatches()) { final ElementNode patches = addElement(fp, Element.PATCHES.getLocalName(), ns); for(FPID patchId : featurePack.getPatches()) { final ElementNode patch = addElement(patches, Element.PATCH.getLocalName(), ns); addAttribute(patch, Attribute.ID, patchId.toString()); if (!featurePack.isInheritPackages()) { packages = addElement(fp, Element.PACKAGES.getLocalName(), ns); addAttribute(packages, Attribute.INHERIT, FALSE); if (featurePack.hasExcludedPackages()) { if (packages == null) { packages = addElement(fp, Element.PACKAGES.getLocalName(), ns); for (String excluded : featurePack.getExcludedPackages()) { final ElementNode exclude = addElement(packages, Element.EXCLUDE.getLocalName(), ns); addAttribute(exclude, Attribute.NAME, excluded); if (featurePack.hasIncludedPackages()) { if (packages == null) { packages = addElement(fp, Element.PACKAGES.getLocalName(), ns); for (PackageConfig included : featurePack.getIncludedPackages()) { final ElementNode include = addElement(packages, Element.INCLUDE.getLocalName(), ns); addAttribute(include, Attribute.NAME, included.getName());
AddDependencyAction(FeaturePackLocation fpl, boolean inheritConfigs, boolean inheritPackages) { this.fpl = fpl; newDepBuilder = FeaturePackConfig.builder(fpl).setInheritConfigs(inheritConfigs).setInheritPackages(inheritPackages); }
protected Builder(FeaturePackConfig config) { this.fpl = config.getLocation(); init(config); }
private ProvisioningConfig.Builder install(FeaturePackConfig fpConfig, ProvisioningConfig.Builder configBuilder) throws ProvisioningException { FeaturePackLocation fpl = fpConfig.getLocation(); final FPID fpid = fpl.getFPID(); if(allPatches.containsKey(fpid)) { FeaturePackConfig.transitiveBuilder(patchTarget.getFPID().getLocation()).addPatch(fpid).build()); FeaturePackConfig.builder(installedFpConfig.getLocation()).init(installedFpConfig).addPatch(fpid).build()); if(installedFp.isTransitiveDep() == fpConfig.isTransitive()) { return configBuilder.updateFeaturePackDep(fpConfig);
Set<ProducerSpec> processed = new HashSet<>(updates.size()); for(FeaturePackConfig fpConfig : config.getFeaturePackDeps()) { final ProducerSpec producer = fpConfig.getLocation().getProducer(); final FeaturePackUpdatePlan fpPlan = updates.get(producer); if(fpPlan != null && !fpPlan.isEmpty()) { if(!fpPlan.getInstalledLocation().equals(fpConfig.getLocation())) { throw new ProvisioningException("Location in the update plan " + fpPlan.getInstalledLocation() + " does not match the installed location " + fpConfig.getLocation()); final FeaturePackConfig.Builder fpBuilder = FeaturePackConfig.builder(fpPlan.getNewLocation()).init(fpConfig); if(fpPlan.hasNewPatches()) { for(FPID patchId : fpPlan.getNewPatches()) { final ProducerSpec producer = fpConfig.getLocation().getProducer(); final FeaturePackUpdatePlan fpPlan = updates.get(producer); if(fpPlan != null && !fpPlan.isEmpty()) { if(fpConfig.getLocation().getBuild() != null && !fpPlan.getInstalledLocation().equals(fpConfig.getLocation())) { throw new ProvisioningException("Update plan build " + fpPlan.getInstalledLocation() + " does not match the installed build " + fpConfig.getLocation()); final FeaturePackConfig.Builder fpBuilder = FeaturePackConfig.transitiveBuilder(fpPlan.getNewLocation()).init(fpConfig); if(fpPlan.hasNewPatches()) { for(FPID patchId : fpPlan.getNewPatches()) { final FeaturePackConfig.Builder fpBuilder = FeaturePackConfig.transitiveBuilder(update.getNewLocation()); if (update.hasNewPatches()) { for (FPID patchId : update.getNewPatches()) {
private void processFpConfig(FeaturePackConfig fpConfig) throws ProvisioningException { final ProducerSpec producer = fpConfig.getLocation().getProducer(); thisOrigin = layout.getFeaturePack(producer); final FeaturePackRuntimeBuilder parentFp = setOrigin(thisOrigin); configStack = entry.getValue(); ConfigModel config = fpConfig.getDefinedConfig(configId); if (config != null && !fpConfigStack.isFilteredOut(producer, configId, true)) { configStack.pushConfig(config); if (fpConfig.isTransitive() || fpConfigStack.isFilteredOut(producer, configId, false)) { continue; if (!fpConfig.isTransitive()) { if (currentOrigin.getSpec().hasFeaturePackDeps()) { if (currentOrigin.getSpec().hasTransitiveDeps()) { if (fpConfig.isInheritPackages() && currentOrigin.getSpec().hasDefaultPackages()) { for (String packageName : currentOrigin.getSpec().getDefaultPackageNames()) { if (fpConfigStack.isPackageFilteredOut(currentOrigin.producer, packageName, false)) { if (fpConfig.hasIncludedPackages()) { for (PackageConfig pkgConfig : fpConfig.getIncludedPackages()) { if (fpConfigStack.isPackageFilteredOut(currentOrigin.producer, pkgConfig.getName(), true)) { continue;
Table t = new Table(headers); for (FeaturePackConfig c : fps) { FeaturePackLocation loc = commandInvocation.getPmSession().getExposedLocation(installation, c.getLocation()); List<Cell> line = new ArrayList<>(); line.add(new Cell(loc.getProducer().getName())); line.add(new Cell(loc.getBuild())); if (showPatches) { if (c.hasPatches()) { Cell patches = new Cell(); for (FPID p : c.getPatches()) { patches.addLine(p.getBuild());
private ConfigModelStack resolveModelOnlyConfig(FeaturePackConfig fpConfig, ConfigModelStack modelOnlyStack, ConfigId configId) throws ProvisioningException { final FeaturePackRuntimeBuilder fp = layout.getFeaturePack(fpConfig.getLocation().getProducer()); final FeaturePackRuntimeBuilder prevOrigin = currentOrigin; try { int pushedCount = 0; ConfigModel config = fpConfig.getDefinedConfig(configId); if(config != null) { if(modelOnlyStack == null) { for(FeaturePackConfig fpDep : fp.getSpec().getFeaturePackDeps()) { extendedStackLevel |= fpConfigStack.push(fpDep, extendedStackLevel); if(fpDep.isConfigModelExcluded(configId) || !fpDep.isInheritModelOnlyConfigs() && !fpDep.isConfigModelIncluded(configId)) { continue;
private void collectDefaultConfigs(FeaturePackConfig fpConfig) throws ProvisioningException { final ProducerSpec producer = fpConfig.getLocation().getProducer(); thisOrigin = layout.getFeaturePack(producer); final FeaturePackRuntimeBuilder parentFp = setOrigin(thisOrigin); try { if (fpConfig.hasDefinedConfigs()) { for(ConfigModel config : fpConfig.getDefinedConfigs()) { final ConfigId id = config.getId(); if(id.isModelOnly() || fpConfigStack.isFilteredOut(producer, id, true)) { if (!fpConfig.isTransitive()) { final FeaturePackSpec currentSpec = currentOrigin.getSpec(); if (currentSpec.hasDefinedConfigs()) {
if (showPatches) { FeaturePackConfig config = configs.get(d.getFPID()); if (config != null && config.hasPatches()) { Cell patches = new Cell(); for (FPID p : config.getPatches()) { patches.addLine(p.getBuild());
final FeaturePackLocation fpl = transitiveConfig.getLocation(); transitiveDeps.add(fpl.getProducer()); if(transitiveConfig.hasPatches()) { addPatches(transitiveConfig); List<F> queue = new ArrayList<>(fpDeps.size()); for(FeaturePackConfig fpConfig : fpDeps) { FeaturePackLocation fpl = fpConfig.getLocation(); if(fpConfig.hasPatches()) { addPatches(fpConfig);
public static Map<FeaturePackConfig, ConfigId> getIncludedConfigurations(PmSession session, FeaturePackConfig config, String configuration) throws PathParserException, PathConsumerException, ProvisioningException, Exception { Map<FeaturePackConfig, ConfigId> configs = new HashMap<>(); if (config == null) { for (FeaturePackConfig c : session.getState().getConfig().getFeaturePackDeps()) { ConfigInfo info = getConfig(session, c.getLocation().getFPID(), configuration); if (info != null && c.getIncludedConfigs().contains(new ConfigId(info.getModel(), info.getName()))) { configs.put(c, info.getId()); } } } else { ConfigInfo info = getConfig(session, config.getLocation().getFPID(), configuration); if (info != null && config.getIncludedConfigs().contains(new ConfigId(info.getModel(), info.getName()))) { configs.put(config, info.getId()); } } if (configs.isEmpty()) { throw new ProvisioningException("Not a valid config " + configuration); } return configs; }
public static Map<FeaturePackConfig, ConfigId> getExcludedConfigurations(PmSession session, FeaturePackConfig config, String configuration) throws PathParserException, PathConsumerException, ProvisioningException, Exception { Map<FeaturePackConfig, ConfigId> configs = new HashMap<>(); if (config == null) { for (FeaturePackConfig c : session.getState().getConfig().getFeaturePackDeps()) { ConfigInfo info = getConfig(session, c.getLocation().getFPID(), configuration); if (info != null && c.getExcludedConfigs().contains(new ConfigId(info.getModel(), info.getName()))) { configs.put(c, info.getId()); } } } else { ConfigInfo info = getConfig(session, config.getLocation().getFPID(), configuration); if (info != null && config.getExcludedConfigs().contains(new ConfigId(info.getModel(), info.getName()))) { configs.put(config, info.getId()); } } if (configs.isEmpty()) { throw new ProvisioningException("Not a valid config " + configuration); } return configs; }
@Override protected Set<String> getTargetedPackages(FeaturePackConfig cf) { Set<String> packages = new HashSet<>(); for (PackageConfig c : cf.getIncludedPackages()) { packages.add(c.getName()); } return packages; }