/**
   * The second step in the wizard
   *
   * @param mapping ActionMapping for struts
   * @param form DynaActionForm representing the form
   * @param ctx RequestContext request context
   * @param response HttpServletResponse response object
   * @param step WizardStep what step are we on?
   * @return ActionForward struts action forward
   * @throws Exception if something goes amiss
   */
  public ActionForward runSecond(
      ActionMapping mapping,
      DynaActionForm form,
      RequestContext ctx,
      HttpServletResponse response,
      WizardStep step)
      throws Exception {
    log.debug("runSecond");

    if (!StringUtils.isBlank(form.getString(HIDDEN_BOND_SLAVE_INTERFACES))) {
      form.set(BOND_SLAVE_INTERFACES, form.getString(HIDDEN_BOND_SLAVE_INTERFACES).split(","));
    }

    Long sid = (Long) form.get(RequestContext.SID);
    User user = ctx.getCurrentUser();

    if (!validateFirstSelections(form, ctx)) {
      return runFirst(mapping, form, ctx, response, step);
    }
    KickstartScheduleCommand cmd = getScheduleCommand(form, ctx, null, null);

    checkForKickstart(form, cmd, ctx);
    addRequestAttributes(ctx, cmd, form);
    if (!cmd.isCobblerOnly()) {
      List packageProfiles = cmd.getProfiles();
      form.set(SYNCH_PACKAGES, packageProfiles);
      List systemProfiles = cmd.getCompatibleSystems();
      form.set(SYNCH_SYSTEMS, systemProfiles);

      // Disable the package/system sync radio buttons if no profiles are
      // available:
      String syncPackageDisabled = "false";
      if (packageProfiles.size() == 0) {
        syncPackageDisabled = "true";
      }
      String syncSystemDisabled = "false";
      if (systemProfiles.size() == 0) {
        syncSystemDisabled = "true";
      }
      ctx.getRequest().setAttribute(SYNC_PACKAGE_DISABED, syncPackageDisabled);
      ctx.getRequest().setAttribute(SYNC_SYSTEM_DISABLED, syncSystemDisabled);

      if (StringUtils.isEmpty(form.getString(TARGET_PROFILE_TYPE))) {
        form.set(TARGET_PROFILE_TYPE, KickstartScheduleCommand.TARGET_PROFILE_TYPE_NONE);
      }
    } else {
      ctx.getRequest().setAttribute(COBBLER_ONLY_PROFILE, Boolean.TRUE);
    }

    if (StringUtils.isEmpty(form.getString(KERNEL_PARAMS_TYPE))) {
      form.set(KERNEL_PARAMS_TYPE, KERNEL_PARAMS_DISTRO);
    }

    if (StringUtils.isEmpty(form.getString(POST_KERNEL_PARAMS_TYPE))) {
      form.set(POST_KERNEL_PARAMS_TYPE, KERNEL_PARAMS_DISTRO);
    }

    SdcHelper.ssmCheck(ctx.getRequest(), sid, user);
    return mapping.findForward("second");
  }
Ejemplo n.º 2
0
  /** {@inheritDoc} */
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm formIn,
      HttpServletRequest request,
      HttpServletResponse response) {

    RequestContext requestContext = new RequestContext(request);
    User user = requestContext.getCurrentUser();
    Long sid = requestContext.getRequiredParam("sid");
    RhnSet set = getSetDecl(sid).get(user);

    ListRhnSetHelper help = new ListRhnSetHelper(this, request, getSetDecl(sid));
    help.setListName(LIST_NAME);
    String parentURL = request.getRequestURI() + "?sid=" + sid;
    help.setParentUrl(parentURL);

    help.execute();

    if (help.isDispatched()) {
      if (requestContext.wasDispatched("errata.jsp.apply")) {
        return applyErrata(mapping, formIn, request, response);
      }
    }

    String showButton = "true";
    // Show the "Apply Errata" button only when unapplied errata exist:
    if (!SystemManager.hasUnscheduledErrata(user, sid)) {
      showButton = "false";
    }

    Map params = new HashMap();
    Set keys = request.getParameterMap().keySet();
    for (Iterator i = keys.iterator(); i.hasNext(); ) {
      String key = (String) i.next();
      params.put(key, request.getParameter(key));
    }

    Server server = SystemManager.lookupByIdAndUser(sid, user);
    SdcHelper.ssmCheck(request, server.getId(), user);
    request.setAttribute("showApplyErrata", showButton);
    request.setAttribute("set", set);
    request.setAttribute("system", server);
    request.setAttribute("combo", getComboList(request));
    request.setAttribute(SELECTOR, request.getParameter(SELECTOR));

    return getStrutsDelegate()
        .forwardParams(mapping.findForward(RhnHelper.DEFAULT_FORWARD), params);
  }
Ejemplo n.º 3
0
 /** {@inheritDoc} */
 public ActionForward execute(
     ActionMapping mapping,
     ActionForm formIn,
     HttpServletRequest request,
     HttpServletResponse response) {
   RequestContext ctx = new RequestContext(request);
   Server server = ctx.lookupAndBindServer();
   User user = ctx.getCurrentUser();
   SdcHelper.ssmCheck(ctx.getRequest(), server.getId(), user);
   DynaActionForm form = (DynaActionForm) formIn;
   SystemRecord rec = (SystemRecord) getCobblerObject(server.getCobblerId(), user);
   if (isSubmitted(form)) {
     if (!Boolean.valueOf(rec.isNetbootEnabled()).equals(form.get(NETBOOT_ENABLED))) {
       rec.enableNetboot(Boolean.TRUE.equals(form.get(NETBOOT_ENABLED)));
       rec.save();
     }
   }
   form.set(NETBOOT_ENABLED, rec.isNetbootEnabled());
   return super.execute(mapping, formIn, request, response);
 }
Ejemplo n.º 4
0
  /** {@inheritDoc} */
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm formIn,
      HttpServletRequest request,
      HttpServletResponse response) {

    RequestContext context = new RequestContext(request);
    context.copyParamToAttributes("sid");
    Server server = context.lookupAndBindServer();

    ListRhnSetHelper helper =
        new ListRhnSetHelper(this, request, RhnSetDecl.setForSystemCrashes(server));
    helper.execute();
    if (helper.isDispatched()) {
      return handleSubmit(mapping, context, server);
    }

    SdcHelper.ssmCheck(request, server.getId(), context.getCurrentUser());

    return mapping.findForward(RhnHelper.DEFAULT_FORWARD);
  }
  /** {@inheritDoc} */
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm formIn,
      HttpServletRequest request,
      HttpServletResponse response) {
    RequestContext context = new RequestContext(request);
    User user = context.getCurrentUser();
    Long sid = context.getRequiredParam("sid");
    Server server = SystemManager.lookupByIdAndUser(sid, user);
    Long xid = context.getRequiredParam("xid");
    XccdfTestResult testResult = ScapFactory.lookupTestResultByIdAndSid(xid, server.getId());
    request.setAttribute("testResult", testResult);
    request.setAttribute("system", server);

    ListHelper helper = new ListHelper(this, request);
    helper.execute();

    request.setAttribute(
        ListTagHelper.PARENT_URL, request.getRequestURI() + "?sid=" + sid + "&xid=" + xid);
    SdcHelper.ssmCheck(request, sid, user);

    return mapping.findForward(RhnHelper.DEFAULT_FORWARD);
  }
  /**
   * The first step in the wizard
   *
   * @param mapping ActionMapping for struts
   * @param form DynaActionForm representing the form
   * @param ctx RequestContext request context
   * @param response HttpServletResponse response object
   * @param step WizardStep what step are we on?
   * @return ActionForward struts action forward
   * @throws Exception if something goes amiss
   */
  public ActionForward runFirst(
      ActionMapping mapping,
      DynaActionForm form,
      RequestContext ctx,
      HttpServletResponse response,
      WizardStep step)
      throws Exception {
    log.debug("runFirst");
    Long sid = (Long) form.get(RequestContext.SID);
    User user = ctx.getCurrentUser();

    KickstartScheduleCommand cmd = getKickstartScheduleCommand(sid, user);

    Server system = SystemManager.lookupByIdAndUser(sid, user);
    if (system.isVirtualGuest()
        && VirtualInstanceFactory.getInstance()
            .getParaVirtType()
            .equals(system.getVirtualInstance().getType())) {
      ctx.getRequest().setAttribute(IS_VIRTUAL_GUEST, Boolean.TRUE.toString());

      ctx.getRequest().setAttribute(VIRT_HOST_IS_REGISTERED, Boolean.FALSE.toString());
      if (system.getVirtualInstance().getHostSystem() != null) {
        Long hostSid = system.getVirtualInstance().getHostSystem().getId();
        ctx.getRequest().setAttribute(VIRT_HOST_IS_REGISTERED, Boolean.TRUE.toString());
        ctx.getRequest().setAttribute(HOST_SID, hostSid);
      }
    } else {
      ctx.getRequest().setAttribute(IS_VIRTUAL_GUEST, Boolean.FALSE.toString());
    }

    addRequestAttributes(ctx, cmd, form);
    checkForKickstart(form, cmd, ctx);
    setupProxyInfo(ctx);
    if (StringUtils.isBlank(form.getString(PROXY_HOST))) {
      form.set(PROXY_HOST, "");
    }
    // create and prepopulate the date picker.
    getStrutsDelegate()
        .prepopulateDatePicker(ctx.getRequest(), form, "date", DatePicker.YEAR_RANGE_POSITIVE);

    SdcHelper.ssmCheck(ctx.getRequest(), system.getId(), user);
    Map params = new HashMap<String, String>();
    params.put(RequestContext.SID, sid);
    ListHelper helper = new ListHelper(new Profiles(), ctx.getRequest(), params);
    helper.execute();
    if (!StringUtils.isBlank(form.getString(RequestContext.COBBLER_ID))) {
      ListTagHelper.selectRadioValue(
          ListHelper.LIST, form.getString(RequestContext.COBBLER_ID), ctx.getRequest());
    } else if (system.getCobblerId() != null) {
      // if nothing is selected by the user yet, use the cobbler
      //  system record to pre-select something.
      SystemRecord rec =
          SystemRecord.lookupById(
              CobblerXMLRPCHelper.getConnection(ConfigDefaults.get().getCobblerAutomatedUser()),
              system.getCobblerId());
      if (rec != null) {
        ListTagHelper.selectRadioValue(ListHelper.LIST, rec.getProfile().getId(), ctx.getRequest());
      }
    }

    ActionForward retval = mapping.findForward("first");
    return retval;
  }