Example #1
0
 /** Applies the changes and returns next dialog (BlockDev). */
 @Override
 public WizardDialog nextDialog() {
   final DrbdResourceInfo dri = getDrbdVolumeInfo().getDrbdResourceInfo();
   final DrbdInfo drbdInfo = dri.getDrbdInfo();
   final boolean protocolInNetSection = drbdInfo.atLeastVersion("8.4");
   if (drbdInfo.getDrbdResources().size() <= 1) {
     for (final String commonP : COMMON_PARAMS) {
       if (!protocolInNetSection && PROTOCOL.equals(commonP)) {
         continue;
       }
       final String value = dri.getComboBoxValue(commonP);
       drbdInfo.getResource().setValue(commonP, value);
       drbdInfo.getWidget(commonP, null).setValue(value);
     }
   }
   Tools.waitForSwing();
   drbdInfo.apply(false);
   dri.apply(false);
   return new Volume(this, getDrbdVolumeInfo());
 }
Example #2
0
  /** Applies the the whole group if for example an order has changed. */
  void applyWhole(
      final Host dcHost,
      final boolean createGroup,
      final List<String> newOrder,
      final boolean testOnly) {
    final String[] params = getParametersFromXML();
    if (!testOnly) {
      Tools.invokeAndWait(
          new Runnable() {
            @Override
            public void run() {
              final MyButton ab = getApplyButton();
              if (ab != null) {
                ab.setEnabled(false);
              }
            }
          });
    }
    getInfoPanel();
    waitForInfoPanel();

    final Map<String, String> groupMetaArgs = new LinkedHashMap<String, String>();
    for (String param : params) {
      if (GUI_ID.equals(param) || PCMK_ID.equals(param)) {
        continue;
      }
      String value = getComboBoxValue(param);
      if (value == null) {
        value = "";
      }
      if (value.equals(getParamDefault(param))) {
        continue;
      }
      if (!"".equals(value)) {
        if (CRMXML.GROUP_ORDERED_META_ATTR.equals(param)) {
          groupMetaArgs.put("ordered", value);
        } else {
          groupMetaArgs.put(param, value);
        }
      }
    }
    final Map<String, Map<String, String>> pacemakerResAttrs =
        new HashMap<String, Map<String, String>>();
    final Map<String, Map<String, String>> pacemakerResArgs =
        new HashMap<String, Map<String, String>>();
    final Map<String, Map<String, String>> pacemakerMetaArgs =
        new HashMap<String, Map<String, String>>();
    final Map<String, String> instanceAttrId = new HashMap<String, String>();
    final Map<String, Map<String, String>> nvpairIdsHash =
        new HashMap<String, Map<String, String>>();
    final Map<String, Map<String, Map<String, String>>> pacemakerOps =
        new HashMap<String, Map<String, Map<String, String>>>();
    final Map<String, String> operationsId = new HashMap<String, String>();
    final Map<String, String> metaAttrsRefId = new HashMap<String, String>();
    final Map<String, String> operationsRefId = new HashMap<String, String>();
    final Map<String, Boolean> stonith = new HashMap<String, Boolean>();

    final ClusterStatus cs = getBrowser().getClusterStatus();
    for (final String resId : newOrder) {
      final ServiceInfo gsi = getBrowser().getServiceInfoFromCRMId(resId);
      if (gsi == null) {
        continue;
      }
      Tools.invokeAndWait(
          new Runnable() {
            @Override
            public void run() {
              gsi.getInfoPanel();
            }
          });
    }
    Tools.waitForSwing();
    for (final String resId : newOrder) {
      final ServiceInfo gsi = getBrowser().getServiceInfoFromCRMId(resId);
      if (gsi == null) {
        continue;
      }
      pacemakerResAttrs.put(resId, gsi.getPacemakerResAttrs(testOnly));
      pacemakerResArgs.put(resId, gsi.getPacemakerResArgs());
      pacemakerMetaArgs.put(resId, gsi.getPacemakerMetaArgs());
      instanceAttrId.put(resId, cs.getResourceInstanceAttrId(resId));
      nvpairIdsHash.put(resId, cs.getParametersNvpairsIds(resId));
      pacemakerOps.put(resId, gsi.getOperations(resId));
      operationsId.put(resId, cs.getOperationsId(resId));
      metaAttrsRefId.put(resId, gsi.getMetaAttrsRefId());
      operationsRefId.put(resId, gsi.getOperationsRefId());
      stonith.put(resId, gsi.getResourceAgent().isStonith());
    }
    final CloneInfo ci = getCloneInfo();
    String cloneId = null;
    boolean master = false;
    final Map<String, String> cloneMetaArgs = new LinkedHashMap<String, String>();
    String cloneMetaAttrsRefIds = null;
    if (createGroup && ci != null) {
      cloneId = ci.getHeartbeatId(testOnly);
      final String[] cloneParams = ci.getParametersFromXML();
      master = ci.getService().isMaster();
      cloneMetaAttrsRefIds = ci.getMetaAttrsRefId();
      for (String param : cloneParams) {
        if (GUI_ID.equals(param) || PCMK_ID.equals(param)) {
          continue;
        }
        final String value = ci.getComboBoxValue(param);
        if (value.equals(ci.getParamDefault(param))) {
          continue;
        }
        if (!GUI_ID.equals(param) && !"".equals(value)) {
          cloneMetaArgs.put(param, value);
        }
      }
    }
    CRM.replaceGroup(
        createGroup,
        dcHost,
        cloneId,
        master,
        cloneMetaArgs,
        cloneMetaAttrsRefIds,
        newOrder,
        groupMetaArgs,
        getHeartbeatId(testOnly),
        pacemakerResAttrs,
        pacemakerResArgs,
        pacemakerMetaArgs,
        instanceAttrId,
        nvpairIdsHash,
        pacemakerOps,
        operationsId,
        metaAttrsRefId,
        getMetaAttrsRefId(),
        operationsRefId,
        stonith,
        testOnly);
    if (!testOnly) {
      storeComboBoxValues(params);
      getBrowser().reload(getNode(), false);
    }
    getBrowser().getCRMGraph().repaint();
  }
Example #3
0
  /** Returns input pane where user can configure a drbd resource. */
  @Override
  protected JComponent getInputPane() {
    final DrbdResourceInfo dri = getDrbdVolumeInfo().getDrbdResourceInfo();
    final DrbdInfo drbdInfo = dri.getDrbdInfo();
    dri.getInfoPanel();
    dri.waitForInfoPanel();
    Tools.waitForSwing();
    final JPanel inputPane = new JPanel();
    inputPane.setLayout(new BoxLayout(inputPane, BoxLayout.X_AXIS));

    final JPanel optionsPanel = new JPanel();
    optionsPanel.setLayout(new BoxLayout(optionsPanel, BoxLayout.Y_AXIS));
    optionsPanel.setAlignmentY(Component.TOP_ALIGNMENT);
    /* common options */
    final Map<String, String> commonPreferredValue = new HashMap<String, String>();
    commonPreferredValue.put(PROTOCOL, "C");
    commonPreferredValue.put(DEGR_WFC_TIMEOUT_PARAM, "0");
    commonPreferredValue.put(CRAM_HMAC_ALG, "sha1");
    commonPreferredValue.put(SHARED_SECRET, getRandomSecret());
    commonPreferredValue.put(ON_IO_ERROR, "detach");
    if (drbdInfo.getDrbdResources().size() <= 1) {
      for (final String commonP : COMMON_PARAMS) {
        /* for the first resource set common options. */
        final String commonValue = drbdInfo.getResource().getValue(commonP);
        if (commonPreferredValue.containsKey(commonP)) {
          final String defaultValue = drbdInfo.getParamDefault(commonP);
          if ((defaultValue == null && "".equals(commonValue))
              || (defaultValue != null && defaultValue.equals(commonValue))) {
            drbdInfo.getWidget(commonP, null).setValue(commonPreferredValue.get(commonP));
            dri.getResource().setValue(commonP, commonPreferredValue.get(commonP));
          } else {
            dri.getResource().setValue(commonP, commonValue);
          }
        }
      }
    } else {
      /* resource options, if not defined in common section. */
      for (final String commonP : COMMON_PARAMS) {
        final String commonValue = drbdInfo.getResource().getValue(commonP);
        if ("".equals(commonValue) && commonPreferredValue.containsKey(commonP)) {
          dri.getResource().setValue(commonP, commonPreferredValue.get(commonP));
        }
      }
    }

    /* address combo boxes */
    dri.addHostAddresses(
        optionsPanel,
        ClusterBrowser.SERVICE_LABEL_WIDTH,
        ClusterBrowser.SERVICE_FIELD_WIDTH,
        true,
        buttonClass(nextButton()));
    dri.addWizardParams(
        optionsPanel,
        PARAMS,
        buttonClass(nextButton()),
        Tools.getDefaultSize("Dialog.DrbdConfig.Resource.LabelWidth"),
        Tools.getDefaultSize("Dialog.DrbdConfig.Resource.FieldWidth"),
        null);

    inputPane.add(optionsPanel);
    final JScrollPane sp = new JScrollPane(inputPane);
    sp.setMaximumSize(new Dimension(Short.MAX_VALUE, 200));
    sp.setPreferredSize(new Dimension(Short.MAX_VALUE, 200));
    return sp;
  }