boolean missingRequirement(IProvisioningPlan failedPlan) { IStatus status = failedPlan.getStatus(); RequestStatus requestStatus = null; if (status instanceof PlannerStatus) requestStatus = ((PlannerStatus) status).getRequestStatus(); return requestStatus != null && requestStatus.getShortExplanation() == Explanation.MISSING_REQUIREMENT; } }
public static IStatus executePlan(IProvisioningPlan result, IEngine engine, IPhaseSet phaseSet, ProvisioningContext context, IProgressMonitor progress) { if (!result.getStatus().isOK()) return result.getStatus(); if (result.getInstallerPlan() != null) { IStatus installerPlanStatus = ((IEngine) result.getInstallerPlan().getProfile().getProvisioningAgent().getService(IEngine.SERVICE_NAME)).perform(result.getInstallerPlan(), phaseSet, progress); if (!installerPlanStatus.isOK()) return installerPlanStatus; Configurator configChanger = ServiceHelper.getService(DirectorActivator.context, Configurator.class); try { configChanger.applyConfiguration(); } catch (IOException e) { return new Status(IStatus.ERROR, DirectorActivator.PI_DIRECTOR, Messages.Director_error_applying_configuration, e); } } return engine.perform(result, phaseSet, progress); } }
private static int countPlanElements(IProvisioningPlan plan) { return QueryUtil.compoundQueryable(plan.getAdditions(), plan.getRemovals()).query(QueryUtil.createIUAnyQuery(), null).toUnmodifiableSet().size(); }
@Override public IStatus perform(IProvisioningPlan plan, IPhaseSet phaseSet, IProgressMonitor monitor) { return perform(plan.getProfile(), phaseSet, ((ProvisioningPlan) plan).getOperands(), plan.getContext(), monitor); }
private void generateInstallUninstall(List<IInstallableUnit> from, List<IInstallableUnit> to) { int toIdx = 0; int fromIdx = 0; while (fromIdx != from.size() && toIdx != to.size()) { IInstallableUnit fromIU = from.get(fromIdx); IInstallableUnit toIU = to.get(toIdx); int comparison = toIU.compareTo(fromIU); if (comparison < 0) { plan.addInstallableUnit(toIU); toIdx++; } else if (comparison == 0) { toIdx++; fromIdx++; // System.out.println("same " + fromIU); } else { plan.removeInstallableUnit(fromIU); fromIdx++; } } if (fromIdx != from.size()) { for (int i = fromIdx; i < from.size(); i++) { plan.removeInstallableUnit(from.get(i)); } } if (toIdx != to.size()) { for (int i = toIdx; i < to.size(); i++) { plan.addInstallableUnit(to.get(i)); } } }
IProfile profile = plan.getProfile(); if (plan.getInstallerPlan() != null) { if (doesPhaseSetIncludeDownload(set)) { Iterator<IInstallableUnit> it = QueryUtil.compoundQueryable(plan.getAdditions(), plan.getInstallerPlan().getAdditions()).query(QueryUtil.createIUAnyQuery(), null).iterator(); while (it.hasNext()) { downloadPlan.addInstallableUnit(it.next()); IStatus installerPlanStatus = getEngine().perform(plan.getInstallerPlan(), set, mon.newChild(100)); if (!installerPlanStatus.isOK()) { mon.done();
public IProfileChangeRequest getChangeRequest(IProfileChangeRequest request, IProfile prof, IProgressMonitor monitor) { this.profile = prof; SubMonitor sub = SubMonitor.convert(monitor, 2); IProfileChangeRequest loosenedRequest = computeLooseRequest(request, sub.newChild(1)); if (canShortCircuit(request)) { return null; } IProvisioningPlan intermediaryPlan = resolve(loosenedRequest, sub.newChild(1)); if (!intermediaryPlan.getStatus().isOK()) return null; if (intermediaryPlan.getAdditions().query(QueryUtil.ALL_UNITS, new NullProgressMonitor()).isEmpty() && intermediaryPlan.getRemovals().query(QueryUtil.ALL_UNITS, new NullProgressMonitor()).isEmpty()) //No changes, we can't return anything return null; if (!productContainmentOK(intermediaryPlan)) { return null; } IProfileChangeRequest effectiveRequest = computeEffectiveChangeRequest(intermediaryPlan, loosenedRequest, request); if (isRequestUseless(effectiveRequest)) return null; return effectiveRequest; }
if (plan == null) throw new RuntimeException("Planner returned null"); handleStatus("Planner", plan.getStatus()); for (IInstallableUnit iu : plan.getAdditions().query(QueryUtil.ALL_UNITS, monitor)) fromSlice.add(iu); if (plan.getInstallerPlan() != null) for (IInstallableUnit iu : plan.getInstallerPlan().getAdditions().query(QueryUtil.ALL_UNITS, monitor)) fromSlice.add(iu);
IStatus status = plan.getStatus(); if (!status.isOK()) { throw new CoreException(status); IProvisioningPlan installerPlan = plan.getInstallerPlan(); if (installerPlan != null) {
if (!plan.getStatus().isOK()) return plan.getStatus(); for (IInstallableUnit initialRoot : strictRoots) { if (plan.getRemovals().query(QueryUtil.createIUQuery(initialRoot), null).isEmpty()) continue; return new Status(IStatus.ERROR, Activator.ID, Messages.remove_all_roots); plan = createProvisioningPlan(finalRequest, context, monitor); if (!plan.getStatus().isOK()) { System.out.println("original request"); //$NON-NLS-1$ System.out.println(request);
Object externalInstallerPlan = getSolutionFor(agentRequest, initialContext, sub.newChild(10)); if (externalInstallerPlan instanceof IProvisioningPlan && ((IProvisioningPlan) externalInstallerPlan).getStatus().getSeverity() == ERROR) { MultiStatus externalInstallerStatus = new MultiStatus(PI_DIRECTOR, 0, Messages.Planner_can_not_install_preq, null); externalInstallerStatus.add(((IProvisioningPlan) externalInstallerPlan).getStatus()); IProvisioningPlan plan = engine.createPlan(initialRequest.getProfile(), initialContext); plan.setStatus(externalInstallerStatus); IProvisioningPlan installerPlan = engine.createPlan(agentProfile, initialContext); installerPlan.setStatus(externalInstallerStatus); plan.setInstallerPlan(installerPlan); return plan; .setInstallerPlan(generatePlan((Projector) externalInstallerPlan, null, agentRequest, initialContext)); return initialPlan;
request.add(sourceIU); IProvisioningPlan plan = planner.getProvisioningPlan(request, context, subMonitor.split(25)); IStatus status = plan.getStatus(); if (!status.isOK()) { throw new CoreException(status); IPhaseSet phases = PhaseSetFactory.createDefaultPhaseSetExcluding(new String[] {PhaseSetFactory.PHASE_CHECK_TRUST, PhaseSetFactory.PHASE_CONFIGURE, PhaseSetFactory.PHASE_UNCONFIGURE, PhaseSetFactory.PHASE_UNINSTALL}); IEngine engine = getEngine(); plan.setProfileProperty(PROP_PROVISION_MODE, TargetDefinitionPersistenceHelper.MODE_PLANNER); plan.setProfileProperty(PROP_ALL_ENVIRONMENTS, Boolean.toString(false)); IStatus result = engine.perform(plan, phases, subMonitor.split(75));
private IStatus executePlan(IProvisioningPlan plan, ProvisioningContext provisioningContext, IProgressMonitor monitor) { IEngine engine = (IEngine) agent.getService(IEngine.SERVICE_NAME); IPhaseSet phaseSet = PhaseSetFactory.createDefaultPhaseSetExcluding(new String[] {PhaseSetFactory.PHASE_COLLECT, PhaseSetFactory.PHASE_CHECK_TRUST}); if (plan.getInstallerPlan() != null) { IStatus installerPlanStatus = engine.perform(plan.getInstallerPlan(), phaseSet, monitor); if (!installerPlanStatus.isOK()) return installerPlanStatus; applyConfiguration(true); } return engine.perform(plan, phaseSet, monitor); }
Iterator<IInstallableUnit> itor = newSet.iterator(); while (itor.hasNext()) { plan.addInstallableUnit(itor.next()); plan.setInstallableUnitProfileProperty(unit, PROP_INSTALLED_IU, Boolean.toString(true)); toRemove.removeAll(newSet); for (Iterator<?> i = toRemove.iterator(); i.hasNext();) { plan.removeInstallableUnit((IInstallableUnit) i.next());
protected IQueryable<IInstallableUnit> getQueryable(IProvisioningPlan plan) { return plan.getAdditions(); } }
for (Iterator<IInstallableUnit> iter = ius.iterator(); iter.hasNext();) { IInstallableUnit iu = iter.next(); plan.addInstallableUnit(iu); plan.setInstallableUnitProfileProperty(iu, "org.eclipse.equinox.p2.internal.inclusion.rules", ProfileInclusionRules.createOptionalInclusionRule(iu)); //$NON-NLS-1$
protected IQueryable<IInstallableUnit> getQueryable(IProvisioningPlan plan) { return plan.getRemovals(); } }
plan.setProfileProperty(toRemove[i], null); plan.setProfileProperty(entry.getKey(), entry.getValue()); continue; for (Map.Entry<String, String> entry2 : entry.getValue().entrySet()) { plan.setInstallableUnitProfileProperty(iu, entry2.getKey(), entry2.getValue()); List<String> iuPropertyRemovals = entry.getValue(); for (String key : iuPropertyRemovals) { plan.setInstallableUnitProfileProperty(iu, key, null);
private void setPlanProperties(IProvisioningPlan plan, ITargetDefinition definition, String mode) { plan.setProfileProperty(PROP_PROVISION_MODE, mode); plan.setProfileProperty(PROP_ALL_ENVIRONMENTS, Boolean.toString(getIncludeAllEnvironments())); plan.setProfileProperty(PROP_AUTO_INCLUDE_SOURCE, Boolean.toString(getIncludeSource())); plan.setProfileProperty(PROP_INCLUDE_CONFIGURE_PHASE, Boolean.toString(getIncludeConfigurePhase())); plan.setProfileProperty(PROP_SEQUENCE_NUMBER, Integer.toString(((TargetDefinition) definition).getSequenceNumber())); }
private IStatus performRemoveForMovedIUs(ReconcilerProfileChangeRequest request, ProvisioningContext context, IProgressMonitor monitor) { Collection<IInstallableUnit> moves = request.getMoves(); if (moves.isEmpty()) return Status.OK_STATUS; IEngine engine = (IEngine) agent.getService(IEngine.SERVICE_NAME); IProvisioningPlan plan = engine.createPlan(profile, context); for (IInstallableUnit unit : moves) plan.removeInstallableUnit(unit); return executePlan(plan, context, monitor); }