private void addSelectStackStage(String desiredRepoVersion, boolean forceInstallOnNonMemberHost, Cluster cluster,
                                 RequestResourceFilter filter, String caption, RequestStageContainer req, Map<String, String> hostLevelParams, String clusterHostInfoJson) throws SystemException {
    Stage stage;
    long stageId;
    ActionExecutionContext actionContext;
    Map<String, String> commandParams = new HashMap<>();
    commandParams.put("version", desiredRepoVersion);

    stage = stageFactory.createNew(req.getId(),
      "/tmp/ambari",
      cluster.getClusterName(),
      cluster.getClusterId(),
      caption,
      StageUtils.getGson().toJson(commandParams),
      StageUtils.getGson().toJson(hostLevelParams));

    stageId = req.getLastStageId() + 1;
    if (0L == stageId) {
      stageId = 1L;
    }
    stage.setStageId(stageId);
    req.addStages(Collections.singletonList(stage));

    actionContext = new ActionExecutionContext(
      null, STACK_SELECT_ACTION,
      Collections.singletonList(filter),
      Collections.emptyMap());
    actionContext.setTimeout(Integer.valueOf(configuration.getDefaultAgentTaskTimeout(true)));

    try {
      actionExecutionHelper.get().addExecutionCommandsToStage(actionContext, stage, null, !forceInstallOnNonMemberHost);
    } catch (AmbariException e) {
      throw new SystemException("Can not modify stage", e);
    }
  }
Adds requested entities to resources
@param resources a list of resources to add to
@param requestedEntities requested entities
@param requestedIds
@param clusterName name of cluster or null if no any
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostStackVersionResourceProvider.java