Example #1
0
  /** Returns the connect hosts dialog content. */
  @Override
  protected JComponent getInputPane() {
    final JPanel pane = new JPanel(new SpringLayout());
    final StringBuilder text = new StringBuilder();
    for (final Host host : getCluster().getHosts()) {
      text.append(host.getName());
      text.append(" connecting...\n");
    }
    pane.add(getAnswerPane(text.toString()));

    SpringUtilities.makeCompactGrid(
        pane, 1, 1, // rows, cols
        1, 1, // initX, initY
        1, 1); // xPad, yPad
    return pane;
  }
Example #2
0
  /** Returns info panel. */
  @Override
  public JComponent getInfoPanel() {
    if (getBrowser().getClusterBrowser() == null) {
      return new JPanel();
    }
    final Font f = new Font("Monospaced", Font.PLAIN, Tools.getConfigData().scaled(12));
    crmShowInProgress = true;
    final JTextArea ta = new JTextArea(Tools.getString("HostInfo.crmShellLoading"));
    ta.setEditable(false);
    ta.setFont(f);

    final MyButton crmConfigureCommitButton =
        new MyButton(Tools.getString("HostInfo.crmShellCommitButton"), Browser.APPLY_ICON);
    registerComponentEnableAccessMode(
        crmConfigureCommitButton, new AccessMode(ConfigData.AccessType.ADMIN, false));
    final MyButton hostInfoButton = new MyButton(Tools.getString("HostInfo.crmShellStatusButton"));
    hostInfoButton.miniButton();

    final MyButton crmConfigureShowButton =
        new MyButton(Tools.getString("HostInfo.crmShellShowButton"));
    crmConfigureShowButton.miniButton();
    crmConfigureCommitButton.setEnabled(false);
    final ExecCallback execCallback =
        new ExecCallback() {
          @Override
          public void done(final String ans) {
            ta.setText(ans);
            SwingUtilities.invokeLater(
                new Runnable() {
                  public void run() {
                    crmConfigureShowButton.setEnabled(true);
                    hostInfoButton.setEnabled(true);
                    crmShowInProgress = false;
                  }
                });
          }

          @Override
          public void doneError(final String ans, final int exitCode) {
            ta.setText(ans);
            Tools.sshError(host, "", ans, "", exitCode);
            SwingUtilities.invokeLater(
                new Runnable() {
                  public void run() {
                    crmConfigureCommitButton.setEnabled(false);
                  }
                });
          }
        };
    hostInfoButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            registerComponentEditAccessMode(ta, new AccessMode(ConfigData.AccessType.GOD, false));
            crmInfo = true;
            hostInfoButton.setEnabled(false);
            crmConfigureCommitButton.setEnabled(false);
            String command = "HostBrowser.getHostInfo";
            if (!host.isCsInit()) {
              command = "HostBrowser.getHostInfoHeartbeat";
            }
            host.execCommand(
                command,
                execCallback,
                null, /* ConvertCmdCallback */
                false, /* outputVisible */
                SSH.DEFAULT_COMMAND_TIMEOUT);
          }
        });
    host.registerEnableOnConnect(hostInfoButton);

    crmConfigureShowButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            registerComponentEditAccessMode(ta, new AccessMode(ConfigData.AccessType.ADMIN, false));
            updateAdvancedPanels();
            crmShowInProgress = true;
            crmInfo = false;
            crmConfigureShowButton.setEnabled(false);
            crmConfigureCommitButton.setEnabled(false);
            host.execCommand(
                "HostBrowser.getCrmConfigureShow",
                execCallback,
                null, /* ConvertCmdCallback */
                false, /* outputVisible */
                SSH.DEFAULT_COMMAND_TIMEOUT);
          }
        });
    final CRMGraph crmg = getBrowser().getClusterBrowser().getCRMGraph();
    final Document taDocument = ta.getDocument();
    taDocument.addDocumentListener(
        new DocumentListener() {
          private void update() {
            if (!crmShowInProgress && !crmInfo) {
              crmConfigureCommitButton.setEnabled(true);
            }
          }

          public void changedUpdate(final DocumentEvent documentEvent) {
            update();
          }

          public void insertUpdate(final DocumentEvent documentEvent) {
            update();
          }

          public void removeUpdate(final DocumentEvent documentEvent) {
            update();
          }
        });

    final ButtonCallback buttonCallback =
        new ButtonCallback() {
          private volatile boolean mouseStillOver = false;

          /** Whether the whole thing should be enabled. */
          @Override
          public boolean isEnabled() {
            if (Tools.versionBeforePacemaker(host)) {
              return false;
            }
            return true;
          }

          @Override
          public void mouseOut() {
            if (!isEnabled()) {
              return;
            }
            mouseStillOver = false;
            crmg.stopTestAnimation(crmConfigureCommitButton);
            crmConfigureCommitButton.setToolTipText(null);
          }

          @Override
          public void mouseOver() {
            if (!isEnabled()) {
              return;
            }
            mouseStillOver = true;
            crmConfigureCommitButton.setToolTipText(ClusterBrowser.STARTING_PTEST_TOOLTIP);
            crmConfigureCommitButton.setToolTipBackground(
                Tools.getDefaultColor("ClusterBrowser.Test.Tooltip.Background"));
            Tools.sleep(250);
            if (!mouseStillOver) {
              return;
            }
            mouseStillOver = false;
            final CountDownLatch startTestLatch = new CountDownLatch(1);
            crmg.startTestAnimation(crmConfigureCommitButton, startTestLatch);
            final Host dcHost = getBrowser().getClusterBrowser().getDCHost();
            getBrowser().getClusterBrowser().ptestLockAcquire();
            final ClusterStatus clStatus = getBrowser().getClusterBrowser().getClusterStatus();
            clStatus.setPtestData(null);
            CRM.crmConfigureCommit(host, ta.getText(), true);
            final PtestData ptestData = new PtestData(CRM.getPtest(dcHost));
            crmConfigureCommitButton.setToolTipText(ptestData.getToolTip());
            clStatus.setPtestData(ptestData);
            getBrowser().getClusterBrowser().ptestLockRelease();
            startTestLatch.countDown();
          }
        };
    addMouseOverListener(crmConfigureCommitButton, buttonCallback);
    crmConfigureCommitButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            crmConfigureCommitButton.setEnabled(false);
            final Thread thread =
                new Thread(
                    new Runnable() {
                      @Override
                      public void run() {
                        getBrowser().getClusterBrowser().clStatusLock();
                        final String ret = CRM.crmConfigureCommit(host, ta.getText(), false);
                        getBrowser().getClusterBrowser().clStatusUnlock();
                      }
                    });
            thread.start();
          }
        });

    final JPanel mainPanel = new JPanel();
    mainPanel.setBackground(HostBrowser.PANEL_BACKGROUND);
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));

    final JPanel buttonPanel = new JPanel(new BorderLayout());
    buttonPanel.setBackground(HostBrowser.BUTTON_PANEL_BACKGROUND);
    buttonPanel.setMinimumSize(new Dimension(0, 50));
    buttonPanel.setPreferredSize(new Dimension(0, 50));
    buttonPanel.setMaximumSize(new Dimension(Short.MAX_VALUE, 50));
    mainPanel.add(buttonPanel);

    /* Actions */
    buttonPanel.add(getActionsButton(), BorderLayout.EAST);
    final JPanel p = new JPanel(new SpringLayout());
    p.setBackground(HostBrowser.BUTTON_PANEL_BACKGROUND);

    p.add(hostInfoButton);
    p.add(crmConfigureShowButton);
    p.add(crmConfigureCommitButton);

    p.add(new JLabel(""));
    SpringUtilities.makeCompactGrid(
        p, 1, 3, // rows, cols
        1, 1, // initX, initY
        1, 1); // xPad, yPad
    mainPanel.setMinimumSize(
        new Dimension(
            Tools.getDefaultSize("HostBrowser.ResourceInfoArea.Width"),
            Tools.getDefaultSize("HostBrowser.ResourceInfoArea.Height")));
    mainPanel.setPreferredSize(
        new Dimension(
            Tools.getDefaultSize("HostBrowser.ResourceInfoArea.Width"),
            Tools.getDefaultSize("HostBrowser.ResourceInfoArea.Height")));
    buttonPanel.add(p);
    mainPanel.add(new JLabel(Tools.getString("HostInfo.crmShellInfo")));
    mainPanel.add(new JScrollPane(ta));
    String command = "HostBrowser.getHostInfo";
    if (!host.isCsInit()) {
      command = "HostBrowser.getHostInfoHeartbeat";
    }
    host.execCommand(
        command,
        execCallback,
        null, /* ConvertCmdCallback */
        false, /* outputVisible */
        SSH.DEFAULT_COMMAND_TIMEOUT);
    return mainPanel;
  }
Example #3
0
  /** Returns the input pane. */
  @Override
  protected JComponent getInputPane() {
    createButton.setEnabled(false);
    final JPanel pane = new JPanel(new SpringLayout());
    /* vg name */
    final JPanel inputPane = new JPanel(new SpringLayout());
    inputPane.setBackground(Browser.BUTTON_PANEL_BACKGROUND);

    /* find next free group volume name */
    String defaultName;
    final Set<String> volumeGroups = host.getVolumeGroupNames();
    int i = 0;
    while (true) {
      defaultName = "vg" + String.format("%02d", i);
      if (volumeGroups == null || !volumeGroups.contains(defaultName)) {
        break;
      }
      i++;
    }
    vgNameWi =
        WidgetFactory.createInstance(
            Widget.Type.TEXTFIELD,
            defaultName,
            Widget.NO_ITEMS,
            Widget.NO_REGEXP,
            250,
            Widget.NO_ABBRV,
            new AccessMode(ConfigData.AccessType.OP, !AccessMode.ADVANCED),
            Widget.NO_BUTTON);
    inputPane.add(new JLabel("VG Name"));
    inputPane.add(vgNameWi);

    createButton.addActionListener(new CreateActionListener());
    inputPane.add(createButton);
    SpringUtilities.makeCompactGrid(
        inputPane, 1, 3, /* rows, cols */ 1, 1, /* initX, initY */ 1, 1); /* xPad, yPad */

    pane.add(inputPane);
    /* Volume groups. */
    final JPanel pvsPane = new JPanel(new FlowLayout(FlowLayout.LEFT));
    final Set<String> selectedPVs = new HashSet<String>();
    final Set<Host> selectedHosts = new HashSet<Host>();
    for (final BlockDevInfo sbdi : selectedBlockDevInfos) {
      if (sbdi.getBlockDevice().isDrbd()) {
        selectedPVs.add(sbdi.getBlockDevice().getDrbdBlockDevice().getName());
      } else {
        selectedPVs.add(sbdi.getName());
      }
      selectedHosts.add(sbdi.getHost());
    }
    pvCheckBoxes = getPVCheckBoxes(selectedPVs);
    pvsPane.add(new JLabel("Select physical volumes: "));
    for (final String pvName : pvCheckBoxes.keySet()) {
      pvCheckBoxes.get(pvName).addItemListener(new ItemChangeListener(true));
      pvsPane.add(pvCheckBoxes.get(pvName));
    }
    final JScrollPane pvSP = new JScrollPane(pvsPane);
    pvSP.setPreferredSize(new Dimension(0, 45));
    pane.add(pvSP);

    final JPanel hostsPane = new JPanel(new FlowLayout(FlowLayout.LEFT));
    final Cluster cluster = host.getCluster();
    hostCheckBoxes = Tools.getHostCheckBoxes(cluster);
    hostsPane.add(new JLabel("Select Hosts: "));
    for (final Host h : hostCheckBoxes.keySet()) {
      hostCheckBoxes.get(h).addItemListener(new ItemChangeListener(true));
      if (host == h) {
        hostCheckBoxes.get(h).setEnabled(false);
        hostCheckBoxes.get(h).setSelected(true);
      } else if (isOneDrbd(selectedBlockDevInfos)) {
        hostCheckBoxes.get(h).setEnabled(false);
        hostCheckBoxes.get(h).setSelected(false);
      } else if (hostHasPVS(h)) {
        hostCheckBoxes.get(h).setEnabled(true);
        hostCheckBoxes.get(h).setSelected(selectedHosts.contains(h));
      } else {
        hostCheckBoxes.get(h).setEnabled(false);
        hostCheckBoxes.get(h).setSelected(false);
      }
      hostsPane.add(hostCheckBoxes.get(h));
    }
    final JScrollPane sp = new JScrollPane(hostsPane);
    sp.setPreferredSize(new Dimension(0, 45));
    pane.add(sp);
    pane.add(getProgressBarPane(null));
    pane.add(getAnswerPane(""));
    SpringUtilities.makeCompactGrid(
        pane, 5, 1, /* rows, cols */ 0, 0, /* initX, initY */ 0, 0); /* xPad, yPad */
    checkButtons();
    return pane;
  }
Example #4
0
  /** Returns the input pane. */
  protected JComponent getInputPane() {
    resizeButton.setEnabled(false);
    final JPanel pane = new JPanel(new SpringLayout());
    final JPanel inputPane = new JPanel(new SpringLayout());
    inputPane.setBackground(Browser.BUTTON_PANEL_BACKGROUND);
    /* old size */
    final JLabel oldSizeLabel = new JLabel("Current Size");
    oldSizeLabel.setEnabled(false);

    final String oldBlockSize = blockDevInfo.getBlockDevice().getBlockSize();
    oldSizeWi =
        new TextfieldWithUnit(
            Tools.convertKilobytes(oldBlockSize),
            getUnits(),
            Widget.NO_REGEXP,
            250,
            Widget.NO_ABBRV,
            new AccessMode(ConfigData.AccessType.OP, !AccessMode.ADVANCED),
            Widget.NO_BUTTON);
    oldSizeWi.setEnabled(false);
    inputPane.add(oldSizeLabel);
    inputPane.add(oldSizeWi);
    inputPane.add(new JLabel());

    final String maxBlockSize = getMaxBlockSize();
    /* size */
    final String newBlockSize =
        Long.toString((Long.parseLong(oldBlockSize) + Long.parseLong(maxBlockSize)) / 2);
    final JLabel sizeLabel = new JLabel("New Size");

    sizeWi =
        new TextfieldWithUnit(
            Tools.convertKilobytes(newBlockSize),
            getUnits(),
            Widget.NO_REGEXP,
            250,
            Widget.NO_ABBRV,
            new AccessMode(ConfigData.AccessType.OP, !AccessMode.ADVANCED),
            Widget.NO_BUTTON);
    inputPane.add(sizeLabel);
    inputPane.add(sizeWi);
    resizeButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            final Thread thread =
                new Thread(
                    new Runnable() {
                      @Override
                      public void run() {
                        if (checkDRBD()) {
                          Tools.invokeAndWait(new EnableResizeRunnable(false));
                          disableComponents();
                          getProgressBar().start(RESIZE_TIMEOUT * hostCheckBoxes.size());
                          final boolean ret = resize(sizeWi.getStringValue());
                          final Host host = blockDevInfo.getHost();
                          host.getBrowser().getClusterBrowser().updateHWInfo(host);
                          setComboBoxes();
                          if (ret) {
                            progressBarDone();
                          } else {
                            progressBarDoneError();
                          }
                          enableComponents();
                        }
                      }
                    });
            thread.start();
          }
        });

    inputPane.add(resizeButton);
    /* max size */
    final JLabel maxSizeLabel = new JLabel("Max Size");
    maxSizeLabel.setEnabled(false);
    maxSizeWi =
        new TextfieldWithUnit(
            Tools.convertKilobytes(maxBlockSize),
            getUnits(),
            Widget.NO_REGEXP,
            250,
            Widget.NO_ABBRV,
            new AccessMode(ConfigData.AccessType.OP, !AccessMode.ADVANCED),
            Widget.NO_BUTTON);
    maxSizeWi.setEnabled(false);
    inputPane.add(maxSizeLabel);
    inputPane.add(maxSizeWi);
    inputPane.add(new JLabel());
    sizeWi.addListeners(
        new WidgetListener() {
          @Override
          public void check(final Object value) {
            checkButtons();
          }
        });

    SpringUtilities.makeCompactGrid(
        inputPane, 3, 3, /* rows, cols */ 1, 1, /* initX, initY */ 1, 1); /* xPad, yPad */

    pane.add(inputPane);
    final JPanel hostsPane = new JPanel(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
    final Cluster cluster = blockDevInfo.getHost().getCluster();
    hostCheckBoxes = Tools.getHostCheckBoxes(cluster);
    hostsPane.add(new JLabel("Select Hosts: "));
    final Host host = blockDevInfo.getHost();
    final String lv = blockDevInfo.getBlockDevice().getLogicalVolume();
    for (final Host h : hostCheckBoxes.keySet()) {
      final Set<String> allLVS = h.getAllLogicalVolumes();
      hostCheckBoxes
          .get(h)
          .addItemListener(
              new ItemListener() {
                @Override
                public void itemStateChanged(final ItemEvent e) {
                  checkButtons();
                }
              });
      if (host == h) {
        hostCheckBoxes.get(h).setEnabled(false);
        hostCheckBoxes.get(h).setSelected(true);
      } else if (blockDevInfo.getBlockDevice().isDrbd()
          && blockDevInfo.getOtherBlockDevInfo().getHost() == h) {
        hostCheckBoxes.get(h).setEnabled(false);
        hostCheckBoxes.get(h).setSelected(true);
      } else if (!blockDevInfo.getBlockDevice().isDrbd() && !allLVS.contains(lv)) {
        hostCheckBoxes.get(h).setEnabled(false);
        hostCheckBoxes.get(h).setSelected(false);
      } else {
        hostCheckBoxes.get(h).setEnabled(true);
        hostCheckBoxes.get(h).setSelected(false);
      }
      hostsPane.add(hostCheckBoxes.get(h));
    }
    final javax.swing.JScrollPane sp = new javax.swing.JScrollPane(hostsPane);
    sp.setPreferredSize(new java.awt.Dimension(0, 45));
    pane.add(sp);
    pane.add(getProgressBarPane(null));
    pane.add(getAnswerPane(""));
    SpringUtilities.makeCompactGrid(
        pane, 4, 1, /* rows, cols */ 0, 0, /* initX, initY */ 0, 0); /* xPad, yPad */
    checkButtons();
    return pane;
  }