public ProducerSpec getProducer() { return FeaturePackLocation.this.getProducer(); }
public static String getDefaultOriginName(FeaturePackLocation fpl) { return fpl.getProducer().toString(); }
private FeaturePackConfig getFpConfig(ProducerSpec producer) { for(int i = fpConfigs.size() - 1; i >= 0; --i) { final FeaturePackConfig fpConfig = fpConfigs.get(i); if(fpConfig.getLocation().getProducer().equals(producer)) { return fpConfig; } } return null; } }
public ProvisioningPlan install(FeaturePackConfig fpConfig) throws ProvisioningDescriptionException { final ProducerSpec producer = fpConfig.getLocation().getProducer(); if(uninstall.contains(producer) || updates.containsKey(producer)) { throw new ProvisioningDescriptionException(producer + " has already been added to the plan"); } install = CollectionUtils.putLinked(install, producer, fpConfig); return this; }
public ProvisioningPlan update(FeaturePackUpdatePlan fpPlan) throws ProvisioningDescriptionException { final ProducerSpec producer = fpPlan.getInstalledLocation().getProducer(); if(install.containsKey(producer) || uninstall.contains(producer)) { throw new ProvisioningDescriptionException(producer + " has already been added to the plan"); } updates = CollectionUtils.putLinked(updates, producer, fpPlan); return this; }
@Override public ProducerSpec getProducer(PmSession session) throws CommandExecutionException { if (origin == null) { return null; } try { return session.getResolvedLocation(null, origin).getProducer(); } catch (ProvisioningException ex) { throw new CommandExecutionException(session, CliErrors.retrieveProducerFailed(), ex); } }
@Override public ProducerSpec getProducer(PmSession session) throws CommandExecutionException { if (origin == null) { return null; } try { return session.getResolvedLocation(null, origin).getProducer(); } catch (ProvisioningException ex) { throw new CommandExecutionException(session, CliErrors.retrieveProducerFailed(), ex); } }
@Override public ProducerSpec getProducer(PmSession session) throws CommandExecutionException { if (origin == null) { return null; } try { return session.getResolvedLocation(null, origin).getProducer(); } catch (ProvisioningException ex) { throw new CommandExecutionException(session, CliErrors.retrieveProducerFailed(), ex); } }
@Override public void doAction(ProvisioningConfig current, ProvisioningConfig.Builder builder) throws ProvisioningException { index = builder.getFeaturePackDepIndex(fpl); fpConfig = current.getFeaturePackDep(fpl.getProducer()); builder.removeFeaturePackDep(fpl); }
public static ProducerSpec newProducer(String producer) { return new FeaturePackLocation(new UniverseSpec(LegacyGalleon1UniverseFactory.ID, null), producer, null, null, null).getProducer(); }
void addFpConfig(FeaturePackConfig fpConfig) { fpConfigs = CollectionUtils.add(fpConfigs, fpConfig); if(fpConfig.isTransitive()) { transitive = CollectionUtils.put(transitive, fpConfig.getLocation().getProducer(), fpConfig); } }
private ConfigModelStack resolveConfigLayer(ConfigId layerId) throws ProvisioningException { ConfigModelStack layerStack = layers.get(layerId); if(layerStack == null) { layerStack = new ConfigModelStack(layerId, this); for (FeaturePackConfig fpConfig : config.getFeaturePackDeps()) { resolveConfigLayer(layout.getFeaturePack(fpConfig.getLocation().getProducer()), layerStack, layerId); } layers = CollectionUtils.put(layers, layerId, layerStack); } return layerStack; }
FeaturePackRuntimeBuilder getOrigin(final String depName) throws ProvisioningException { if(Constants.THIS.equals(depName)) { if(thisOrigin == null) { throw new ProvisioningException("Feature-pack reference 'this' cannot be used in the current context."); } return thisOrigin; } final FeaturePackLocation fpl = currentOrigin == null ? config.getFeaturePackDep(depName).getLocation() : currentOrigin.getSpec().getFeaturePackDep(depName).getLocation(); return layout.getFeaturePack(fpl.getProducer()); }
@SuppressWarnings("unchecked") public B removeTransitiveDep(FPID fpid) throws ProvisioningException { final FeaturePackLocation fpl = resolveUniverseSpec(fpid.getLocation()); final ProducerSpec producer = fpl.getProducer(); final FeaturePackConfig fpDep = transitiveDeps.get(producer); if(fpDep == null) { throw new ProvisioningException(Errors.unknownFeaturePack(fpid)); } if(!fpDep.getLocation().equals(fpl)) { throw new ProvisioningException(Errors.unknownFeaturePack(fpid)); } if(transitiveDeps.size() == 1) { transitiveDeps = Collections.emptyMap(); return (B) this; } else { transitiveDeps = CollectionUtils.remove(transitiveDeps, producer); } updateOriginMappings(producer); return (B) this; }
public FeaturePackConfig getProvisionedFP(PmSession session) throws CommandExecutionException { ProducerSpec channel = getProducer(session); if (channel == null) { return null; } ProvisioningConfig config = session.getState().getConfig(); for (FeaturePackConfig dep : config.getFeaturePackDeps()) { if (dep.getLocation().getProducer().equals(channel)) { return dep; } } return null; }
private Builder(ProvisioningConfig original) throws ProvisioningDescriptionException { if(original == null) { return; } if(original.hasPluginOptions()) { addOptions(original.getPluginOptions()); } for (FeaturePackConfig fp : original.getFeaturePackDeps()) { addFeaturePackDep(original.originOf(fp.getLocation().getProducer()), fp); } if (original.hasTransitiveDeps()) { for (FeaturePackConfig fp : original.getTransitiveDeps()) { addFeaturePackDep(original.originOf(fp.getLocation().getProducer()), fp); } } initUniverses(original); initConfigs(original); }
public static void printFeaturePack(PmCommandInvocation commandInvocation, FeaturePackLocation loc) { loc = commandInvocation.getPmSession().getExposedLocation(null, loc); Table t = new Table(Headers.PRODUCT, Headers.BUILD, Headers.UPDATE_CHANNEL); t.addLine(loc.getProducer().getName(), loc.getBuild(), formatChannel(loc)); commandInvocation.print(t.build()); }
private static void addCustomUpdates(ProvisioningPlan plan, List<FeaturePackLocation> custom, ProvisioningManager mgr) throws ProvisioningException { try (ProvisioningLayout<?> layout = mgr.getLayoutFactory().newConfigLayout(mgr.getProvisioningConfig())) { for (FeaturePackLocation loc : custom) { FeaturePackLayout fpl = layout.getFeaturePack(loc.getProducer()); FeaturePackLocation current = fpl.getFPID().getLocation(); FeaturePackUpdatePlan fpPlan = FeaturePackUpdatePlan.request(current, fpl.isTransitiveDep()).setNewLocation(loc).buildPlan(); if (fpPlan.hasNewLocation()) { plan.update(fpPlan); } } } }
private ResolvedFeatureSpec resolveRefMapping(ProvisioningRuntimeBuilder rt, FeaturePackRuntimeBuilder origin, FeatureReferenceSpec refSpec) throws ProvisioningException { try { if(refSpec.getOrigin() != null) { origin = rt.layout.getFeaturePack(origin.getSpec().getFeaturePackDep(refSpec.getOrigin()).getLocation().getProducer()); } final ResolvedFeatureSpec resolvedRefSpec = rt.getFeatureSpec(origin, refSpec.getFeature().getName()); assertRefParamMapping(refSpec, resolvedRefSpec); return resolvedRefSpec; } catch (ProvisioningDescriptionException e) { throw new ProvisioningDescriptionException(Errors.failedToResolveFeatureReference(refSpec, id), e); } }
private void resolveConfigLayer(FeaturePackRuntimeBuilder fp, ConfigModelStack layerStack, ConfigId layerId) throws ProvisioningException { final FeaturePackRuntimeBuilder prevOrigin = currentOrigin; try { final ConfigLayerSpec configLayer = fp.getConfigLayer(layerId); if (configLayer != null) { layerStack.pushGroup(configLayer); } if(fp.getSpec().hasFeaturePackDeps()) { for(FeaturePackConfig depConfig : fp.getSpec().getFeaturePackDeps()) { resolveConfigLayer(layout.getFeaturePack(depConfig.getLocation().getProducer()), layerStack, layerId); } } if(configLayer != null) { setOrigin(fp); processConfigLayer(layerStack, popLayer(layerStack)); } } finally { setOrigin(prevOrigin); } }